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 |
|