From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796185925; b=nzhnNsxqMZpCR7v7ZEWv8xKUSkT8wbbFgJvz20Wdo8btTkXiRdYOIGd6r9yVM/MVIHk0 Uyqu5PNafy9rOF9T1ztJ+pNl7cYx8lnv0S/Qc+etekjpHkHhpNRQg3CJSKF37V05Tqhvj brDH+crNPsfGcB37R/Poa+DrNWzAYSEJmxDLQ8kDNuMSXlikmwKd2059uZwYHPc61WJDR F+AC+9s+1dh2/JqOqRdm7jw84O6OBnxr0M/T3yuvIBXTBpQjIZOaDBj6xKiAe/ZoDSI8m SRS8iIv/pevkGtx5F0quBVCgu/kf/J3kJdLEpNYTdJvEhy1E7XRlX5E4G37fIasneyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796185925; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=L/3huCz5WlK3O0K4pmtEkJXyDPSUOT7DV5Pd8O8fS/k=; b=uK5SSm4QnYG2tL6nDkO2GqE9n46x+nMCgwr8smqSLZN59OBC8qprtxdb9MsN3YPxcaTW osXZe1qc5T+/+RifG/0C57T6bk79hoOnoTN/Z3w/SzAoHqcu/6c58rGoZe+oZbWZCPzad O6fk+RxV5EPq4U/TAZlaFlrNTDsfk9qg+ZKqh3mZqCtgfiZ6YFuc+WnHNQ8YT+9z8WzQ7 aMU89L0ZhNsaz+WGMwSFVhGEOuOwTb5PKiICFXKbrbeRFRJ1XeTpoMv6v7R/s2+F4QMLA ruqOO3i9AgR4CY97H3N56fo4BQjyY11O0O6emVSP9u2fyMbJq3N64o9Krr/rKvErsCA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=blockcast.net; spf=pass smtp.mailfrom=blockcast.net; dkim=pass header.d=blockcast.net header.i=@blockcast.net header.a=rsa-sha256 header.s=google header.b=TYHtEw26; arc=none smtp.remote-ip=74.125.82.172 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37FC5606A32C for ; Wed, 2 Dec 2026 04:32:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 37FC5606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=blockcast.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=blockcast.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=blockcast.net header.i=@blockcast.net header.a=rsa-sha256 header.s=google header.b=TYHtEw26 Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-3282db206d3so388858eec.0 for ; Tue, 01 Dec 2026 20:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockcast.net; s=google; t=1796185924; x=1796790724; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=L/3huCz5WlK3O0K4pmtEkJXyDPSUOT7DV5Pd8O8fS/k=; b=TYHtEw26C9UGubVeGO+Lm6MpzgoSAsh0fycCSMDiY6hEqoIo8JhSr/r8KA03ESFhIK Ula4snxLv1KyHr/yVfPqB6l/A2QohMYnSAPQpEs5erYvp9RtR/GUjGZ7o8yhJOAvooYc tzAnR1aiejpzawnJK9ZBNK9z9MuGOvWfGHfpVOvGaS8tIq5QCdZ7+d4B7z1bKaFueBN5 ZyiSl8FTAm7gVwneGu0ZQCEgs8XcHnoqwY4M3ia565SBWqYveMZeRK49b8b0rshoTgnP LZ8ELVvCF3o/BpL1djmAVtn7DcUzZgC33wCUJmTXypBLTrRh05rdEn5merPx1oPQDljT Qh0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796185924; x=1796790724; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=L/3huCz5WlK3O0K4pmtEkJXyDPSUOT7DV5Pd8O8fS/k=; b=oIrX+ihoxOk/xL/8M6eSzyYcGzUSpwZLlHraKFyXy3uLI9mKDU5x5zMvnlE4kZUil3 W1G6WAEdeGoetP29tGPmwByPtDENshkW5UjYf2JrrH4aC6Ji2Lt51ZKyV4K4aNLRvIca 2Q3kQ6Q/+UNwabG1i409x5sROBvjuVXdmfdUVhbw36QIa3ydkfJUm4YO4VDcUqonLnqb 7R+fyEwksVYcutB5/PHyZaQiuyQhupWvOeAn+1I+16uOPiiHH3rjLEX/+CsrmbQ0j2Cx PTFnCQQEQRMT8y38K1GLzrzHjucr+qy3AjO4/OE/CV0s6zFriY6OTbmtfMJP5k91HEFH 2t8Q== X-Forwarded-Encrypted: i=1; AL+hErEf064qbuARPtMcBFTS2enTMyx0mu28dCtk8oOGPze5k8L09OyD07DK+JKmsmFPmHwMQiPX/nl2vnZHiaA=@vger.kernel.org X-Gm-Message-State: APuU4Z/WKmEptoS42TBeadSiILZ9Cfs4SzIhG1BEaZ9Wp+rm5+GALupQ gZNFN8LYGDomZCRnyliifip1pr2gjQhX88tYmd0rbNgoycVpF9F9nfVv2gwlYIytWw4= X-Gm-Gg: AZFdTZePA8jRbTBNFPbdevJxjOtQ5x+OKY1FueG4dFPQnJ/ThSgrU9fMiKRyPOfRqRM Aimt4Luc79wxvuk0ZC+7nQyHeyofmPgMWLhWvvdEw1L7l/wpQU5dQt+jV8MojkXNCPQZmx5s48d P0+ViEFRJr52MZYC5+/8B/AA6ViDYJ7/1KMNdVx0JI1L5x/jbscKbNBNEEHis7fjolQP00WnStw f7TLTuVWq1n46YqPHGVKFglR5vguirk1k2wDNX6+6/jP2Jiuht4ZPH6J8CmwrOPzsTl9ShJkVwX e1deF6SH2E/uIxeZlI+sIjKaOx22QOkZ4g+hGuJ8PFPQ86VFrdhPct6pGJp4aFHXskoLlUrb6ht 5CSYU4Op7QNs0VINo7hjd2vicSKrvwOrOqut4qrHaR3AmpvuWQNe5MSiDnPG9QeKxqm4nx2rV3a DcI2XXl4+Byfa0dAJysqDmQYPY9gdvVeWbv8teWGD+lpS2FLU8XDgq+3H5iXXfgHiwv3OfzYuro rldgFZjb6x7cIpaNlvEvBsy4WWA4LZ2ct1W2hWg4Ad3ziC2Vwrv4tW1QZmPRJCLRv4H0wrQqDxB BXEoxu149bGQ+R1Wl9DuotBZHQ+7sX8PUDzfqQ6xiI5jpafCybcBK8o7OSTYX+pzoHmCspYrYYG iBoc3VBNbj5A4I+yjb6bhy0QsbKM= X-Received: by 2002:a05:7301:2022:b0:387:307c:faa2 with SMTP id 5a478bee46e88-387307cfd9emr1513756eec.38.1796185924348; Tue, 01 Dec 2026 20:32:04 -0800 (PST) Received: from devbox.ts.blockcast.net ([2602:f74d:1::32]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386d605c894sm54632028eec.2.2026.12.01.20.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 20:32:03 -0800 (PST) From: Omar Ramadan To: Taehee Yoo , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Simon Horman , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Willem de Bruijn , David Ahern , Ido Schimmel Subject: [PATCH net-next v6 01/12] amt: create an AF_INET6 encapsulation socket for an IPv6 outer address Date: Wed, 2 Dec 2026 04:31:49 +0000 Message-ID: <20261202043200.286260-2-omar@blockcast.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261202043200.286260-1-omar@blockcast.net> References: <20261202043200.286260-1-omar@blockcast.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The amt device binds one AF_INET UDP socket, so a relay and its gateways can only talk AMT over IPv4. RFC 7450 allows either: the Relay Advertisement carries an IPv4 or an IPv6 relay address (s5.1.2.5), and a relay must answer a Discovery received over IPv6 with the IPv6 form (s5.3.3.2). Add the outer IPv6 local address to struct amt_dev, and amt_v6(), which reports the outer family from it. For an IPv6 device amt_create_sock() binds an AF_INET6 socket that is V6ONLY, so that it does not claim the IPv4 wildcard port, and that sends and verifies the UDP checksum (RFC 8200 s8.1). The socket is also bound to IFLA_AMT_LINK. An IPv6 route lookup with a source address treats the output interface only as a preference, so without the binding the outer traffic could leave through another link, and two gateways with the same link-local address on different links would share a tunnel. ICMPv6 errors go to amt_err_lookup(), which relies on amt_parse_type() pulling the AMT header behind the transport header, as "amt: pull the AMT header behind the transport header in amt_parse_type()" in net does. Nothing sets local_ipv6 yet, so there is no functional change. Assisted-by: LLM Signed-off-by: Omar Ramadan --- drivers/net/amt.c | 34 ++++++++++++++++++++++++++++------ include/net/amt.h | 2 ++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index b145ed3ca..2f1b9cd04 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -90,6 +90,12 @@ static struct in6_addr mld2_all_node = MLD2_ALL_NODE_INIT; static struct mld2_grec mldv2_zero_grec; #endif +/* An IPv6 local address selects an IPv6 outer transport. */ +static bool amt_v6(const struct amt_dev *amt) +{ + return IS_ENABLED(CONFIG_IPV6) && !ipv6_addr_any(&amt->local_ipv6); +} + static void __amt_source_gc_work(void) { struct amt_source_node *snode; @@ -3310,19 +3316,35 @@ drop: return 0; } -static struct sock *amt_create_sock(struct net *net, __be16 port) +static struct sock *amt_create_sock(const struct amt_dev *amt) { struct udp_port_cfg udp_conf; struct socket *sock; int err; memset(&udp_conf, 0, sizeof(udp_conf)); - udp_conf.family = AF_INET; - udp_conf.local_ip.s_addr = htonl(INADDR_ANY); + if (amt_v6(amt)) { + /* Bound to :: and to the underlying link: that makes route + * lookups strict about the output interface and receives from + * that link only, where a link-local peer is unique. V6ONLY + * leaves the IPv4 wildcard port to an IPv4 amt device. The UDP + * checksum is always sent (RFC 8200 s8.1); a gateway also + * accepts a zero one on Multicast Data (RFC 7450 s5.2.3.3), and + * amt_rcv() drops it on other messages. + */ + udp_conf.family = AF_INET6; + udp_conf.bind_ifindex = amt->stream_dev->ifindex; + udp_conf.use_udp6_tx_checksums = true; + udp_conf.use_udp6_rx_checksums = true; + udp_conf.ipv6_v6only = true; + } else { + udp_conf.family = AF_INET; + udp_conf.local_ip.s_addr = htonl(INADDR_ANY); + } - udp_conf.local_udp_port = port; + udp_conf.local_udp_port = amt->relay_port; - err = udp_sock_create(net, &udp_conf, &sock); + err = udp_sock_create(amt->net, &udp_conf, &sock); if (err < 0) return ERR_PTR(err); @@ -3334,7 +3356,7 @@ static int amt_socket_create(struct amt_dev *amt) struct udp_tunnel_sock_cfg tunnel_cfg; struct sock *sk; - sk = amt_create_sock(amt->net, amt->relay_port); + sk = amt_create_sock(amt); if (IS_ERR(sk)) return PTR_ERR(sk); diff --git a/include/net/amt.h b/include/net/amt.h index 9ba097127..ca35782f8 100644 --- a/include/net/amt.h +++ b/include/net/amt.h @@ -361,6 +361,8 @@ struct amt_dev { __be16 gw_port; /* Outer local ip */ __be32 local_ip; + /* Outer local IPv6 address, :: unless the outer transport is IPv6 */ + struct in6_addr local_ipv6; /* Outer remote ip */ __be32 remote_ip; /* Outer discovery ip */