Skip to contentSkip to conversation

net: reset gso header when the copied skb is linearized

PATCH In review Flavio Leitner 3 participants 6 messages Oct 25, 2010 – Nov 4, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: reset gso header when the copied skb is linearized

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

---
 net/core/skbuff.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
net/core/skbuff.c +7 -1
index 104f844..54a2d3a 100644
@@ -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;
 }
Signature · 1 line
1.7.3.1
maintainer
#1 lore raw

From: Flavio Leitner <[email protected]>
Date: Mon, 25 Oct 2010 20:23:18 -0200

Quoted 5 lines

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

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.

#2 lore raw
Quoted 7 lines · David Miller

From: Flavio Leitner <[email protected]>
Date: Mon, 25 Oct 2010 20:23:18 -0200

Quoted 4 lines

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

Quoted 5 lines
Quoted 1 line

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.

Quoted 3 lines

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,

Signature · 1 line
Flavio
maintainer
#3 lore raw

From: Flavio Leitner <[email protected]>
Date: Tue, 26 Oct 2010 17:25:11 -0200

Quoted 6 lines

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.

#4 lore raw
Quoted 3 lines · David Miller

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 :)

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#5 lore raw
In reply to David Miller
Quoted 14 lines · David Miller

From: Flavio Leitner <[email protected]>
Date: Tue, 26 Oct 2010 17:25:11 -0200

Quoted 6 lines

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.

Quoted 8 lines

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,

Signature · 1 line
Flavio