All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] udp: avoid csum_partial() for validated skb
@ 2016-05-31 22:22 Eric Dumazet
  2016-06-02  0:41 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2016-05-31 22:22 UTC (permalink / raw)
  To: Sam Kumar, Willem de Bruijn, David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

In commit e6afc8ace6dd5 ("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: Eric Dumazet <edumazet@google.com>
---
 include/net/udp.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/net/udp.h b/include/net/udp.h
index ae07f375370da41271b839a272676ac970c3647e..8894d7144189935d4441fc2231edcb825dd7497e 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -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)
 {
-	if (skb->ip_summed == CHECKSUM_NONE)
-		skb->csum = csum_partial(udp_hdr(skb), sizeof(struct udphdr),
+	if (!skb->csum_valid && skb->ip_summed == CHECKSUM_NONE)
+		skb->csum = csum_partial(skb->data, sizeof(struct udphdr),
 					 skb->csum);
 	skb_pull_rcsum(skb, sizeof(struct udphdr));
 	UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] udp: avoid csum_partial() for validated skb
  2016-05-31 22:22 [PATCH net-next] udp: avoid csum_partial() for validated skb Eric Dumazet
@ 2016-06-02  0:41 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-06-02  0:41 UTC (permalink / raw)
  To: eric.dumazet; +Cc: samanthakumar, willemb, netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 31 May 2016 15:22:41 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> In commit e6afc8ace6dd5 ("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: Eric Dumazet <edumazet@google.com>

Applied, thanks Eric.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-02  0:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31 22:22 [PATCH net-next] udp: avoid csum_partial() for validated skb Eric Dumazet
2016-06-02  0:41 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.