Skip to content

Commit 174e238

Browse files
Florian Westphaldavem330
authored andcommitted
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) Fixes: 95a7233 ("net: openvswitch: Set OvS recirc_id from tc chain index") Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6b3656a commit 174e238

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

include/linux/skbuff.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4144,8 +4144,17 @@ static inline void *skb_ext_find(const struct sk_buff *skb, enum skb_ext_id id)
41444144

41454145
return NULL;
41464146
}
4147+
4148+
static 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+
}
41474155
#else
41484156
static inline void skb_ext_put(struct sk_buff *skb) {}
4157+
static inline void skb_ext_reset(struct sk_buff *skb) {}
41494158
static inline void skb_ext_del(struct sk_buff *skb, int unused) {}
41504159
static inline void __skb_ext_copy(struct sk_buff *d, const struct sk_buff *s) {}
41514160
static inline void skb_ext_copy(struct sk_buff *dst, const struct sk_buff *s) {}

net/core/dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5666,7 +5666,7 @@ EXPORT_SYMBOL(gro_find_complete_by_type);
56665666
static void napi_skb_free_stolen_head(struct sk_buff *skb)
56675667
{
56685668
skb_dst_drop(skb);
5669-
secpath_reset(skb);
5669+
skb_ext_put(skb);
56705670
kmem_cache_free(skbuff_head_cache, skb);
56715671
}
56725672

@@ -5733,7 +5733,7 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
57335733
skb->encapsulation = 0;
57345734
skb_shinfo(skb)->gso_type = 0;
57355735
skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
5736-
secpath_reset(skb);
5736+
skb_ext_reset(skb);
57375737

57385738
napi->skb = skb;
57395739
}

net/core/skbuff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5119,7 +5119,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
51195119
skb->skb_iif = 0;
51205120
skb->ignore_df = 0;
51215121
skb_dst_drop(skb);
5122-
secpath_reset(skb);
5122+
skb_ext_reset(skb);
51235123
nf_reset(skb);
51245124
nf_reset_trace(skb);
51255125

0 commit comments

Comments
 (0)