提交 d75f1306 编写于 作者: E Edward Cree 提交者: David S. Miller

net: udp: always set up for CHECKSUM_PARTIAL offload

If the dst device doesn't support it, it'll get fixed up later anyway
 by validate_xmit_skb().  Also, this allows us to take advantage of LCO
 to avoid summing the payload multiple times.
Signed-off-by: NEdward Cree <ecree@solarflare.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 179bc67f
...@@ -857,23 +857,11 @@ void udp_set_csum(bool nocheck, struct sk_buff *skb, ...@@ -857,23 +857,11 @@ void udp_set_csum(bool nocheck, struct sk_buff *skb,
uh->check = udp_v4_check(len, saddr, daddr, lco_csum(skb)); uh->check = udp_v4_check(len, saddr, daddr, lco_csum(skb));
if (uh->check == 0) if (uh->check == 0)
uh->check = CSUM_MANGLED_0; uh->check = CSUM_MANGLED_0;
} else if (skb_dst(skb) && skb_dst(skb)->dev && } else {
(skb_dst(skb)->dev->features &
(NETIF_F_IP_CSUM | NETIF_F_HW_CSUM))) {
skb->ip_summed = CHECKSUM_PARTIAL; skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum_start = skb_transport_header(skb) - skb->head; skb->csum_start = skb_transport_header(skb) - skb->head;
skb->csum_offset = offsetof(struct udphdr, check); skb->csum_offset = offsetof(struct udphdr, check);
uh->check = ~udp_v4_check(len, saddr, daddr, 0); uh->check = ~udp_v4_check(len, saddr, daddr, 0);
} else {
__wsum csum;
uh->check = 0;
csum = skb_checksum(skb, 0, len, 0);
uh->check = udp_v4_check(len, saddr, daddr, csum);
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;
skb->ip_summed = CHECKSUM_UNNECESSARY;
} }
} }
EXPORT_SYMBOL(udp_set_csum); EXPORT_SYMBOL(udp_set_csum);
......
...@@ -103,22 +103,11 @@ void udp6_set_csum(bool nocheck, struct sk_buff *skb, ...@@ -103,22 +103,11 @@ void udp6_set_csum(bool nocheck, struct sk_buff *skb,
uh->check = udp_v6_check(len, saddr, daddr, lco_csum(skb)); uh->check = udp_v6_check(len, saddr, daddr, lco_csum(skb));
if (uh->check == 0) if (uh->check == 0)
uh->check = CSUM_MANGLED_0; uh->check = CSUM_MANGLED_0;
} else if (skb_dst(skb) && skb_dst(skb)->dev && } else {
(skb_dst(skb)->dev->features & NETIF_F_IPV6_CSUM)) {
skb->ip_summed = CHECKSUM_PARTIAL; skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum_start = skb_transport_header(skb) - skb->head; skb->csum_start = skb_transport_header(skb) - skb->head;
skb->csum_offset = offsetof(struct udphdr, check); skb->csum_offset = offsetof(struct udphdr, check);
uh->check = ~udp_v6_check(len, saddr, daddr, 0); uh->check = ~udp_v6_check(len, saddr, daddr, 0);
} else {
__wsum csum;
uh->check = 0;
csum = skb_checksum(skb, 0, len, 0);
uh->check = udp_v6_check(len, saddr, daddr, csum);
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;
skb->ip_summed = CHECKSUM_UNNECESSARY;
} }
} }
EXPORT_SYMBOL(udp6_set_csum); EXPORT_SYMBOL(udp6_set_csum);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册