All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] gro: should aggregate frames without DF
@ 2013-05-31 17:02 Eric Dumazet
  2013-05-31 18:14 ` Jerry Chu
  2013-05-31 20:09 ` Ben Hutchings
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Dumazet @ 2013-05-31 17:02 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Jerry Chu, Herbert Xu

From: Eric Dumazet <edumazet@google.com>

GRO on IPv4 doesn't aggregate frames if they don't have DF bit set.

Some servers use IP_MTU_DISCOVER/IP_PMTUDISC_PROBE, so linux receivers
are unable to aggregate this kind of traffic.

The right thing to do is to allow aggregation as long as the DF bit has
same value on all segments.

bnx2x LRO does this correctly.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jerry Chu <hkchu@google.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
---
 net/ipv4/af_inet.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index b05ae96..328cc62 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1384,9 +1384,9 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
 	if (unlikely(ip_fast_csum((u8 *)iph, 5)))
 		goto out_unlock;
 
-	id = ntohl(*(__be32 *)&iph->id);
-	flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id ^ IP_DF));
-	id >>= 16;
+	flush = ntohs(iph->tot_len) ^ skb_gro_len(skb);
+
+	id = ntohs(iph->id);
 
 	for (p = *head; p; p = p->next) {
 		struct iphdr *iph2;
@@ -1407,6 +1407,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
 		NAPI_GRO_CB(p)->flush |=
 			(iph->ttl ^ iph2->ttl) |
 			(iph->tos ^ iph2->tos) |
+			((iph->frag_off ^ iph2->frag_off) & htons(IP_DF)) |
 			((u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) ^ id);
 
 		NAPI_GRO_CB(p)->flush |= flush;

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

* Re: [PATCH net-next] gro: should aggregate frames without DF
  2013-05-31 17:02 [PATCH net-next] gro: should aggregate frames without DF Eric Dumazet
@ 2013-05-31 18:14 ` Jerry Chu
  2013-05-31 20:09 ` Ben Hutchings
  1 sibling, 0 replies; 7+ messages in thread
From: Jerry Chu @ 2013-05-31 18:14 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Herbert Xu

On Fri, May 31, 2013 at 10:02 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> GRO on IPv4 doesn't aggregate frames if they don't have DF bit set.
>
> Some servers use IP_MTU_DISCOVER/IP_PMTUDISC_PROBE, so linux receivers
> are unable to aggregate this kind of traffic.
>
> The right thing to do is to allow aggregation as long as the DF bit has
> same value on all segments.
>
> bnx2x LRO does this correctly.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Jerry Chu <hkchu@google.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> ---
>  net/ipv4/af_inet.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index b05ae96..328cc62 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -1384,9 +1384,9 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
>         if (unlikely(ip_fast_csum((u8 *)iph, 5)))
>                 goto out_unlock;
>
> -       id = ntohl(*(__be32 *)&iph->id);
> -       flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id ^ IP_DF));
> -       id >>= 16;
> +       flush = ntohs(iph->tot_len) ^ skb_gro_len(skb);
> +
> +       id = ntohs(iph->id);
>
>         for (p = *head; p; p = p->next) {
>                 struct iphdr *iph2;
> @@ -1407,6 +1407,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
>                 NAPI_GRO_CB(p)->flush |=
>                         (iph->ttl ^ iph2->ttl) |
>                         (iph->tos ^ iph2->tos) |
> +                       ((iph->frag_off ^ iph2->frag_off) & htons(IP_DF)) |
>                         ((u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) ^ id);
>
>                 NAPI_GRO_CB(p)->flush |= flush;
>
>

Acked-by: Jerry Chu <hkchu@google.com>

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

* Re: [PATCH net-next] gro: should aggregate frames without DF
  2013-05-31 17:02 [PATCH net-next] gro: should aggregate frames without DF Eric Dumazet
  2013-05-31 18:14 ` Jerry Chu
@ 2013-05-31 20:09 ` Ben Hutchings
  2013-05-31 21:12   ` Eric Dumazet
  2013-05-31 21:18   ` [PATCH v2 " Eric Dumazet
  1 sibling, 2 replies; 7+ messages in thread
From: Ben Hutchings @ 2013-05-31 20:09 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Jerry Chu, Herbert Xu

On Fri, 2013-05-31 at 10:02 -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> GRO on IPv4 doesn't aggregate frames if they don't have DF bit set.
> 
> Some servers use IP_MTU_DISCOVER/IP_PMTUDISC_PROBE, so linux receivers
> are unable to aggregate this kind of traffic.
> 
> The right thing to do is to allow aggregation as long as the DF bit has
> same value on all segments.
> 
> bnx2x LRO does this correctly.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Jerry Chu <hkchu@google.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> ---
>  net/ipv4/af_inet.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index b05ae96..328cc62 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -1384,9 +1384,9 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
>  	if (unlikely(ip_fast_csum((u8 *)iph, 5)))
>  		goto out_unlock;
>  
> -	id = ntohl(*(__be32 *)&iph->id);
> -	flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id ^ IP_DF));
> -	id >>= 16;
> +	flush = ntohs(iph->tot_len) ^ skb_gro_len(skb);
> +
> +	id = ntohs(iph->id);
>  
>  	for (p = *head; p; p = p->next) {
>  		struct iphdr *iph2;
> @@ -1407,6 +1407,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
>  		NAPI_GRO_CB(p)->flush |=
>  			(iph->ttl ^ iph2->ttl) |
>  			(iph->tos ^ iph2->tos) |
> +			((iph->frag_off ^ iph2->frag_off) & htons(IP_DF)) |

But this results in ignoring the actual offset bits of frag_off!
We should allow merging only if all packets have frag_off == IP_DF or
all have frag_off == 0.  The first assignment of flush therefore still
needs to check the combined id/frag_off word, but using (id & ~IP_DF)
instead of (id ^ IP_DF).

Ben.

>  			((u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) ^ id);
>  
>  		NAPI_GRO_CB(p)->flush |= flush;

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

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

* Re: [PATCH net-next] gro: should aggregate frames without DF
  2013-05-31 20:09 ` Ben Hutchings
@ 2013-05-31 21:12   ` Eric Dumazet
  2013-05-31 21:18   ` [PATCH v2 " Eric Dumazet
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2013-05-31 21:12 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: David Miller, netdev, Jerry Chu, Herbert Xu

On Fri, 2013-05-31 at 21:09 +0100, Ben Hutchings wrote:

> But this results in ignoring the actual offset bits of frag_off!
> We should allow merging only if all packets have frag_off == IP_DF or
> all have frag_off == 0.  The first assignment of flush therefore still
> needs to check the combined id/frag_off word, but using (id & ~IP_DF)
> instead of (id ^ IP_DF).

You're right, I guess I wanted too much getting rid of black magic in
this code ;)

I'll send a v2

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

* [PATCH v2 net-next] gro: should aggregate frames without DF
  2013-05-31 20:09 ` Ben Hutchings
  2013-05-31 21:12   ` Eric Dumazet
@ 2013-05-31 21:18   ` Eric Dumazet
  2013-05-31 21:27     ` Ben Hutchings
  2013-06-01  0:15     ` David Miller
  1 sibling, 2 replies; 7+ messages in thread
From: Eric Dumazet @ 2013-05-31 21:18 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: David Miller, netdev, Jerry Chu, Herbert Xu

From: Eric Dumazet <edumazet@google.com>

GRO on IPv4 doesn't aggregate frames if they don't have DF bit set.

Some servers use IP_MTU_DISCOVER/IP_PMTUDISC_PROBE, so linux receivers
are unable to aggregate this kind of traffic.

The right thing to do is to allow aggregation as long as the DF bit has
same value on all segments.

bnx2x LRO does this correctly.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jerry Chu <hkchu@google.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
v2 : fix from Ben Hutchings (Thanks !)

 net/ipv4/af_inet.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index b05ae96..9c090c7 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1385,7 +1385,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
 		goto out_unlock;
 
 	id = ntohl(*(__be32 *)&iph->id);
-	flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id ^ IP_DF));
+	flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id & ~IP_DF));
 	id >>= 16;
 
 	for (p = *head; p; p = p->next) {
@@ -1407,6 +1407,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
 		NAPI_GRO_CB(p)->flush |=
 			(iph->ttl ^ iph2->ttl) |
 			(iph->tos ^ iph2->tos) |
+			((iph->frag_off ^ iph2->frag_off) & htons(IP_DF)) |
 			((u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) ^ id);
 
 		NAPI_GRO_CB(p)->flush |= flush;

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

* Re: [PATCH v2 net-next] gro: should aggregate frames without DF
  2013-05-31 21:18   ` [PATCH v2 " Eric Dumazet
@ 2013-05-31 21:27     ` Ben Hutchings
  2013-06-01  0:15     ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: Ben Hutchings @ 2013-05-31 21:27 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Jerry Chu, Herbert Xu

On Fri, 2013-05-31 at 14:18 -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> GRO on IPv4 doesn't aggregate frames if they don't have DF bit set.
> 
> Some servers use IP_MTU_DISCOVER/IP_PMTUDISC_PROBE, so linux receivers
> are unable to aggregate this kind of traffic.
> 
> The right thing to do is to allow aggregation as long as the DF bit has
> same value on all segments.
> 
> bnx2x LRO does this correctly.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Jerry Chu <hkchu@google.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: Ben Hutchings <bhutchings@solarflare.com>
> ---
> v2 : fix from Ben Hutchings (Thanks !)

Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>

>  net/ipv4/af_inet.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index b05ae96..9c090c7 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -1385,7 +1385,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
>  		goto out_unlock;
>  
>  	id = ntohl(*(__be32 *)&iph->id);
> -	flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id ^ IP_DF));
> +	flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id & ~IP_DF));
>  	id >>= 16;
>  
>  	for (p = *head; p; p = p->next) {
> @@ -1407,6 +1407,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
>  		NAPI_GRO_CB(p)->flush |=
>  			(iph->ttl ^ iph2->ttl) |
>  			(iph->tos ^ iph2->tos) |
> +			((iph->frag_off ^ iph2->frag_off) & htons(IP_DF)) |
>  			((u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) ^ id);
>  
>  		NAPI_GRO_CB(p)->flush |= flush;
> 
> 

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

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

* Re: [PATCH v2 net-next] gro: should aggregate frames without DF
  2013-05-31 21:18   ` [PATCH v2 " Eric Dumazet
  2013-05-31 21:27     ` Ben Hutchings
@ 2013-06-01  0:15     ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2013-06-01  0:15 UTC (permalink / raw)
  To: eric.dumazet; +Cc: bhutchings, netdev, hkchu, herbert

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 31 May 2013 14:18:10 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> GRO on IPv4 doesn't aggregate frames if they don't have DF bit set.
> 
> Some servers use IP_MTU_DISCOVER/IP_PMTUDISC_PROBE, so linux receivers
> are unable to aggregate this kind of traffic.
> 
> The right thing to do is to allow aggregation as long as the DF bit has
> same value on all segments.
> 
> bnx2x LRO does this correctly.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied, thanks.

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

end of thread, other threads:[~2013-06-01  0:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-31 17:02 [PATCH net-next] gro: should aggregate frames without DF Eric Dumazet
2013-05-31 18:14 ` Jerry Chu
2013-05-31 20:09 ` Ben Hutchings
2013-05-31 21:12   ` Eric Dumazet
2013-05-31 21:18   ` [PATCH v2 " Eric Dumazet
2013-05-31 21:27     ` Ben Hutchings
2013-06-01  0:15     ` 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.