Patchwork [RFC,2/3] Prepare to allow for hardware checksum of ICMPv6

login
register
mail settings
Submitter David Woodhouse
Date Jan. 14, 2013, 12:12 p.m.
Message ID <1358165551.27054.64.camel@shinybook.infradead.org>
Download mbox | patch
Permalink /patch/211779/
State RFC
Delegated to: David Miller
Headers show

Comments

David Woodhouse - Jan. 14, 2013, 12:12 p.m.
If netif_skb_features() has to filter out non-TCP and non-UDP frames
anyway for devices with limited checksum support, there's no reason we
shouldn't generate them in our *own* stack. This allows ICMPv6 to do
so...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Patch

diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index b4a9fd5..e474df9 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -235,12 +235,19 @@  static int icmpv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6, struc
 	icmp6h->icmp6_cksum = 0;
 
 	if (skb_queue_len(&sk->sk_write_queue) == 1) {
-		skb->csum = csum_partial(icmp6h,
-					sizeof(struct icmp6hdr), skb->csum);
-		icmp6h->icmp6_cksum = csum_ipv6_magic(&fl6->saddr,
-						      &fl6->daddr,
-						      len, fl6->flowi6_proto,
-						      skb->csum);
+		if (skb->ip_summed == CHECKSUM_PARTIAL) {
+			skb->csum_start = skb_transport_header(skb) - skb->head;
+			skb->csum_offset = offsetof(struct icmp6hdr, icmp6_cksum);
+			icmp6h->icmp6_cksum = ~csum_ipv6_magic(&fl6->saddr, &fl6->daddr,
+							       len, fl6->flowi6_proto, 0);
+		} else {
+			skb->csum = csum_partial(icmp6h,
+						 sizeof(struct icmp6hdr), skb->csum);
+			icmp6h->icmp6_cksum = csum_ipv6_magic(&fl6->saddr,
+							      &fl6->daddr,
+							      len, fl6->flowi6_proto,
+							      skb->csum);
+		}
 	} else {
 		__wsum tmp_csum = 0;