public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next 0/2] Add support for seg6 tunsrc
@ 2026-03-16 16:49 Justin Iurman
  2026-03-16 16:49 ` [PATCH iproute2-next 1/2] seg6: add tunsrc support in iproute_lwtunnel Justin Iurman
  2026-03-16 16:49 ` [PATCH iproute2-next 2/2] man8: update seg6 encap documentation Justin Iurman
  0 siblings, 2 replies; 5+ messages in thread
From: Justin Iurman @ 2026-03-16 16:49 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, stephen, andrea.mayer, justin.iurman, nicolas.dichtel,
	stefano.salsano, paolo.lungaroni, ahabdels, Justin Iurman

This series adds support for the new per-route seg6 "tunsrc" parameter.

A rebase of uapi headers is required (net-next patch is being reviewed).

Justin Iurman (2):
  seg6: add tunsrc support in iproute_lwtunnel
  man8: update seg6 encap documentation

 ip/iproute_lwtunnel.c  | 31 +++++++++++++++++++++++++++++++
 man/man8/ip-route.8.in | 13 ++++++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH iproute2-next 1/2] seg6: add tunsrc support in iproute_lwtunnel
  2026-03-16 16:49 [PATCH iproute2-next 0/2] Add support for seg6 tunsrc Justin Iurman
@ 2026-03-16 16:49 ` Justin Iurman
  2026-03-17 11:10   ` Andrea Mayer
  2026-03-16 16:49 ` [PATCH iproute2-next 2/2] man8: update seg6 encap documentation Justin Iurman
  1 sibling, 1 reply; 5+ messages in thread
From: Justin Iurman @ 2026-03-16 16:49 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, stephen, andrea.mayer, justin.iurman, nicolas.dichtel,
	stefano.salsano, paolo.lungaroni, ahabdels, Justin Iurman

Add support for the new optional "tunsrc" parameter. Now, a tunnel
source address can be configured per route and has priority over the
configured per-netns source address (if any).

Example:
ip -6 r a 2001:db8:1::/64 encap seg6 mode encap tunsrc 2001:db8:ab::
    segs 2001:db8:42::1,2001:db8:ffff::2 dev eth0

Signed-off-by: Justin Iurman <justin.iurman@6wind.com>
---
 ip/iproute_lwtunnel.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index a7885dba28c1..00b4f7565be6 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -266,6 +266,13 @@ static void print_encap_seg6(FILE *fp, struct rtattr *encap)
 	print_string(PRINT_ANY, "mode",
 		     "mode %s ", format_seg6mode_type(tuninfo->mode));
 
+	if (tb[SEG6_IPTUNNEL_SRC]) {
+		print_color_string(PRINT_ANY, COLOR_INET6,
+				   "tunsrc", "tunsrc %s ",
+				   rt_addr_n2a_rta(AF_INET6,
+						   tb[SEG6_IPTUNNEL_SRC]));
+	}
+
 	print_srh(fp, tuninfo->srh);
 }
 
@@ -953,6 +960,8 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp,
 	struct ipv6_sr_hdr *srh;
 	char **argv = *argvp;
 	char segbuf[1024] = "";
+	bool tunsrc = false;
+	inet_prefix saddr;
 	int argc = *argcp;
 	int encap = -1;
 	__u32 hmac = 0;
@@ -967,6 +976,22 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp,
 			encap = read_seg6mode_type(*argv);
 			if (encap < 0)
 				invarg("\"mode\" value is invalid\n", *argv);
+		} else if (strcmp(*argv, "tunsrc") == 0) {
+			NEXT_ARG();
+			if (encap == -1)
+				invarg("\"tunsrc\" provided before \"mode\"\n",
+				       *argv);
+			if (encap == SEG6_IPTUN_MODE_INLINE)
+				invarg("\"tunsrc\" invalid with inline mode\n",
+				       *argv);
+			if (tunsrc)
+				duparg2("tunsrc", *argv);
+
+			get_addr(&saddr, *argv, AF_INET6);
+			if (saddr.family != AF_INET6 || saddr.bytelen != 16)
+				invarg("\"tunsrc\" value is invalid\n", *argv);
+
+			tunsrc = true;
 		} else if (strcmp(*argv, "segs") == 0) {
 			NEXT_ARG();
 			if (segs_ok++)
@@ -1005,6 +1030,12 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp,
 			  sizeof(*tuninfo) + srhlen))
 		goto out;
 
+	if (tunsrc) {
+		if (rta_addattr_l(rta, len, SEG6_IPTUNNEL_SRC,
+				  &saddr.data, saddr.bytelen))
+			goto out;
+	}
+
 	*argcp = argc + 1;
 	*argvp = argv - 1;
 	ret = 0;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2-next 2/2] man8: update seg6 encap documentation
  2026-03-16 16:49 [PATCH iproute2-next 0/2] Add support for seg6 tunsrc Justin Iurman
  2026-03-16 16:49 ` [PATCH iproute2-next 1/2] seg6: add tunsrc support in iproute_lwtunnel Justin Iurman
@ 2026-03-16 16:49 ` Justin Iurman
  1 sibling, 0 replies; 5+ messages in thread
From: Justin Iurman @ 2026-03-16 16:49 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, stephen, andrea.mayer, justin.iurman, nicolas.dichtel,
	stefano.salsano, paolo.lungaroni, ahabdels, Justin Iurman

Include "tunsrc" in the man page.

Signed-off-by: Justin Iurman <justin.iurman@6wind.com>
---
 man/man8/ip-route.8.in | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
index aafa6d98a4c2..9f29fd436f59 100644
--- a/man/man8/ip-route.8.in
+++ b/man/man8/ip-route.8.in
@@ -240,7 +240,9 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
 .IR ENCAP_SEG6 " := "
 .B seg6
 .BR mode " [ "
-.BR encap " | " encap.red " | " inline " | " l2encap " | " l2encap.red " ] "
+.BR encap " | " encap.red " | " inline " | " l2encap " | " l2encap.red " ] ["
+.B tunsrc
+.IR ADDRESS " ]"
 .B segs
 .IR SEGMENTS " [ "
 .B hmac
@@ -893,6 +895,15 @@ applying the reduced segment list. When there is only one segment
 and the HMAC is not present, the SRH is omitted.
 .sp
 
+.B tunsrc
+.I ADDRESS
+- IPv6 address of the tunnel source (outer header), not used with inline mode.
+It is optional: if not provided, the tunnel source address is chosen based on
+the per-netns configuration ("ip sr tunsrc set ADDRESS") or, if not configured,
+it is dynamically resolved. If provided, it takes priority over the per-netns
+configuration and dynamic resolution.
+.sp
+
 .I SEGMENTS
 - List of comma-separated IPv6 addresses
 .sp
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2-next 1/2] seg6: add tunsrc support in iproute_lwtunnel
  2026-03-16 16:49 ` [PATCH iproute2-next 1/2] seg6: add tunsrc support in iproute_lwtunnel Justin Iurman
@ 2026-03-17 11:10   ` Andrea Mayer
  2026-03-18 12:07     ` Justin Iurman
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Mayer @ 2026-03-17 11:10 UTC (permalink / raw)
  To: Justin Iurman
  Cc: netdev, dsahern, stephen, justin.iurman, nicolas.dichtel,
	stefano.salsano, paolo.lungaroni, ahabdels, Andrea Mayer

On Mon, 16 Mar 2026 17:49:06 +0100
Justin Iurman <justin.iurman@6wind.com> wrote:

> Add support for the new optional "tunsrc" parameter. Now, a tunnel
> source address can be configured per route and has priority over the
> configured per-netns source address (if any).
> 
> Example:
> ip -6 r a 2001:db8:1::/64 encap seg6 mode encap tunsrc 2001:db8:ab::
>     segs 2001:db8:42::1,2001:db8:ffff::2 dev eth0
> 
> Signed-off-by: Justin Iurman <justin.iurman@6wind.com>
> ---
>  ip/iproute_lwtunnel.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
> index a7885dba28c1..00b4f7565be6 100644
> --- a/ip/iproute_lwtunnel.c
> +++ b/ip/iproute_lwtunnel.c
> @@ -266,6 +266,13 @@ static void print_encap_seg6(FILE *fp, struct rtattr *encap)
>  	print_string(PRINT_ANY, "mode",
>  		     "mode %s ", format_seg6mode_type(tuninfo->mode));
>  
> +	if (tb[SEG6_IPTUNNEL_SRC]) {
> +		print_color_string(PRINT_ANY, COLOR_INET6,
> +				   "tunsrc", "tunsrc %s ",
> +				   rt_addr_n2a_rta(AF_INET6,
> +						   tb[SEG6_IPTUNNEL_SRC]));
> +	}
> +
>  	print_srh(fp, tuninfo->srh);
>  }
>  

Hi Justin,

This doesn't build: SEG6_IPTUNNEL_SRC is used in iproute_lwtunnel.c
but the UAPI header sync for include/uapi/linux/seg6_iptunnel.h is
missing from this patch. Please include it.

Thanks,
Andrea

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2-next 1/2] seg6: add tunsrc support in iproute_lwtunnel
  2026-03-17 11:10   ` Andrea Mayer
@ 2026-03-18 12:07     ` Justin Iurman
  0 siblings, 0 replies; 5+ messages in thread
From: Justin Iurman @ 2026-03-18 12:07 UTC (permalink / raw)
  To: Andrea Mayer
  Cc: netdev, dsahern, stephen, justin.iurman, nicolas.dichtel,
	stefano.salsano, paolo.lungaroni, ahabdels

On Tue, Mar 17, 2026 at 12:10 PM Andrea Mayer <andrea.mayer@uniroma2.it> wrote:
>
> On Mon, 16 Mar 2026 17:49:06 +0100
> Justin Iurman <justin.iurman@6wind.com> wrote:
>
> > Add support for the new optional "tunsrc" parameter. Now, a tunnel
> > source address can be configured per route and has priority over the
> > configured per-netns source address (if any).
> >
> > Example:
> > ip -6 r a 2001:db8:1::/64 encap seg6 mode encap tunsrc 2001:db8:ab::
> >     segs 2001:db8:42::1,2001:db8:ffff::2 dev eth0
> >
> > Signed-off-by: Justin Iurman <justin.iurman@6wind.com>
> > ---
> >  ip/iproute_lwtunnel.c | 31 +++++++++++++++++++++++++++++++
> >  1 file changed, 31 insertions(+)

[snip]

> Hi Justin,
>
> This doesn't build: SEG6_IPTUNNEL_SRC is used in iproute_lwtunnel.c
> but the UAPI header sync for include/uapi/linux/seg6_iptunnel.h is
> missing from this patch. Please include it.

Hi Andrea,

I usually don't include uapi changes in iproute2-next patches: instead
I add a note that it needs a uapi rebase, which I forgot btw (i.e.,
David would drop it and rebase uapi from net-next anyway). Right, I'll
send v2 and include it to simplify testing.

Cheers,
Justin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-18 12:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 16:49 [PATCH iproute2-next 0/2] Add support for seg6 tunsrc Justin Iurman
2026-03-16 16:49 ` [PATCH iproute2-next 1/2] seg6: add tunsrc support in iproute_lwtunnel Justin Iurman
2026-03-17 11:10   ` Andrea Mayer
2026-03-18 12:07     ` Justin Iurman
2026-03-16 16:49 ` [PATCH iproute2-next 2/2] man8: update seg6 encap documentation Justin Iurman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox