diff options
author | 2014-06-10 18:54:19 -0700 | |
---|---|---|
committer | 2014-06-11 15:46:13 -0700 | |
commit | 7e3cead5172927732f51fde77fef6f521e22f209 (patch) | |
tree | 7b7cad61aa68ba302c395b9a1ea3dafb69881d0d /net/core | |
parent | net: Preserve CHECKSUM_COMPLETE at validation (diff) | |
download | linux-7e3cead5172927732f51fde77fef6f521e22f209.tar.gz linux-7e3cead5172927732f51fde77fef6f521e22f209.tar.bz2 linux-7e3cead5172927732f51fde77fef6f521e22f209.zip |
net: Save software checksum complete
In skb_checksum complete, if we need to compute the checksum for the
packet (via skb_checksum) save the result as CHECKSUM_COMPLETE.
Subsequent checksum verification can use this.
Also, added csum_complete_sw flag to distinguish between software and
hardware generated checksum complete, we should always be able to trust
the software computation.
Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/datagram.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/net/core/datagram.c b/net/core/datagram.c index a16ed7bbe376..6b1c04ca1d50 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -739,11 +739,15 @@ __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len) __sum16 sum; sum = csum_fold(skb_checksum(skb, 0, len, skb->csum)); - if (likely(!sum)) { - if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) - netdev_rx_csum_fault(skb->dev); - skb->ip_summed = CHECKSUM_UNNECESSARY; - } + if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) && !sum && + !skb->csum_complete_sw) + netdev_rx_csum_fault(skb->dev); + + /* Save checksum complete for later use */ + skb->csum = sum; + skb->ip_summed = CHECKSUM_COMPLETE; + skb->csum_complete_sw = 1; + return sum; } EXPORT_SYMBOL(__skb_checksum_complete_head); |