Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2-next v2] iplink: amt: support an IPv6 outer transport
@ 2026-11-26  0:43 Omar Ramadan
  0 siblings, 0 replies; only message in thread
From: Omar Ramadan @ 2026-11-26  0:43 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern, Stephen Hemminger

The amt driver can now run AMT over IPv6 (net-next, "amt: add netlink
attributes for an IPv6 outer transport"). IFLA_AMT_LOCAL_IP6 selects
IPv6 as the outer transport, IFLA_AMT_DISCOVERY_IP6 is the IPv6 address
a gateway discovers its relay through, and IFLA_AMT_REMOTE_IP6 reports
the relay address the gateway learned.

Put an IPv6 local or discovery address in the new attributes, and print
all three under the same keys as their IPv4 counterparts; a device has
one family, so only one of each pair is present. Until now an IPv6
literal was put in the 4-byte IPv4 attribute: older kernels quietly
used its first four bytes as an IPv4 address, and kernels whose policy
sets the attribute's exact length reject it.

  ip link add amtg type amt mode gateway local 2001:db8:a::1 \
          discovery 2001:db8:a::2 dev eth0

This needs include/uapi/linux/amt.h synced with the kernel change.

Assisted-by: LLM
Signed-off-by: Omar Ramadan <omar@blockcast.net>
---
v2: print each IPv6 address with print_color_string() and
format_host_r(), and the keyword outside the color, as ip6tunnel.c
does (Stephen Hemminger).
v1: https://lore.kernel.org/netdev/20261125170100.3054010-iproute2-omar@blockcast.net/

 ip/iplink_amt.c       | 39 +++++++++++++++++++++++++++++++++++++--
 man/man8/ip-link.8.in |  6 +++++-
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/ip/iplink_amt.c b/ip/iplink_amt.c
index 3a35bd9..2370bc5 100644
--- a/ip/iplink_amt.c
+++ b/ip/iplink_amt.c
@@ -107,7 +107,10 @@ static int amt_parse_opt(struct link_util *lu, int argc, char **argv,
 			check_duparg(&attrs, IFLA_AMT_LOCAL_IP, "local", *argv);
 			get_addr(&saddr, *argv, daddr.family);
 
-			if (is_addrtype_inet(&saddr))
+			if (saddr.family == AF_INET6)
+				addattr_l(n, 1024, IFLA_AMT_LOCAL_IP6,
+					  saddr.data, saddr.bytelen);
+			else if (is_addrtype_inet(&saddr))
 				addattr_l(n, 1024, IFLA_AMT_LOCAL_IP,
 					  saddr.data, saddr.bytelen);
 		} else if (strcmp(*argv, "discovery") == 0) {
@@ -115,7 +118,10 @@ static int amt_parse_opt(struct link_util *lu, int argc, char **argv,
 			check_duparg(&attrs, IFLA_AMT_DISCOVERY_IP,
 				     "discovery", *argv);
 			get_addr(&daddr, *argv, daddr.family);
-			if (is_addrtype_inet(&daddr))
+			if (daddr.family == AF_INET6)
+				addattr_l(n, 1024, IFLA_AMT_DISCOVERY_IP6,
+					  daddr.data, daddr.bytelen);
+			else if (is_addrtype_inet(&daddr))
 				addattr_l(n, 1024, IFLA_AMT_DISCOVERY_IP,
 					  daddr.data, daddr.bytelen);
 		} else if (strcmp(*argv, "help") == 0) {
@@ -134,6 +140,8 @@ static int amt_parse_opt(struct link_util *lu, int argc, char **argv,
 
 static void amt_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 {
+	SPRINT_BUF(b1);
+
 	if (!tb)
 		return;
 
@@ -156,6 +164,15 @@ static void amt_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 			     format_host(AF_INET, 4, &addr));
 	}
 
+	if (tb[IFLA_AMT_LOCAL_IP6]) {
+		const void *addr = RTA_DATA(tb[IFLA_AMT_LOCAL_IP6]);
+
+		print_string(PRINT_FP, NULL, "%s", "local ");
+		print_color_string(PRINT_ANY, COLOR_INET6, "local", "%s ",
+				   format_host_r(AF_INET6, 16, addr,
+						 b1, sizeof(b1)));
+	}
+
 	if (tb[IFLA_AMT_REMOTE_IP]) {
 		__be32 addr = rta_getattr_u32(tb[IFLA_AMT_REMOTE_IP]);
 
@@ -163,6 +180,15 @@ static void amt_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 			     format_host(AF_INET, 4, &addr));
 	}
 
+	if (tb[IFLA_AMT_REMOTE_IP6]) {
+		const void *addr = RTA_DATA(tb[IFLA_AMT_REMOTE_IP6]);
+
+		print_string(PRINT_FP, NULL, "%s", "remote ");
+		print_color_string(PRINT_ANY, COLOR_INET6, "remote", "%s ",
+				   format_host_r(AF_INET6, 16, addr,
+						 b1, sizeof(b1)));
+	}
+
 	if (tb[IFLA_AMT_DISCOVERY_IP]) {
 		__be32 addr = rta_getattr_u32(tb[IFLA_AMT_DISCOVERY_IP]);
 
@@ -170,6 +196,15 @@ static void amt_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 			     format_host(AF_INET, 4, &addr));
 	}
 
+	if (tb[IFLA_AMT_DISCOVERY_IP6]) {
+		const void *addr = RTA_DATA(tb[IFLA_AMT_DISCOVERY_IP6]);
+
+		print_string(PRINT_FP, NULL, "%s", "discovery ");
+		print_color_string(PRINT_ANY, COLOR_INET6, "discovery", "%s ",
+				   format_host_r(AF_INET6, 16, addr,
+						 b1, sizeof(b1)));
+	}
+
 	if (tb[IFLA_AMT_LINK]) {
 		unsigned int link = rta_getattr_u32(tb[IFLA_AMT_LINK]);
 
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 8fd900e..48d2ca9 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -1616,12 +1616,16 @@ the following additional arguments are supported:
 .sp
 .BI discovery " IPADDR"
 - specifies the unicast discovery IP address to use to find remote IP address.
+It must be of the same family as the
+.B local
+address.
 
 .BR mode " { " gateway " | " relay " } "
 - specifies the role of AMT, Gateway or Relay
 
 .BI local " IPADDR "
-- specifies the source IP address to use in outgoing packets.
+- specifies the source IP address to use in outgoing packets. An IPv6
+address makes the device use IPv6 as the outer transport of the tunnel.
 
 .BI dev " PHYS_DEV "
 - specifies the underlying physical interface from which transform traffic

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-26  0:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  0:43 [PATCH iproute2-next v2] iplink: amt: support an IPv6 outer transport Omar Ramadan

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