diff options
author | David S. Miller <davem@davemloft.net> | 2018-12-21 10:24:54 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-12-21 10:24:54 -0800 |
commit | 64935310f2fc0128373bbbcfb5b8b49fd26e2ae8 (patch) | |
tree | 11fb43824d249c87afe417bef0b9c372077972b4 | |
parent | 7fa4bd739fc0fa209fa5120383aab17f6e9600f7 (diff) | |
parent | 682ec859518d73435cc924d816da2953343241c1 (diff) | |
download | linux-64935310f2fc0128373bbbcfb5b8b49fd26e2ae8.tar.bz2 |
Merge branch 'skb_ext-fixes'
Paolo Abeni says:
====================
net: skb extension follow-ups
This series includes some follow-up for the recently added skb extension.
The first patch addresses an unlikely race while adding skb extensions,
and the following two are just minor code clean-up.
v1 -> v2:
- be sure to flag the newly added extension as active in skb_ext_add()
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/skbuff.h | 11 | ||||
-rw-r--r-- | net/core/skbuff.c | 9 |
2 files changed, 3 insertions, 17 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 3f741b04e55d..2a57a365c711 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3938,16 +3938,6 @@ static inline void skb_ext_put(struct sk_buff *skb) __skb_ext_put(skb->extensions); } -static inline void skb_ext_get(struct sk_buff *skb) -{ - if (skb->active_extensions) { - struct skb_ext *ext = skb->extensions; - - if (ext) - refcount_inc(&ext->refcnt); - } -} - static inline void __skb_ext_copy(struct sk_buff *dst, const struct sk_buff *src) { @@ -3995,7 +3985,6 @@ static inline void *skb_ext_find(const struct sk_buff *skb, enum skb_ext_id id) } #else static inline void skb_ext_put(struct sk_buff *skb) {} -static inline void skb_ext_get(struct sk_buff *skb) {} static inline void skb_ext_del(struct sk_buff *skb, int unused) {} static inline void __skb_ext_copy(struct sk_buff *d, const struct sk_buff *s) {} static inline void skb_ext_copy(struct sk_buff *dst, const struct sk_buff *s) {} diff --git a/net/core/skbuff.c b/net/core/skbuff.c index cb0bf4215745..37317ffec146 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5666,13 +5666,10 @@ void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id id) if (!new) return NULL; - if (__skb_ext_exist(old, id)) { - if (old != new) - skb->extensions = new; + if (__skb_ext_exist(new, id)) goto set_active; - } - newoff = old->chunks; + newoff = new->chunks; } else { newoff = SKB_EXT_CHUNKSIZEOF(*new); @@ -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); } |