Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2-next] iplink: amt: support an IPv6 outer transport
@ 2026-11-25 19:14 Omar Ramadan
  2026-11-25 22:54 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Omar Ramadan @ 2026-11-25 19:14 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>
---
 ip/iplink_amt.c       | 31 +++++++++++++++++++++++++++++--
 man/man8/ip-link.8.in |  6 +++++-
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/ip/iplink_amt.c b/ip/iplink_amt.c
index 3a35bd9..22e935d 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) {
@@ -156,6 +162,13 @@ 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_ANY, "local", "local %s ",
+			     format_host(AF_INET6, 16, addr));
+	}
+
 	if (tb[IFLA_AMT_REMOTE_IP]) {
 		__be32 addr = rta_getattr_u32(tb[IFLA_AMT_REMOTE_IP]);
 
@@ -163,6 +176,13 @@ 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_ANY, "remote", "remote %s ",
+			     format_host(AF_INET6, 16, addr));
+	}
+
 	if (tb[IFLA_AMT_DISCOVERY_IP]) {
 		__be32 addr = rta_getattr_u32(tb[IFLA_AMT_DISCOVERY_IP]);
 
@@ -170,6 +190,13 @@ 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_ANY, "discovery", "discovery %s ",
+			     format_host(AF_INET6, 16, addr));
+	}
+
 	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 719781b..c9cf0b3 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
-- 
2.50.1 (Apple Git-155)


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

* Re: [PATCH iproute2-next] iplink: amt: support an IPv6 outer transport
  2026-11-25 19:14 [PATCH iproute2-next] iplink: amt: support an IPv6 outer transport Omar Ramadan
@ 2026-11-25 22:54 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2026-11-25 22:54 UTC (permalink / raw)
  To: Omar Ramadan; +Cc: netdev, David Ahern

On Wed, 25 Nov 2026 19:14:47 +0000
Omar Ramadan <omar@blockcast.net> wrote:

> +	if (tb[IFLA_AMT_LOCAL_IP6]) {
> +		const void *addr = RTA_DATA(tb[IFLA_AMT_LOCAL_IP6]);
> +
> +		print_string(PRINT_ANY, "local", "local %s ",
> +			     format_host(AF_INET6, 16, addr));
> +	}

Should be something like:
		print_string(PRINT_FP, NULL, "%s", "local ");
		print_color_string(PRINT_ANY, "local", "%s", format_host_r(AF_INET6, 16, addr, b1, sizeof(b1));

key point:
	color output
	only for address not the "local "
	prefer format_host_r on new code 

See ip/ip6tunnel.c for examples


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

end of thread, other threads:[~2026-11-25 22:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 19:14 [PATCH iproute2-next] iplink: amt: support an IPv6 outer transport Omar Ramadan
2026-11-25 22:54 ` Stephen Hemminger

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