History

sk_buff: drop all skb extensions on free and skb scrubbing

Now that we have a 3rd extension, add a new helper that drops the extension space and use it when we need to scrub an sk_buff. At this time, scrubbing clears secpath and bridge netfilter data, but retains the tc skb extension, after this patch all three get cleared. NAPI reuse/free assumes we can only have a secpath attached to skb, but it seems better to clear all extensions there as well. v2: add unlikely hint (Eric Dumazet)

Florian Westphal committed 7 years ago

Commit 174e2381 parent 6b3656a3 files · +12 −3Browse files

Unified · Split

3 files
  1. include/linux/skbuff.h +9 −0
  2. net/core/dev.c +2 −2
  3. net/core/skbuff.c +1 −1
include/linux/skbuff.h+9−0
@@ -4144,8 +4144,17 @@ static inline void *skb_ext_find(const struct sk_buff *skb, enum skb_ext_id id) · 4143 unmodified lines
4144 4144
4145 return NULL;4145 return NULL;
4146}4146}
4147
4148static inline void skb_ext_reset(struct sk_buff *skb)
4149{
4150 if (unlikely(skb->active_extensions)) {
4151 __skb_ext_put(skb->extensions);
4152 skb->active_extensions = 0;
4153 }
4154}
4147#else4155#else
4148static inline void skb_ext_put(struct sk_buff *skb) {}4156static inline void skb_ext_put(struct sk_buff *skb) {}
4157static inline void skb_ext_reset(struct sk_buff *skb) {}
4149static inline void skb_ext_del(struct sk_buff *skb, int unused) {}4158static inline void skb_ext_del(struct sk_buff *skb, int unused) {}
4150static inline void __skb_ext_copy(struct sk_buff *d, const struct sk_buff *s) {}4159static inline void __skb_ext_copy(struct sk_buff *d, const struct sk_buff *s) {}
4151static inline void skb_ext_copy(struct sk_buff *dst, const struct sk_buff *s) {}4160static inline void skb_ext_copy(struct sk_buff *dst, const struct sk_buff *s) {}
net/core/dev.c+2−2
@@ -5666,7 +5666,7 @@ EXPORT_SYMBOL(gro_find_complete_by_type); · 5665 unmodified lines
5666static void napi_skb_free_stolen_head(struct sk_buff *skb)5666static void napi_skb_free_stolen_head(struct sk_buff *skb)
5667{5667{
5668 skb_dst_drop(skb);5668 skb_dst_drop(skb);
5669 secpath_reset(skb);5669 skb_ext_put(skb);
5670 kmem_cache_free(skbuff_head_cache, skb);5670 kmem_cache_free(skbuff_head_cache, skb);
5671}5671}
5672 5672
@@ -5733,7 +5733,7 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) · 60 unmodified lines
5733 skb->encapsulation = 0;5733 skb->encapsulation = 0;
5734 skb_shinfo(skb)->gso_type = 0;5734 skb_shinfo(skb)->gso_type = 0;
5735 skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));5735 skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
5736 secpath_reset(skb);5736 skb_ext_reset(skb);
5737 5737
5738 napi->skb = skb;5738 napi->skb = skb;
5739}5739}
net/core/skbuff.c+1−1
@@ -5119,7 +5119,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet) · 5118 unmodified lines
5119 skb->skb_iif = 0;5119 skb->skb_iif = 0;
5120 skb->ignore_df = 0;5120 skb->ignore_df = 0;
5121 skb_dst_drop(skb);5121 skb_dst_drop(skb);
5122 secpath_reset(skb);5122 skb_ext_reset(skb);
5123 nf_reset(skb);5123 nf_reset(skb);
5124 nf_reset_trace(skb);5124 nf_reset_trace(skb);
5125 5125

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t