diff options
author | Cong Wang <amwang@redhat.com> | 2013-08-31 01:44:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-31 22:30:01 -0400 |
commit | eb3c0d83cc78361a28e52e514a7095fdbf771e7e (patch) | |
tree | 78cdcc8781c3e040546e72c49f201ba2659353d0 /net/ipv4 | |
parent | d949d826c09fb65e230f55868ff70dc581ec06fa (diff) |
net: unify skb_udp_tunnel_segment() and skb_udp6_tunnel_segment()
As suggested by Pravin, we can unify the code in case of duplicated
code.
Cc: Pravin Shelar <pshelar@nicira.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/udp.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 0b24508bcdc4..74d2c95db57f 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -2337,7 +2337,7 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, | |||
2337 | uh->len = htons(skb->len - udp_offset); | 2337 | uh->len = htons(skb->len - udp_offset); |
2338 | 2338 | ||
2339 | /* csum segment if tunnel sets skb with csum. */ | 2339 | /* csum segment if tunnel sets skb with csum. */ |
2340 | if (unlikely(uh->check)) { | 2340 | if (protocol == htons(ETH_P_IP) && unlikely(uh->check)) { |
2341 | struct iphdr *iph = ip_hdr(skb); | 2341 | struct iphdr *iph = ip_hdr(skb); |
2342 | 2342 | ||
2343 | uh->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, | 2343 | uh->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, |
@@ -2348,7 +2348,18 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, | |||
2348 | if (uh->check == 0) | 2348 | if (uh->check == 0) |
2349 | uh->check = CSUM_MANGLED_0; | 2349 | uh->check = CSUM_MANGLED_0; |
2350 | 2350 | ||
2351 | } else if (protocol == htons(ETH_P_IPV6)) { | ||
2352 | struct ipv6hdr *ipv6h = ipv6_hdr(skb); | ||
2353 | u32 len = skb->len - udp_offset; | ||
2354 | |||
2355 | uh->check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr, | ||
2356 | len, IPPROTO_UDP, 0); | ||
2357 | uh->check = csum_fold(skb_checksum(skb, udp_offset, len, 0)); | ||
2358 | if (uh->check == 0) | ||
2359 | uh->check = CSUM_MANGLED_0; | ||
2360 | skb->ip_summed = CHECKSUM_NONE; | ||
2351 | } | 2361 | } |
2362 | |||
2352 | skb->protocol = protocol; | 2363 | skb->protocol = protocol; |
2353 | } while ((skb = skb->next)); | 2364 | } while ((skb = skb->next)); |
2354 | out: | 2365 | out: |