From: Omar Ramadan <omar@blockcast.net>
To: netdev@vger.kernel.org
Cc: David Ahern <dsahern@kernel.org>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2-next] iplink: amt: support an IPv6 outer transport
Date: Wed, 25 Nov 2026 19:14:47 +0000 [thread overview]
Message-ID: <20261125170100.3054010-iproute2-omar@blockcast.net> (raw)
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)
next reply other threads:[~2026-11-25 19:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 19:14 Omar Ramadan [this message]
2026-11-25 22:54 ` [PATCH iproute2-next] iplink: amt: support an IPv6 outer transport Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125170100.3054010-iproute2-omar@blockcast.net \
--to=omar@blockcast.net \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox