aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/skbuff.c
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2013-05-19 11:46:49 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-22 18:06:13 -0400
commit1cdbcb7957cf9e5f841dbcde9b38fd18a804208b (patch)
tree915c68bc9c74b85ef0450c611b3fb6fa66036084 /net/core/skbuff.c
parent6b7df111ece130fa979a0c4f58e53674c1e47d3e (diff)
net: Loosen constraints for recalculating checksum in skb_segment()
This is a generic solution to resolve a specific problem that I have observed. If the encapsulation of an skb changes then ability to offload checksums may also change. In particular it may be necessary to perform checksumming in software. An example of such a case is where a non-GRE packet is received but is to be encapsulated and transmitted as GRE. Another example relates to my proposed support for for packets that are non-MPLS when received but MPLS when transmitted. The cost of this change is that the value of the csum variable may be checked when it previously was not. In the case where the csum variable is true this is pure overhead. In the case where the csum variable is false it leads to software checksumming, which I believe also leads to correct checksums in transmitted packets for the cases described above. Further analysis: This patch relies on the return value of can_checksum_protocol() being correct and in turn the return value of skb_network_protocol(), used to provide the protocol parameter of can_checksum_protocol(), being correct. It also relies on the features passed to skb_segment() and in turn to can_checksum_protocol() being correct. I believe that this problem has not been observed for VLANs because it appears that almost all drivers, the exception being xgbe, set vlan_features such that that the checksum offload support for VLAN packets is greater than or equal to that of non-VLAN packets. I wonder if the code in xgbe may be an oversight and the hardware does support checksumming of VLAN packets. If so it may be worth updating the vlan_features of the driver as this patch will force such checksums to be performed in software rather than hardware. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r--net/core/skbuff.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index af9185d0be6a..d6298914f4e7 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2853,7 +2853,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features)
2853 doffset + tnl_hlen); 2853 doffset + tnl_hlen);
2854 2854
2855 if (fskb != skb_shinfo(skb)->frag_list) 2855 if (fskb != skb_shinfo(skb)->frag_list)
2856 continue; 2856 goto perform_csum_check;
2857 2857
2858 if (!sg) { 2858 if (!sg) {
2859 nskb->ip_summed = CHECKSUM_NONE; 2859 nskb->ip_summed = CHECKSUM_NONE;
@@ -2917,6 +2917,7 @@ skip_fraglist:
2917 nskb->len += nskb->data_len; 2917 nskb->len += nskb->data_len;
2918 nskb->truesize += nskb->data_len; 2918 nskb->truesize += nskb->data_len;
2919 2919
2920perform_csum_check:
2920 if (!csum) { 2921 if (!csum) {
2921 nskb->csum = skb_checksum(nskb, doffset, 2922 nskb->csum = skb_checksum(nskb, doffset,
2922 nskb->len - doffset, 0); 2923 nskb->len - doffset, 0);