aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/udp_offload.c
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2014-09-20 17:52:29 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-26 00:22:46 -0400
commitf71470b37e79d6eb151debd47364d920b7babd30 (patch)
treecef41e3672ce144ddb9d251afc93190dcc3931c8 /net/ipv6/udp_offload.c
parentd020f8f73318589bf41f864b7f89f95669350873 (diff)
udp: move logic out of udp[46]_ufo_send_check
In udp[46]_ufo_send_check the UDP checksum initialized to the pseudo header checksum. We can move this logic into udp[46]_ufo_fragment. After this change udp[64]_ufo_send_check is a no-op. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/udp_offload.c')
-rw-r--r--net/ipv6/udp_offload.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index de85f809bf29..e4af6437ea3b 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -19,23 +19,6 @@
19 19
20static int udp6_ufo_send_check(struct sk_buff *skb) 20static int udp6_ufo_send_check(struct sk_buff *skb)
21{ 21{
22 const struct ipv6hdr *ipv6h;
23 struct udphdr *uh;
24
25 if (!pskb_may_pull(skb, sizeof(*uh)))
26 return -EINVAL;
27
28 if (likely(!skb->encapsulation)) {
29 ipv6h = ipv6_hdr(skb);
30 uh = udp_hdr(skb);
31
32 uh->check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr, skb->len,
33 IPPROTO_UDP, 0);
34 skb->csum_start = skb_transport_header(skb) - skb->head;
35 skb->csum_offset = offsetof(struct udphdr, check);
36 skb->ip_summed = CHECKSUM_PARTIAL;
37 }
38
39 return 0; 22 return 0;
40} 23}
41 24
@@ -49,7 +32,6 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
49 u8 *packet_start, *prevhdr; 32 u8 *packet_start, *prevhdr;
50 u8 nexthdr; 33 u8 nexthdr;
51 u8 frag_hdr_sz = sizeof(struct frag_hdr); 34 u8 frag_hdr_sz = sizeof(struct frag_hdr);
52 int offset;
53 __wsum csum; 35 __wsum csum;
54 int tnl_hlen; 36 int tnl_hlen;
55 37
@@ -83,13 +65,27 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
83 (SKB_GSO_UDP_TUNNEL|SKB_GSO_UDP_TUNNEL_CSUM)) 65 (SKB_GSO_UDP_TUNNEL|SKB_GSO_UDP_TUNNEL_CSUM))
84 segs = skb_udp_tunnel_segment(skb, features); 66 segs = skb_udp_tunnel_segment(skb, features);
85 else { 67 else {
68 const struct ipv6hdr *ipv6h;
69 struct udphdr *uh;
70
71 if (!pskb_may_pull(skb, sizeof(struct udphdr)))
72 goto out;
73
86 /* Do software UFO. Complete and fill in the UDP checksum as HW cannot 74 /* Do software UFO. Complete and fill in the UDP checksum as HW cannot
87 * do checksum of UDP packets sent as multiple IP fragments. 75 * do checksum of UDP packets sent as multiple IP fragments.
88 */ 76 */
89 offset = skb_checksum_start_offset(skb); 77
90 csum = skb_checksum(skb, offset, skb->len - offset, 0); 78 uh = udp_hdr(skb);
91 offset += skb->csum_offset; 79 ipv6h = ipv6_hdr(skb);
92 *(__sum16 *)(skb->data + offset) = csum_fold(csum); 80
81 uh->check = 0;
82 csum = skb_checksum(skb, 0, skb->len, 0);
83 uh->check = udp_v6_check(skb->len, &ipv6h->saddr,
84 &ipv6h->daddr, csum);
85
86 if (uh->check == 0)
87 uh->check = CSUM_MANGLED_0;
88
93 skb->ip_summed = CHECKSUM_NONE; 89 skb->ip_summed = CHECKSUM_NONE;
94 90
95 /* Check if there is enough headroom to insert fragment header. */ 91 /* Check if there is enough headroom to insert fragment header. */