[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <76dff768078f418b5b1e7555e468b11256cc9d6d.1545413818.git.pabeni@redhat.com>
Date: Fri, 21 Dec 2018 19:03:15 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Florian Westphal <fw@...len.de>
Subject: [PATCH net-next v2 3/3] net: minor cleanup in skb_ext_add()
When the extension to be added is already present, the only
skb field we may need to update is 'extensions': we can reorder
the code and avoid a branch.
v1 -> v2:
- be sure to flag the newly added extension as active
Signed-off-by: Paolo Abeni <pabeni@...hat.com>
---
net/core/skbuff.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e1d88762f659..37317ffec146 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5666,11 +5666,8 @@ void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id id)
if (!new)
return NULL;
- if (__skb_ext_exist(new, id)) {
- if (old != new)
- skb->extensions = new;
+ if (__skb_ext_exist(new, id))
goto set_active;
- }
newoff = new->chunks;
} else {
@@ -5684,8 +5681,8 @@ void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id id)
newlen = newoff + skb_ext_type_len[id];
new->chunks = newlen;
new->offset[id] = newoff;
- skb->extensions = new;
set_active:
+ skb->extensions = new;
skb->active_extensions |= 1 << id;
return skb_ext_get_ptr(new, id);
}
--
2.19.2
Powered by blists - more mailing lists