From: Antony Antony <antony@phenome.org>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: Antony Antony <antony@phenome.org>,
Steffen Klassert <steffen.klassert@secunet.com>,
netdev@vger.kernel.org, devel@linux-ipsec.org
Subject: Re: [PATCH ipsec-next] xfrm: Use regular error handling instead of BUG_ON() in the netlink API.
Date: Fri, 8 May 2026 05:44:24 +0200 [thread overview]
Message-ID: <af1cGISaaBmQQfqJ@Antony2201.local> (raw)
In-Reply-To: <afxJOGtMkRK5FrvG@krikkit>
On Thu, May 07, 2026 at 10:11:36AM +0200, Sabrina Dubroca via Devel wrote:
> 2026-05-07, 06:21:57 +0100, Antony Antony wrote:
> > wHi Steffen,
> >
> > Thanks Steffen, I was hit by this in the new XFRM_MIGRATE_STATE I am adding.
> > I am glad to see we are addressing this.
> >
> > On Wed, May 06, 2026 at 06:08:55PM +0200, Steffen Klassert via Devel wrote:
> > > The xfrm netlink API uses BUG_ON() on failures since it exists.
> > > However all these error are uncritical and can be handled
> > > with regular error handling. This fixes machine crashes
> > > in situations where an emergency break is not needed.
> >
> > While BUG_ON is an extreme measure for a recoverable netlink error, it does
> > have diagnostic value: it leaves a stack trace. The patch trades
> > a crash + stack trace for a silent error return, which loses observability.
> >
> > Would you consider using WARN_ONCE instead of a bare if (err < 0)?
> >
> > - BUG_ON(err < 0);
> > + if (WARN_ONCE(err < 0, "xfrm: build_spdinfo failed: %d\n", err)) {
> > + kfree_skb(r_skb);
> > + return err;
> > + }
>
> OTOH we already have a bunch of functions doing something similar
> without using BUG_ON/WARN_ON, so at least with this patch it becomes
> consistent.
>
> xfrm_notify_userpolicy
> xfrm_get_default
> xfrm_get_ae
> xfrm_exp_state_notify
> xfrm_notify_sa_flush
> xfrm_notify_sa
> xfrm_notify_policy
> xfrm_notify_policy_flush
>
>
> (I'm looking into generic ways to avoid this split getsize/fill that
> always becomes inconsistent in areas where new attributes are added
> frequently, but nothing to share yet)
>
> > Something like the above would preserve the "shouldn't happen" signal with a
> > stack trace on first occurrence, without panicking the machine.
> > Or are there better signaling styles in Kernel?
>
> Maybe DEBUG_NET_WARN_ON_ONCE so that only developers see those messages.
I would discourage DEBUG_NET_* here, because these situations are not often
caught by testing or by developers. Typically IPsec builds disable debug
completely - and I would even speculate that is why it was BUG_ON in the
early days. If IPsec failed, halting was justified back then. While these
days it is less so.
I vote for something along the lines of WARN_*. That has a higher chance of gathering better diagnostics for developers.
Would other IKE userspace developers like to chime in?
-antony
prev parent reply other threads:[~2026-05-08 3:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 16:08 [PATCH ipsec-next] xfrm: Use regular error handling instead of BUG_ON() in the netlink API Steffen Klassert
2026-05-06 17:20 ` Sabrina Dubroca
2026-05-07 5:21 ` Antony Antony
2026-05-07 8:11 ` Sabrina Dubroca
2026-05-08 3:44 ` Antony Antony [this message]
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=af1cGISaaBmQQfqJ@Antony2201.local \
--to=antony@phenome.org \
--cc=devel@linux-ipsec.org \
--cc=netdev@vger.kernel.org \
--cc=sd@queasysnail.net \
--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