mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
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 <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
d949d826c0
commit
eb3c0d83cc
2 changed files with 13 additions and 56 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue