[PATCH] net: Set trailer iff skb1 is the last one

Subsystems: networking [general], the rest

DORMANTno replies

2 messages, 2 authors, 2020-08-27 · open the first message on its own page

[PATCH] net: Set trailer iff skb1 is the last one

From: Miaohe Lin <linmiaohe@huawei.com>
Date: 2020-08-27 15:22:25

Set trailer iff skb1 is the skbuff where the tailbits space begins.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 net/core/skbuff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 0b24aed04060..18ed56316e56 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4488,8 +4488,9 @@ int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)
 			skb1 = skb2;
 		}
 		elt++;
-		*trailer = skb1;
 		skb_p = &skb1->next;
+		if (!*skb_p)
+			*trailer = skb1;
 	}
 
 	return elt;
-- 
2.19.1

Re: [PATCH] net: Set trailer iff skb1 is the last one

From: Eric Dumazet <edumazet@google.com>
Date: 2020-08-27 11:49:04

On Thu, Aug 27, 2020 at 4:31 AM Miaohe Lin [off-list ref] wrote:
quoted hunk
Set trailer iff skb1 is the skbuff where the tailbits space begins.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 net/core/skbuff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 0b24aed04060..18ed56316e56 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4488,8 +4488,9 @@ int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)
                        skb1 = skb2;
                }
                elt++;
-               *trailer = skb1;
                skb_p = &skb1->next;
+               if (!*skb_p)
+                       *trailer = skb1;
Why is adding a conditional test going to help ?

cpu will have hard time predicting this one, I doubt this kind of
change is a win.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help