Commit 595d0b29 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

udp: avoid csum_partial() for validated skb

In commit e6afc8ac ("udp: remove headers from UDP packets before
queueing"), udp_csum_pull_header() helper was added but missed fact
that CHECKSUM_UNNECESSARY packets were now converted to CHECKSUM_NONE
and skb->csum_valid was set to 1 for them.

Since csum_partial() is quite expensive, even for 8-byte area, it is
worth adding a test.

We also can use skb->data instead of udp_hdr() as we are pulling
UDP headers, as it is sightly faster.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 524c6f69
...@@ -160,8 +160,8 @@ void udp_set_csum(bool nocheck, struct sk_buff *skb, ...@@ -160,8 +160,8 @@ void udp_set_csum(bool nocheck, struct sk_buff *skb,
static inline void udp_csum_pull_header(struct sk_buff *skb) static inline void udp_csum_pull_header(struct sk_buff *skb)
{ {
if (skb->ip_summed == CHECKSUM_NONE) if (!skb->csum_valid && skb->ip_summed == CHECKSUM_NONE)
skb->csum = csum_partial(udp_hdr(skb), sizeof(struct udphdr), skb->csum = csum_partial(skb->data, sizeof(struct udphdr),
skb->csum); skb->csum);
skb_pull_rcsum(skb, sizeof(struct udphdr)); skb_pull_rcsum(skb, sizeof(struct udphdr));
UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr); UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment