netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: reset gso header when the copied skb is linearized
@ 2010-10-25 22:23 Flavio Leitner
  2010-10-26 18:31 ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Flavio Leitner @ 2010-10-25 22:23 UTC (permalink / raw)
  To: netdev; +Cc: Flavio Leitner

The gso header is incorrect when the copied skb is
linearized. This patch creates another helper function
to copy the gso header when it is appropriated

Signed-off-by: Flavio Leitner <fleitner@redhat.com>
---
 net/core/skbuff.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 104f844..54a2d3a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -649,6 +649,12 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 	if (skb_mac_header_was_set(new))
 		new->mac_header	      += offset;
 #endif
+}
+
+static void copy_skb_header_gso(struct sk_buff *new, const struct sk_buff *old)
+{
+	copy_skb_header(new, old);
+
 	skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size;
 	skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs;
 	skb_shinfo(new)->gso_type = skb_shinfo(old)->gso_type;
@@ -740,7 +746,7 @@ struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask)
 		skb_clone_fraglist(n);
 	}
 
-	copy_skb_header(n, skb);
+	copy_skb_header_gso(n, skb);
 out:
 	return n;
 }
-- 
1.7.3.1


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

* Re: [PATCH] net: reset gso header when the copied skb is linearized
  2010-10-25 22:23 [PATCH] net: reset gso header when the copied skb is linearized Flavio Leitner
@ 2010-10-26 18:31 ` David Miller
  2010-10-26 19:25   ` Flavio Leitner
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2010-10-26 18:31 UTC (permalink / raw)
  To: fleitner; +Cc: netdev, herbert

From: Flavio Leitner <fleitner@redhat.com>
Date: Mon, 25 Oct 2010 20:23:18 -0200

> The gso header is incorrect when the copied skb is
> linearized. This patch creates another helper function
> to copy the gso header when it is appropriated
> 
> Signed-off-by: Flavio Leitner <fleitner@redhat.com>

I don't understand why the GSO information should be
omitted just because we are creating a linearlized
version of the SKB?

The packet still could have a larger than MSS size,
and thus be composed of multiple actual segments for
the network.

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

* Re: [PATCH] net: reset gso header when the copied skb is linearized
  2010-10-26 18:31 ` David Miller
@ 2010-10-26 19:25   ` Flavio Leitner
  2010-10-26 19:28     ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Flavio Leitner @ 2010-10-26 19:25 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, herbert

On Tue, Oct 26, 2010 at 11:31:57AM -0700, David Miller wrote:
> From: Flavio Leitner <fleitner@redhat.com>
> Date: Mon, 25 Oct 2010 20:23:18 -0200
> 
> > The gso header is incorrect when the copied skb is
> > linearized. This patch creates another helper function
> > to copy the gso header when it is appropriated
> > 
> > Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> 
> I don't understand why the GSO information should be
> omitted just because we are creating a linearlized
> version of the SKB?

If I understand that correctly, the gso_segs is the number
of GSO segments which are divided in non-linear way. When the
copy is made using that function, the skb turns into a big
one segment inlined. So, the idea of segments is lost and
I'm not seeing how it is going to be divided again. 
Later the NIC drives does, for example:

drivers/net/e1000/e1000_main.c
...
                if (cleaned) {
                        struct sk_buff *skb = buffer_info->skb;
                        unsigned int segs, bytecount;
                        segs = skb_shinfo(skb)->gso_segs ?: 1;
                        /* multiply data chunks by size of * headers */
                        bytecount = ((segs - 1) * skb_headlen(skb)) +
                                    skb->len;
                        total_tx_packets += segs;
                        total_tx_bytes += bytecount;
                }
...

The bytecount there will be wrong because it will multiply 
the old gso_segs X skb_headlen(skb) which will be the entire
skb as the payload is inlined.

I see that there are some places checking for skb_is_gso()
before do something or calculating using that math above.

> The packet still could have a larger than MSS size,
> and thus be composed of multiple actual segments for
> the network.

hopefully I answered this too in my previous comment

thanks,
-- 
Flavio

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

* Re: [PATCH] net: reset gso header when the copied skb is linearized
  2010-10-26 19:25   ` Flavio Leitner
@ 2010-10-26 19:28     ` David Miller
  2010-10-26 19:38       ` Herbert Xu
  2010-11-04 20:35       ` Flavio Leitner
  0 siblings, 2 replies; 6+ messages in thread
From: David Miller @ 2010-10-26 19:28 UTC (permalink / raw)
  To: fleitner; +Cc: netdev, herbert

From: Flavio Leitner <fleitner@redhat.com>
Date: Tue, 26 Oct 2010 17:25:11 -0200

> If I understand that correctly, the gso_segs is the number
> of GSO segments which are divided in non-linear way. When the
> copy is made using that function, the skb turns into a big
> one segment inlined. So, the idea of segments is lost and
> I'm not seeing how it is going to be divided again. 
> Later the NIC drives does, for example:

GSO has nothing to do with linearity, although it just so happens
to be that GSO packets tend to be non-linear due to the way
TCP builds such frames.

The GSO segment count is the number of MSS sized frames are
contained inside of a larger than MSS sized SKB.

That is it.  So the definition and meaning is independent of
linearity.

Thus, if we linearize a larger than MSS sized frame, it should still
have the same GSO attributes.

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

* Re: [PATCH] net: reset gso header when the copied skb is linearized
  2010-10-26 19:28     ` David Miller
@ 2010-10-26 19:38       ` Herbert Xu
  2010-11-04 20:35       ` Flavio Leitner
  1 sibling, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2010-10-26 19:38 UTC (permalink / raw)
  To: David Miller; +Cc: fleitner, netdev

On Tue, Oct 26, 2010 at 12:28:01PM -0700, David Miller wrote:
>
> Thus, if we linearize a larger than MSS sized frame, it should still
> have the same GSO attributes.

I agree with you on all counts :)
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] net: reset gso header when the copied skb is linearized
  2010-10-26 19:28     ` David Miller
  2010-10-26 19:38       ` Herbert Xu
@ 2010-11-04 20:35       ` Flavio Leitner
  1 sibling, 0 replies; 6+ messages in thread
From: Flavio Leitner @ 2010-11-04 20:35 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, herbert

On Tue, Oct 26, 2010 at 12:28:01PM -0700, David Miller wrote:
> From: Flavio Leitner <fleitner@redhat.com>
> Date: Tue, 26 Oct 2010 17:25:11 -0200
> 
> > If I understand that correctly, the gso_segs is the number
> > of GSO segments which are divided in non-linear way. When the
> > copy is made using that function, the skb turns into a big
> > one segment inlined. So, the idea of segments is lost and
> > I'm not seeing how it is going to be divided again. 
> > Later the NIC drives does, for example:
> 
> GSO has nothing to do with linearity, although it just so happens
> to be that GSO packets tend to be non-linear due to the way
> TCP builds such frames.
> 
> The GSO segment count is the number of MSS sized frames are
> contained inside of a larger than MSS sized SKB.
> 
> That is it.  So the definition and meaning is independent of
> linearity.
> 
> Thus, if we linearize a larger than MSS sized frame, it should still
> have the same GSO attributes.

It makes sense, thanks for the explanation.
Please ignore the proposed patch.

thanks again,
-- 
Flavio

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

end of thread, other threads:[~2010-11-04 20:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-25 22:23 [PATCH] net: reset gso header when the copied skb is linearized Flavio Leitner
2010-10-26 18:31 ` David Miller
2010-10-26 19:25   ` Flavio Leitner
2010-10-26 19:28     ` David Miller
2010-10-26 19:38       ` Herbert Xu
2010-11-04 20:35       ` Flavio Leitner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).