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>
This commit is contained in:

committed by
David S. Miller

parent
d949d826c0
commit
eb3c0d83cc
@@ -2337,7 +2337,7 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
|
||||
uh->len = htons(skb->len - udp_offset);
|
||||
|
||||
/* csum segment if tunnel sets skb with csum. */
|
||||
if (unlikely(uh->check)) {
|
||||
if (protocol == htons(ETH_P_IP) && unlikely(uh->check)) {
|
||||
struct iphdr *iph = ip_hdr(skb);
|
||||
|
||||
uh->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
|
||||
@@ -2348,7 +2348,18 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
|
||||
if (uh->check == 0)
|
||||
uh->check = CSUM_MANGLED_0;
|
||||
|
||||
} else if (protocol == htons(ETH_P_IPV6)) {
|
||||
struct ipv6hdr *ipv6h = ipv6_hdr(skb);
|
||||
u32 len = skb->len - udp_offset;
|
||||
|
||||
uh->check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr,
|
||||
len, IPPROTO_UDP, 0);
|
||||
uh->check = csum_fold(skb_checksum(skb, udp_offset, len, 0));
|
||||
if (uh->check == 0)
|
||||
uh->check = CSUM_MANGLED_0;
|
||||
skb->ip_summed = CHECKSUM_NONE;
|
||||
}
|
||||
|
||||
skb->protocol = protocol;
|
||||
} while ((skb = skb->next));
|
||||
out:
|
||||
|
Reference in New Issue
Block a user