Re: [RFC PATCH net-next 2/3] seg6: add SRv6 L2 tunnel device (srl2)

From: Andrea Mayer

Date: Mon Mar 30 2026 - 21:02:02 EST


On Thu, 26 Mar 2026 17:44:29 +0100
Nicolas Dichtel <nicolas.dichtel@xxxxxxxxx> wrote:

>
>

Thanks Nicolas for your time and for the review.


> Le 22/03/2026 à 01:05, Andrea Mayer a écrit :
> > Introduce srl2, an Ethernet pseudowire device over SRv6. It
> > encapsulates L2 frames in IPv6 with a Segment Routing Header for
> > transmission across an SRv6 network.
> >
> > The encapsulation logic reuses seg6_do_srh_encap() with
> > IPPROTO_ETHERNET. The transmit path uses the standard IPv6 tunnel
> > infrastructure (dst_cache, ip6_route_output, ip6tunnel_xmit).
> >
> > The device is configured with a segment list for point-to-point
> > L2 encapsulation.
> >
> > Usage:
> >
> > ip link add srl2-0 type srl2 segs fc00::a,fc00::b
> >
> > Co-developed-by: Stefano Salsano <stefano.salsano@xxxxxxxxxxx>
> > Signed-off-by: Stefano Salsano <stefano.salsano@xxxxxxxxxxx>
> > Signed-off-by: Andrea Mayer <andrea.mayer@xxxxxxxxxxx>
> > ---
> > include/linux/srl2.h | 7 +
> > include/uapi/linux/srl2.h | 20 +++
> > net/ipv6/Kconfig | 16 +++
> > net/ipv6/Makefile | 1 +
> > net/ipv6/seg6.c | 1 +
> > net/ipv6/srl2.c | 269 ++++++++++++++++++++++++++++++++++++++
> > 6 files changed, 314 insertions(+)
> > create mode 100644 include/linux/srl2.h
> > create mode 100644 include/uapi/linux/srl2.h
> > create mode 100644 net/ipv6/srl2.c
> >
> > diff --git a/include/linux/srl2.h b/include/linux/srl2.h
> > new file mode 100644
> > index 000000000000..c1342b979402
> > --- /dev/null
> > +++ b/include/linux/srl2.h
> > @@ -0,0 +1,7 @@
> > +/* SPDX-License-Identifier: GPL-2.0-or-later */
> > +#ifndef _LINUX_SRL2_H
> > +#define _LINUX_SRL2_H
> > +
> > +#include <uapi/linux/srl2.h>
> > +
> > +#endif
> Is this really needed?

No. Moving IFLA_SRL2_* to if_link.h makes both srl2.h headers
unnecessary.


>
> > diff --git a/include/uapi/linux/srl2.h b/include/uapi/linux/srl2.h
> > new file mode 100644
> > index 000000000000..e7c8f6fc0791
> > --- /dev/null
> > +++ b/include/uapi/linux/srl2.h
> > @@ -0,0 +1,20 @@
> > +/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */
> > +/*
> > + * SRv6 L2 tunnel device
> > + *
> > + * Author:
> > + * Andrea Mayer <andrea.mayer@xxxxxxxxxxx>
> > + */
> > +
> > +#ifndef _UAPI_LINUX_SRL2_H
> > +#define _UAPI_LINUX_SRL2_H
> > +
> > +enum {
> > + IFLA_SRL2_UNSPEC,
> > + IFLA_SRL2_SRH, /* binary: struct ipv6_sr_hdr + segments */
> > + __IFLA_SRL2_MAX,
> > +};
> > +
> > +#define IFLA_SRL2_MAX (__IFLA_SRL2_MAX - 1)
> It should probably be generated automatically from specs, see
> https://docs.kernel.org/userspace-api/netlink/intro-specs.html
>

We'll add srl2 to rt-link.yaml. It seems that if_link.h is not
auto-generated from the spec yet, so I think we need to add
IFLA_SRL2_* there manually like the other link types.


> > [snip]
> > +static void srl2_setup(struct net_device *dev)
> > +{
> > + ether_setup(dev);
> > +
> > + dev->netdev_ops = &srl2_netdev_ops;
> > + dev->needs_free_netdev = true;
> > + dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
> > + dev->needed_headroom = LL_MAX_HEADER + sizeof(struct ipv6hdr) +
> > + SRL2_SRH_HEADROOM_EST;
> > +
> > + dev->priv_flags &= ~IFF_TX_SKB_SHARING;
> > + dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
> > + dev->lltx = true;
> > +
> Maybe setting dev->netns_immutable to true ?
>

It makes sense; the SRv6 configuration is bound to the current
netns, so the device should stay there as well.


> Regards,
> Nicolas

Thanks,
Andrea