Re: [PATCH net-next v2] net: ipv6: seg6: report lwtunnel setup errors via extack

From: Gabriel Goller

Date: Wed Sep 23 2026 - 08:00:20 EST


On 23.09.2026 09:29, Hangbin Liu wrote:
> On Tue, Sep 22, 2026 at 11:08:33AM +0200, Gabriel Goller wrote:
> > seg6_build_state() rejected invalid configurations with a generic -EINVAL, so
> > "ip route add ... encap seg6 ..." always reported "Invalid argument".
> >
> > Attach an extack message to each of them. The checks themselves and their return
> > values are unchanged.
> >
> > Signed-off-by: Gabriel Goller <g.goller@xxxxxxxxxxx>
> > ---
> >
> > v2 (https://lore.kernel.org/netdev/20260918153544.1178884-1-g.goller@xxxxxxxxxxx/):
> > * dropped tests
> >
> > net/ipv6/seg6_iptunnel.c | 25 ++++++++++++++++++++-----
> > 1 file changed, 20 insertions(+), 5 deletions(-)
> >
> > diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
> > index 61c6a27bf202..e7f75970e26e 100644
> > --- a/net/ipv6/seg6_iptunnel.c
> > +++ b/net/ipv6/seg6_iptunnel.c
> > @@ -756,8 +756,12 @@ static int seg6_build_state(struct net *net, struct nlattr *nla,
> > struct seg6_lwt *slwt;
> > int err;
> >
> > - if (family != AF_INET && family != AF_INET6)
> > + if (family != AF_INET && family != AF_INET6) {
> > + NL_SET_ERR_MSG(
> > + extack,
> > + "unsupported address family for SRv6 encapsulation");
> > return -EINVAL;
> > + }
> >
> > err = nla_parse_nested_deprecated(tb, SEG6_IPTUNNEL_MAX, nla,
> > seg6_iptunnel_policy, extack);
> > @@ -765,8 +769,10 @@ static int seg6_build_state(struct net *net, struct nlattr *nla,
> > if (err < 0)
> > return err;
> >
> > - if (!tb[SEG6_IPTUNNEL_SRH])
> > + if (!tb[SEG6_IPTUNNEL_SRH]) {
> > + NL_SET_ERR_MSG(extack, "missing SRv6 SRH attribute");
>
> I think we can use NL_SET_ERR_MSG_ATTR.

Done, thanks!

Gabriel

>
> Thanks
> Hangbin
>
>