* [PATCH iproute2-next v2 0/3] Add support for seg6 tunsrc
@ 2026-03-20 14:08 Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 1/3] uapi: add SEG6_IPTUNNEL_SRC Justin Iurman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Justin Iurman @ 2026-03-20 14:08 UTC (permalink / raw)
To: netdev
Cc: dsahern, stephen, andrea.mayer, justin.iurman, nicolas.dichtel,
stefano.salsano, Justin Iurman
This series adds support for the new per-route seg6 "tunsrc" parameter.
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
Justin Iurman (3):
uapi: add SEG6_IPTUNNEL_SRC
seg6: add tunsrc support in iproute_lwtunnel
man8: update seg6 encap documentation
include/uapi/linux/seg6_iptunnel.h | 1 +
ip/iproute_lwtunnel.c | 31 ++++++++++++++++++++++++++++++
man/man8/ip-route.8.in | 13 ++++++++++++-
3 files changed, 44 insertions(+), 1 deletion(-)
---
v2: include uapi change
v1:
https://lore.kernel.org/netdev/20260316164907.1255510-1-justin.iurman@6wind.com/
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH iproute2-next v2 1/3] uapi: add SEG6_IPTUNNEL_SRC
2026-03-20 14:08 [PATCH iproute2-next v2 0/3] Add support for seg6 tunsrc Justin Iurman
@ 2026-03-20 14:08 ` Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 2/3] seg6: add tunsrc support in iproute_lwtunnel Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 3/3] man8: update seg6 encap documentation Justin Iurman
2 siblings, 0 replies; 4+ messages in thread
From: Justin Iurman @ 2026-03-20 14:08 UTC (permalink / raw)
To: netdev
Cc: dsahern, stephen, andrea.mayer, justin.iurman, nicolas.dichtel,
stefano.salsano, Justin Iurman
Rebase uapi to have support for SEG6_IPTUNNEL_SRC.
Signed-off-by: Justin Iurman <justin.iurman@6wind.com>
---
include/uapi/linux/seg6_iptunnel.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/seg6_iptunnel.h b/include/uapi/linux/seg6_iptunnel.h
index e1929d21c0b6..993a7bd06775 100644
--- a/include/uapi/linux/seg6_iptunnel.h
+++ b/include/uapi/linux/seg6_iptunnel.h
@@ -20,6 +20,7 @@
enum {
SEG6_IPTUNNEL_UNSPEC,
SEG6_IPTUNNEL_SRH,
+ SEG6_IPTUNNEL_SRC,
__SEG6_IPTUNNEL_MAX,
};
#define SEG6_IPTUNNEL_MAX (__SEG6_IPTUNNEL_MAX - 1)
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH iproute2-next v2 2/3] seg6: add tunsrc support in iproute_lwtunnel
2026-03-20 14:08 [PATCH iproute2-next v2 0/3] Add support for seg6 tunsrc Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 1/3] uapi: add SEG6_IPTUNNEL_SRC Justin Iurman
@ 2026-03-20 14:08 ` Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 3/3] man8: update seg6 encap documentation Justin Iurman
2 siblings, 0 replies; 4+ messages in thread
From: Justin Iurman @ 2026-03-20 14:08 UTC (permalink / raw)
To: netdev
Cc: dsahern, stephen, andrea.mayer, justin.iurman, nicolas.dichtel,
stefano.salsano, 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] 4+ messages in thread
* [PATCH iproute2-next v2 3/3] man8: update seg6 encap documentation
2026-03-20 14:08 [PATCH iproute2-next v2 0/3] Add support for seg6 tunsrc Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 1/3] uapi: add SEG6_IPTUNNEL_SRC Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 2/3] seg6: add tunsrc support in iproute_lwtunnel Justin Iurman
@ 2026-03-20 14:08 ` Justin Iurman
2 siblings, 0 replies; 4+ messages in thread
From: Justin Iurman @ 2026-03-20 14:08 UTC (permalink / raw)
To: netdev
Cc: dsahern, stephen, andrea.mayer, justin.iurman, nicolas.dichtel,
stefano.salsano, 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] 4+ messages in thread
end of thread, other threads:[~2026-03-20 14:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 14:08 [PATCH iproute2-next v2 0/3] Add support for seg6 tunsrc Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 1/3] uapi: add SEG6_IPTUNNEL_SRC Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 2/3] seg6: add tunsrc support in iproute_lwtunnel Justin Iurman
2026-03-20 14:08 ` [PATCH iproute2-next v2 3/3] 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