Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 182595 | Differences between
and this patch

Collapse All | Expand All

(-)vmnet-only.old/bridge.c (-3 / +61 lines)
Lines 1083-1094 Link Here
1083
VNetBridgeComputeHeaderPos(struct sk_buff *skb) // IN: buffer to examine
1083
VNetBridgeComputeHeaderPos(struct sk_buff *skb) // IN: buffer to examine
1084
{
1084
{
1085
   /* Maybe some kernel gets it right... */
1085
   /* Maybe some kernel gets it right... */
1086
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1087
   if (skb_transport_header(skb) != skb_network_header(skb)) {
1088
#else
1086
   if (skb->h.raw != skb->nh.raw) {
1089
   if (skb->h.raw != skb->nh.raw) {
1090
#endif
1087
      return;
1091
      return;
1088
   }
1092
   }
1093
1089
   switch (be16_to_cpu(skb->protocol)) {
1094
   switch (be16_to_cpu(skb->protocol)) {
1090
      case ETH_P_IP:
1095
      case ETH_P_IP:
1096
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1097
         skb->transport_header = skb->network_header + (skb_network_header(skb)[0] & 0x0F) * 4;
1098
#else
1091
         skb->h.raw = skb->nh.raw + (skb->nh.raw[0] & 0x0F) * 4;
1099
         skb->h.raw = skb->nh.raw + (skb->nh.raw[0] & 0x0F) * 4;
1100
#endif
1092
	 return;
1101
	 return;
1093
      default:
1102
      default:
1094
         LOG(3, (KERN_DEBUG "Unknown EII protocol %04X: csum at %d\n", 
1103
         LOG(3, (KERN_DEBUG "Unknown EII protocol %04X: csum at %d\n", 
Lines 1146-1164 Link Here
1146
   if (((struct ethhdr *)skb->mac.raw)->h_proto != htons(ETH_P_IP)) {
1155
   if (((struct ethhdr *)skb->mac.raw)->h_proto != htons(ETH_P_IP)) {
1147
      return ERR_PTR(-EPFNOSUPPORT);
1156
      return ERR_PTR(-EPFNOSUPPORT);
1148
   }
1157
   }
1149
1158
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1159
   if (((struct iphdr *)skb_network_header(skb))->protocol != IPPROTO_TCP) {
1160
#else
1150
   if (skb->nh.iph->protocol != IPPROTO_TCP) {
1161
   if (skb->nh.iph->protocol != IPPROTO_TCP) {
1162
#endif
1151
      return ERR_PTR(-EPROTONOSUPPORT);
1163
      return ERR_PTR(-EPROTONOSUPPORT);
1152
   }
1164
   }
1153
1165
1166
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1167
   macHdrLen = skb->network_header - skb->mac_header;
1168
   ipHdrLen = ((struct iphdr *)skb_network_header(skb))->ihl << 2;
1169
   tcpHdrLen = ((struct tcphdr *)skb_transport_header(skb))->doff << 2;
1170
#else
1154
   macHdrLen = skb->nh.raw - skb->mac.raw;
1171
   macHdrLen = skb->nh.raw - skb->mac.raw;
1155
   ipHdrLen = skb->nh.iph->ihl << 2;
1172
   ipHdrLen = skb->nh.iph->ihl << 2;
1156
   tcpHdrLen = skb->h.th->doff << 2;
1173
   tcpHdrLen = skb->h.th->doff << 2;
1174
#endif
1157
   allHdrLen = macHdrLen + ipHdrLen + tcpHdrLen;
1175
   allHdrLen = macHdrLen + ipHdrLen + tcpHdrLen;
1158
1176
1177
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1178
   ipID = ntohs(((struct iphdr *)skb_network_header(skb))->id);
1179
   seqNo = ntohl(((struct tcphdr *)skb_transport_header(skb))->seq);
1180
#else
1159
   ipID = ntohs(skb->nh.iph->id);
1181
   ipID = ntohs(skb->nh.iph->id);
1160
   seqNo = ntohl(skb->h.th->seq);
1182
   seqNo = ntohl(skb->h.th->seq);
1161
1183
#endif
1162
   /* Host TCP stack populated this (MSS) for the host NIC driver */
1184
   /* Host TCP stack populated this (MSS) for the host NIC driver */
1163
   bytesPerPacket = skb_shinfo(skb)->tso_size;
1185
   bytesPerPacket = skb_shinfo(skb)->tso_size;
1164
1186
Lines 1194-1203 Link Here
1194
      memcpy(skb_put(newSkb, allHdrLen), skb->data, allHdrLen);
1216
      memcpy(skb_put(newSkb, allHdrLen), skb->data, allHdrLen);
1195
1217
1196
      /* Fix up pointers to different layers */
1218
      /* Fix up pointers to different layers */
1219
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1220
      skb_reset_mac_header(newSkb);
1221
      skb_set_network_header(newSkb, macHdrLen);
1222
      skb_set_transport_header(newSkb, macHdrLen + ipHdrLen);
1223
#else
1197
      newSkb->mac.raw = newSkb->data;
1224
      newSkb->mac.raw = newSkb->data;
1198
      newSkb->nh.raw = newSkb->data + macHdrLen;
1225
      newSkb->nh.raw = newSkb->data + macHdrLen;
1199
      newSkb->h.raw = newSkb->nh.raw + ipHdrLen;
1226
      newSkb->h.raw = newSkb->nh.raw + ipHdrLen;
1200
1227
#endif
1201
      /* Payload copy */
1228
      /* Payload copy */
1202
      skb_copy_bits(skb, curByteOffset, newSkb->tail, payloadSize);
1229
      skb_copy_bits(skb, curByteOffset, newSkb->tail, payloadSize);
1203
      skb_put(newSkb, payloadSize);
1230
      skb_put(newSkb, payloadSize);
Lines 1206-1211 Link Here
1206
      bytesLeft -= payloadSize;
1233
      bytesLeft -= payloadSize;
1207
1234
1208
      /* Fix up IP hdr */
1235
      /* Fix up IP hdr */
1236
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1237
      ((struct iphdr *)skb_network_header(newSkb))->tot_len = htons(payloadSize + tcpHdrLen + ipHdrLen);
1238
      ((struct iphdr *)skb_network_header(newSkb))->id = htons(ipID);
1239
      ((struct iphdr *)skb_network_header(newSkb))->check = 0;
1240
      /* Recompute new IP checksum */
1241
      ((struct iphdr *)skb_network_header(newSkb))->check =
1242
         ip_fast_csum((uint8 *)((struct iphdr *)skb_network_header(newSkb)), ((struct iphdr *)skb_network_header(newSkb))->ihl);
1243
1244
      /* Fix up TCP hdr */
1245
      ((struct tcphdr *)skb_transport_header(newSkb))->seq = htonl(seqNo);
1246
      /* Clear FIN/PSH if not last packet */
1247
      if (bytesLeft > 0) {
1248
         ((struct tcphdr *)skb_transport_header(newSkb))->fin = 0;
1249
         ((struct tcphdr *)skb_transport_header(newSkb))->psh = 0;
1250
      }
1251
      /* Recompute partial TCP checksum */
1252
      ((struct tcphdr *)skb_transport_header(newSkb))->check =
1253
         ~csum_tcpudp_magic(((struct iphdr *)skb_network_header(newSkb))->saddr,
1254
                            ((struct iphdr *)skb_network_header(newSkb))->daddr,
1255
                            payloadSize+tcpHdrLen, IPPROTO_TCP, 0);
1256
#else
1209
      newSkb->nh.iph->tot_len = htons(payloadSize + tcpHdrLen + ipHdrLen);
1257
      newSkb->nh.iph->tot_len = htons(payloadSize + tcpHdrLen + ipHdrLen);
1210
      newSkb->nh.iph->id = htons(ipID);
1258
      newSkb->nh.iph->id = htons(ipID);
1211
      newSkb->nh.iph->check = 0;
1259
      newSkb->nh.iph->check = 0;
Lines 1225-1230 Link Here
1225
         ~csum_tcpudp_magic(newSkb->nh.iph->saddr,
1273
         ~csum_tcpudp_magic(newSkb->nh.iph->saddr,
1226
                            newSkb->nh.iph->daddr,
1274
                            newSkb->nh.iph->daddr,
1227
                            payloadSize+tcpHdrLen, IPPROTO_TCP, 0);
1275
                            payloadSize+tcpHdrLen, IPPROTO_TCP, 0);
1276
#endif
1228
1277
1229
      /* Offset of field */
1278
      /* Offset of field */
1230
      newSkb->csum = offsetof(struct tcphdr, check);
1279
      newSkb->csum = offsetof(struct tcphdr, check);
Lines 1370-1377 Link Here
1370
#  endif
1419
#  endif
1371
1420
1372
   if (bridge->smac) {
1421
   if (bridge->smac) {
1422
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1423
      if (VNetCallSMACFunc(bridge->smac, &skb, skb_mac_header(skb), 
1424
                           SMAC_CheckPacketFromHost) != 
1425
#else
1373
      if (VNetCallSMACFunc(bridge->smac, &skb, skb->mac.raw, 
1426
      if (VNetCallSMACFunc(bridge->smac, &skb, skb->mac.raw, 
1374
                           SMAC_CheckPacketFromHost) != 
1427
                           SMAC_CheckPacketFromHost) != 
1428
#endif
1375
          PacketStatusForwardPacket) {
1429
          PacketStatusForwardPacket) {
1376
         LOG(4, (KERN_NOTICE "bridge-%s: packet dropped .\n",
1430
         LOG(4, (KERN_NOTICE "bridge-%s: packet dropped .\n",
1377
                 bridge->name));
1431
                 bridge->name));
Lines 1392-1398 Link Here
1392
#endif
1446
#endif
1393
#endif
1447
#endif
1394
1448
1449
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1450
   skb_push(skb, skb->data - skb_mac_header(skb));
1451
#else
1395
   skb_push(skb, skb->data - skb->mac.raw);
1452
   skb_push(skb, skb->data - skb->mac.raw);
1453
#endif
1396
   LOG(3, (KERN_DEBUG "bridge-%s: receive %d\n",
1454
   LOG(3, (KERN_DEBUG "bridge-%s: receive %d\n",
1397
	   bridge->name, (int) skb->len));
1455
	   bridge->name, (int) skb->len));
1398
1456
(-)vmnet-only.old/filter.c (-1 / +23 lines)
Lines 229-237 Link Here
229
   /* When the host receives, hooknum is NF_IP_LOCAL_IN. */
229
   /* When the host receives, hooknum is NF_IP_LOCAL_IN. */
230
   transmit = (hooknum == NF_IP_POST_ROUTING);
230
   transmit = (hooknum == NF_IP_POST_ROUTING);
231
231
232
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
233
   ip = (struct iphdr *) skb_network_header(skb);
234
#else
232
   ip = skb->nh.iph;
235
   ip = skb->nh.iph;
236
#endif
233
   packetHeader = (uint8 *)ip;
237
   packetHeader = (uint8 *)ip;
234
238
239
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
240
   if (transmit) {
241
      /* skb all set up for us. */
242
      packet = skb_transport_header(skb);
243
   } else {
244
      /* skb hasn't had a chance to be processed by TCP yet. */
245
      packet = skb_network_header(skb) + (ip->ihl << 2);
246
   }
247
#else
235
   if (transmit) {
248
   if (transmit) {
236
      /* skb all set up for us. */
249
      /* skb all set up for us. */
237
      packet = skb->h.raw;
250
      packet = skb->h.raw;
Lines 239-245 Link Here
239
      /* skb hasn't had a chance to be processed by TCP yet. */
252
      /* skb hasn't had a chance to be processed by TCP yet. */
240
      packet = skb->nh.raw + (ip->ihl << 2);
253
      packet = skb->nh.raw + (ip->ihl << 2);
241
   }
254
   }
242
255
#endif
243
   HostFilterPrint(("PacketFilter: IP ver %d ihl %d tos %d len %d id %d\n"
256
   HostFilterPrint(("PacketFilter: IP ver %d ihl %d tos %d len %d id %d\n"
244
                    "              offset %d ttl %d proto %d xsum %d\n"
257
                    "              offset %d ttl %d proto %d xsum %d\n"
245
                    "              src 0x%08x dest 0x%08x %s\n",
258
                    "              src 0x%08x dest 0x%08x %s\n",
Lines 259-271 Link Here
259
       * know why, but in such cases, this calculation will lead to a negative
272
       * know why, but in such cases, this calculation will lead to a negative
260
       * packetLength, and the packet to be dropped.
273
       * packetLength, and the packet to be dropped.
261
       */
274
       */
275
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
276
      packetLength = skb->len - (skb->network_header - skb->mac_header) - (ip->ihl << 2);
277
#else
262
      packetLength = skb->len - (skb->nh.raw - skb->mac.raw) - (ip->ihl << 2);
278
      packetLength = skb->len - (skb->nh.raw - skb->mac.raw) - (ip->ihl << 2);
279
#endif
263
   }
280
   }
264
281
265
   if (packetLength < 0) {
282
   if (packetLength < 0) {
266
      HostFilterPrint(("PacketFilter: ill formed packet for IPv4\n"));
283
      HostFilterPrint(("PacketFilter: ill formed packet for IPv4\n"));
284
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
285
      HostFilterPrint(("skb: len %d h.raw %p nh.raw %p mac.raw %p, packetLength %d\n",
286
                       skb->len, skb_transport_header(skb), skb_network_header(skb), skb_mac_header(skb), packetLength));
287
#else
267
      HostFilterPrint(("skb: len %d h.raw %p nh.raw %p mac.raw %p, packetLength %d\n",
288
      HostFilterPrint(("skb: len %d h.raw %p nh.raw %p mac.raw %p, packetLength %d\n",
268
                       skb->len, skb->h.raw, skb->nh.raw, skb->mac.raw, packetLength));
289
                       skb->len, skb->h.raw, skb->nh.raw, skb->mac.raw, packetLength));
290
#endif
269
      verdict = NF_DROP;
291
      verdict = NF_DROP;
270
      DropPacket(VNET_FILTER_ACTION_DRP_SHORT, packetHeader, packet, 0);
292
      DropPacket(VNET_FILTER_ACTION_DRP_SHORT, packetHeader, packet, 0);
271
      goto out_unlock;
293
      goto out_unlock;
(-)vmnet-only.old/userif.c (+8 lines)
Lines 627-639 Link Here
627
    */
627
    */
628
   if (skb->pkt_type == PACKET_OUTGOING && 	/* Packet must be outgoing */
628
   if (skb->pkt_type == PACKET_OUTGOING && 	/* Packet must be outgoing */
629
       skb->ip_summed == VM_CHECKSUM_PARTIAL &&	/* Without checksum */
629
       skb->ip_summed == VM_CHECKSUM_PARTIAL &&	/* Without checksum */
630
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
631
       skb->transport_header != skb->network_header &&		/* We must know where header is */
632
#else
630
       skb->h.raw != skb->nh.raw &&		/* We must know where header is */
633
       skb->h.raw != skb->nh.raw &&		/* We must know where header is */
634
#endif
631
       skb->len == count) {			/* No truncation may occur */
635
       skb->len == count) {			/* No truncation may occur */
632
      size_t skl;
636
      size_t skl;
633
      int csum;
637
      int csum;
634
      u_int16_t csum16;
638
      u_int16_t csum16;
635
      
639
      
640
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
641
      skl = skb_transport_header(skb) - skb->data;
642
#else
636
      skl = skb->h.raw - skb->data;
643
      skl = skb->h.raw - skb->data;
644
#endif
637
      if (VNetCopyDatagram(skb, buf, skl)) {
645
      if (VNetCopyDatagram(skb, buf, skl)) {
638
	 return -EFAULT;
646
	 return -EFAULT;
639
      }
647
      }
(-)vmnet-only.old/vnetInt.h (+10 lines)
Lines 22-27 Link Here
22
      skb_datarefp(clone) == skb_datarefp(skb) \
22
      skb_datarefp(clone) == skb_datarefp(skb) \
23
   )
23
   )
24
#endif
24
#endif
25
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
26
#define DEV_QUEUE_XMIT(skb, dev, pri)	(                 \
27
    (skb)->dev = (dev),                                   \
28
    (skb)->priority = (pri),                              \
29
    skb_reset_mac_header(skb),                            \
30
    skb_set_network_header(skb, sizeof (struct ethhdr)),  \
31
    dev_queue_xmit(skb)                                   \
32
  )
33
#else
25
#define DEV_QUEUE_XMIT(skb, dev, pri)	(                 \
34
#define DEV_QUEUE_XMIT(skb, dev, pri)	(                 \
26
    (skb)->dev = (dev),                                   \
35
    (skb)->dev = (dev),                                   \
27
    (skb)->priority = (pri),                              \
36
    (skb)->priority = (pri),                              \
Lines 29-34 Link Here
29
    (skb)->nh.raw = (skb)->data + sizeof (struct ethhdr), \
38
    (skb)->nh.raw = (skb)->data + sizeof (struct ethhdr), \
30
    dev_queue_xmit(skb)                                   \
39
    dev_queue_xmit(skb)                                   \
31
  )
40
  )
41
#endif
32
#ifdef KERNEL_2_3_15
42
#ifdef KERNEL_2_3_15
33
#  define dev_lock_list()		read_lock(&dev_base_lock)
43
#  define dev_lock_list()		read_lock(&dev_base_lock)
34
#  define dev_unlock_list()		read_unlock(&dev_base_lock)
44
#  define dev_unlock_list()		read_unlock(&dev_base_lock)

Return to bug 182595