From: Jakub Sitnicki <jakub@cloudflare.com>
To: netdev@vger.kernel.org, Florian Westphal <fw@strlen.de>,
Paolo Abeni <pabeni@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Simon Horman <horms@kernel.org>,
Jeremy Kerr <jk@codeconstruct.com.au>,
Matt Johnston <matt@codeconstruct.com.au>,
Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
kernel-team@cloudflare.com
Subject: [PATCH net-next 1/2] net: Make skb_ext_put_sp() idempotent
Date: Mon, 31 Aug 2026 08:27:38 +0200 [thread overview]
Message-ID: <20260831-skb-ext-prep-work-v1-1-ecc2a8542fd9@cloudflare.com> (raw)
In-Reply-To: <20260831-skb-ext-prep-work-v1-0-ecc2a8542fd9@cloudflare.com>
The sec_path extension can be released either when it is deleted from an
skb or when the last skb holding the extension block is freed. Make
skb_ext_put_sp() safe to call from both paths by returning when
sec_path->len is zero and clearing it after dropping the XFRM state
references.
This will let __skb_ext_put() release the sec_path without checking whether
the extension is present first, which is needed if we want to reuse skb_ext
chunks area after skb scrubbing.
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
---
net/core/skbuff.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 966af3beed94..aa8b42c74f42 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -7236,8 +7236,12 @@ static void skb_ext_put_sp(struct sec_path *sp)
{
unsigned int i;
+ if (!sp->len)
+ return;
+
for (i = 0; i < sp->len; i++)
xfrm_state_put(sp->xvec[i]);
+ sp->len = 0;
}
#endif
@@ -7260,10 +7264,8 @@ void __skb_ext_del(struct sk_buff *skb, enum skb_ext_id id)
#ifdef CONFIG_XFRM
} else if (id == SKB_EXT_SEC_PATH &&
refcount_read(&ext->refcnt) == 1) {
- struct sec_path *sp = skb_ext_get_ptr(ext, SKB_EXT_SEC_PATH);
- skb_ext_put_sp(sp);
- sp->len = 0;
+ skb_ext_put_sp(skb_ext_get_ptr(ext, SKB_EXT_SEC_PATH));
#endif
}
}
--
2.43.0
next prev parent reply other threads:[~2026-08-31 6:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 6:27 [PATCH net-next 0/2] net: Prepare skb extensions for reuse across scrubs Jakub Sitnicki
2026-08-31 6:27 ` Jakub Sitnicki [this message]
2026-09-02 0:15 ` [PATCH net-next 1/2] net: Make skb_ext_put_sp() idempotent Jakub Kicinski
2026-09-02 5:51 ` Jakub Sitnicki
2026-09-02 9:24 ` Paolo Abeni
2026-09-02 14:03 ` Florian Westphal
2026-08-31 6:27 ` [PATCH net-next 2/2] net: Make skb_ext_put_mctp() idempotent Jakub Sitnicki
2026-09-01 5:26 ` Jeremy Kerr
2026-09-02 0:36 ` [PATCH net-next 0/2] net: Prepare skb extensions for reuse across scrubs patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260831-skb-ext-prep-work-v1-1-ecc2a8542fd9@cloudflare.com \
--to=jakub@cloudflare.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=jk@codeconstruct.com.au \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=matt@codeconstruct.com.au \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox