Skip to content

Commit 35fc92a

Browse files
herbertxDavid S. Miller
authored andcommitted
[NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE
Right now Xen has a horrible hack that lets it forward packets with partial checksums. One of the reasons that CHECKSUM_PARTIAL and CHECKSUM_COMPLETE were added is so that we can get rid of this hack (where it creates two extra bits in the skbuff to essentially mirror ip_summed without being destroyed by the forwarding code). I had forgotten that I've already gone through all the deivce drivers last time around to make sure that they're looking at ip_summed == CHECKSUM_PARTIAL rather than ip_summed != 0 on transmit. In any case, I've now done that again so it should definitely be safe. Unfortunately nobody has yet added any code to update CHECKSUM_COMPLETE values on forward so we I'm setting that to CHECKSUM_NONE. This should be safe to remove for bridging but I'd like to check that code path first. So here is the patch that lets us get rid of the hack by preserving ip_summed (mostly) on forwarded packets. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2d771cd commit 35fc92a

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎include/linux/skbuff.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,5 +1654,12 @@ static inline int skb_is_gso(const struct sk_buff *skb)
16541654
return skb_shinfo(skb)->gso_size;
16551655
}
16561656

1657+
static inline void skb_forward_csum(struct sk_buff *skb)
1658+
{
1659+
/* Unfortunately we don't support this one. Any brave souls? */
1660+
if (skb->ip_summed == CHECKSUM_COMPLETE)
1661+
skb->ip_summed = CHECKSUM_NONE;
1662+
}
1663+
16571664
#endif /* __KERNEL__ */
16581665
#endif /* _LINUX_SKBUFF_H */

‎net/bridge/br_forward.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
7171

7272
indev = skb->dev;
7373
skb->dev = to->dev;
74-
skb->ip_summed = CHECKSUM_NONE;
74+
skb_forward_csum(skb);
7575

7676
NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
7777
br_forward_finish);

‎net/ipv4/ip_forward.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int ip_forward(struct sk_buff *skb)
6767
if (skb->pkt_type != PACKET_HOST)
6868
goto drop;
6969

70-
skb->ip_summed = CHECKSUM_NONE;
70+
skb_forward_csum(skb);
7171

7272
/*
7373
* According to the RFC, we must first decrease the TTL field. If

‎net/ipv6/ip6_output.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int ip6_forward(struct sk_buff *skb)
378378
goto drop;
379379
}
380380

381-
skb->ip_summed = CHECKSUM_NONE;
381+
skb_forward_csum(skb);
382382

383383
/*
384384
* We DO NOT make any processing on

0 commit comments

Comments
 (0)