Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795924021; b=kuc/TdRJ2ztd7+h8gbl5vdIwbBAHwkEO01eePiMUUgkVz+/Anzo06nzh5HxMKNOXvRD5 v76HRfRB7QzSR1bUwTxC7ci/qd03+QR9jHuCAYdFUcy/MZ1dcTv/FT4zimJaZF9i1aCRw EQzN225fat6zD1TLZ99p+N7vPWIDBTx/QU2eHKsUfqE7uKa13hMRRFWD8ENyZuGx/7Jza 9wKOikyqFoe6nKNcvoRLouxRP4iS4a0U03TgzsU4jS5TQ01Dv0Lgqve4AC+xyO9dyqEMi ANmxHW9wEOd4+F+uppe+qxuXD6akaKAewo62b4QCCs7TMRPmXpgwBA4kKEmhb/tGBgQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795924021; 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=rN4zzwZ+VDU4LekRohAVCdx1vs6Zvs0rfZj2ujk21Lo=; b=HvHtAmJYsb2KkVNmWmU1v0cu3AwPNxXZ1Dzt3Lw8Oc/u8d2h6suWSSxjrXtpZHcs/jrm lIMjXSsmKTUof16TiBm0UCTVBZwzBncVgpoXeESr30dM+DQanbEwF/5oAg+QkV7UcXF/Z d9Il0zsCC+sy8BHsjvdzk9RS2/3QCsE/X44f+iLFpKyab5dIvGjCU4SDnPcSCt5cVfaZD Lcdt8yi9U4I3XDKwsB7Cw16lrfKbi0/tPO3zVIvSDBgs3VMb8JgoVvnkz+8mUpxqSPTDJ 3cbkdpOVfBeawLpsnO6y6cXs8+vLKp1nZWXj7iL3E+IDEfm4weDONDTI5Y2QZAA7tBg== 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=KVUcPcJs; arc=none smtp.remote-ip=74.125.82.179 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (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 45E65606A6A2 for ; Sun, 29 Nov 2026 03:47:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 45E65606A6A2 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=KVUcPcJs Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-380c28f9e35so10233778eec.1 for ; Sat, 28 Nov 2026 19:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockcast.net; s=google; t=1795924020; x=1796528820; 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=rN4zzwZ+VDU4LekRohAVCdx1vs6Zvs0rfZj2ujk21Lo=; b=KVUcPcJsRQgKmneE+XaA09uC8dkDaHv837e4dVgEKpe3tmpjHg3EcFWPRVjv4MkvJu vO0THCQXsL7NlpWusBe+Dtq+FIBhU0H4/TcCWsMbealY1pMcUHqiI6VV2sS7vQHCiJlN TPVrfndwMXvAFUuKsTMc5tT8bm259KOlD7mG7BLUoecLNK6g0Zo9G3PaS5o0vSC1cYcZ YT386vCpi4Uic0aAJC+h7m0NwHbA3qY7ZPmfjC/4XKYNCl7hURbTZzSYgGuUPRCkvkqq nohSea9j6zwn8hUJDOs6iluiyyybvZUDF6NsGLPRpHLiGmcs0+bBGbhHN5UuApkp+A1Y 7VmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795924020; x=1796528820; 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=rN4zzwZ+VDU4LekRohAVCdx1vs6Zvs0rfZj2ujk21Lo=; b=HRCTnhpnBmG6OJPO+s5MEsn5otbukDJGCtawZZXioO6ajS77RZ6vnc6bjzdmsVZqcM jTHPcPmxU6Z9xGaIjM/pOwKweJYchhfV0gsxcAtjMZf0RSg5qW8XfXhP24AByHZRFkA1 FMnCUwRvde90Dr6ZQg5XhmxBp8e7wKj0Dt3OPeJu+iUkStJB0v8EjuGiOmZeKVOWzQha kmH43wGlLML9ef9d2SWyfc0bYTTWrptyDdQpC5w36PH8//rHYhJKmjA8KkPjDAVXEkXk QNYq/CoSmMM1Htl7aAFmyBwi9D3vKPuL03jQ3WyP+/VZv221TQmf6sirCJKWlwxgSeUY uGCw== X-Forwarded-Encrypted: i=1; AL+hErFwizSE8r0yHaO7ChAKPrOU/sNQ2W+oOq8TNbhz60iav9bMLzUEY5GQIqTfkYBua7x4VZhrN8+rwZRHEKADmNs=@vger.kernel.org X-Gm-Message-State: APuU4Z8G/35ySIySmu7ZOamiDm1xkYApbOHrmpAwufaMe/NEpmEEl4fq 4Qx2Pw6KCy9kkoaYBeJk7IYl0n8Sf7OxC7x22Wq/1mvnLKPLzjrLOB6LPQf3hiJ7BhQ= X-Gm-Gg: AZFdTZdYRKND5O8b8sqkNIGa4t1wuxRo9DP6ox1qyaGi3/gp23U0laOS/nhukAbxb5o O/+z9LiO1mn1w90yCc2gfseoI4bVds4sTDYTUM/TJI4cXNYV9gA5f1Wnq+OpM+D23+OTnntuPqw YUqNqUesDFgFPi4yeYWw6+c1j3jPRRgAnq6YU/AkGPVf3vicGwgEAMqPlJb9RjTFlQq/yUNELOr LyTTv4OvtFcHpVyenko8w5Dq4PcsiGTJk7Ebm/R0hLXmZGXn+85COxDXBMdzWVfIAMtiqXu4bAw qjMF9RN6dl5eqEE8uZ6rL2gY+PvbSzVpOKL6F0U2PWvblmpMosc81GMavyQknlv3c/V7ArqXqsa dfTPu9ZQUkpmc/eol3IGT0u5iAHurOm1QOFGkIW5B+/pbUngGA7GxLYHN8KbvHayMU9QeAAaKPM xGZ9+IHhLV3Ya1pNrbtU0J7BBpKdLM+8n3EqkaKanMbpdELHfO1S1G7XR5iYAQCUrDgvdcPwR/B s3XaBQoN2GIHlnTixAshHcebK31a9dqBeAC9dk+TwxhdrO6oBoeXl/5YM21V0qfD4Y90mboAgbt iMkjNSCZX3vI41KH93NOv6p5Ur10dBBULYpKZDKVEl2clNW3EkG0J+VBWnqAt+Zm5q+XkVvU+Tk 9oqbHG1rzj6azqulYKlT4jyBCtFc= X-Received: by 2002:a05:7022:1703:b0:1b5:64c0:d2be with SMTP id a92af1059eb24-1b564c0d31fmr23893261c88.19.1795924019918; Sat, 28 Nov 2026 19:46:59 -0800 (PST) Received: from devbox.ts.blockcast.net ([2602:f74d:1::32]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b56ef9fd16sm61119077c88.4.2026.11.28.19.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 19:46:59 -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 Subject: [PATCH net-next v4 03/12] amt: key relay tunnels on a union amt_addr endpoint Date: Sun, 29 Nov 2026 03:46:43 +0000 Message-ID: <20261129034652.1853485-4-omar@blockcast.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261129034652.1853485-1-omar@blockcast.net> References: <20261129034652.1853485-1-omar@blockcast.net> X-Mailing-List: linux-kselftest@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 A relay keeps one struct amt_tunnel_list per gateway endpoint and finds it by the gateway's IPv4 address, stored as __be32 ip4 and taken from ip_hdr(skb)->saddr, together with its UDP source port. On an IPv6 outer transport that would read four bytes from the middle of the IPv6 source address, and the field cannot hold the gateway's address anyway. Store the endpoint as a union amt_addr, which group and source nodes already use, and move the union above struct amt_tunnel_list so the tunnel can embed it. Its ip6 member is no longer under CONFIG_IPV6, so code that only copies, compares or prints an endpoint compiles without an #if and relies on amt_v6() being false. A kernel without IPv6 pays 12 bytes per group and source node, which it already zeroes. The tunnel needs no family of its own: the relay's socket is bound to one family, so every tunnel has the device's family, which amt_v6() reports. amt_outer_saddr() copies the outer source address of a received message by value into a zeroed union amt_addr. amt_update_handler() takes that snapshot before pskb_may_pull() and iptunnel_pull_header() can reallocate the header; amt_request_handler() takes it after its only pskb_may_pull() and pulls nothing more. amt_update_handler() passes it to amt_update_tunnel(), which hands it on to amt_tunnel_get_or_create() and amt_tunnel_lookup(); amt_request_handler() walks the tunnel list itself, with the same matching, and uses the snapshot for the MAC and the Query. Tunnels are matched on their endpoint with the existing amt_addr_equal(); the union is zero-padded for IPv4, so one memcmp() serves both families. The per-source tunnel cap counts differently. An IPv6 host normally owns a whole /64, so a count per address would let it open the cap's worth of tunnels from each of its addresses and keep the table full. amt_request_handler() and amt_tunnel_get_or_create() count the tunnels of one source with amt_same_source(), which compares the whole address for IPv4 and the /64 for IPv6. Gateways that share a /64 share the cap; each still has its own tunnel, found by its full endpoint. The kernel-doc and comments of the cap say source, not address. The Membership Update MAC becomes amt_relay_mac(), one siphash() over the packed {address, port, nonce} tuple instead of siphash_3u32() over the IPv4 address. The Request and Update handlers both compute it with the helper. Only the relay computes and checks the MAC; the gateway echoes it verbatim, so the different IPv4 value is not visible on the wire. The IPv4 senders and the relay status debug message are converted to tunnel->addr.ip4, and the debug message prints an IPv6 endpoint with %pI6c. amt_v6() is still false for every device, so there is no functional change. Assisted-by: LLM Signed-off-by: Omar Ramadan --- drivers/net/amt.c | 120 ++++++++++++++++++++++++++++++++-------------- include/net/amt.h | 22 +++++---- 2 files changed, 98 insertions(+), 44 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 52ccaca08..386dec11a 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -98,6 +98,32 @@ static bool amt_v6(const struct amt_dev *amt) return IS_ENABLED(CONFIG_IPV6) && !ipv6_addr_any(&amt->local_ipv6); } +/* Snapshot the outer source address of a received AMT message. */ +static void amt_outer_saddr(const struct amt_dev *amt, + const struct sk_buff *skb, union amt_addr *addr) +{ + memset(addr, 0, sizeof(*addr)); + if (amt_v6(amt)) + addr->ip6 = ipv6_hdr(skb)->saddr; + else + addr->ip4 = ip_hdr(skb)->saddr; +} + +/* The Membership Update MAC for a gateway endpoint. The gateway only echoes + * it, so one siphash() over the zero-padded endpoint serves both families. + */ +static u64 amt_relay_mac(const union amt_addr *addr, __be16 port, __be32 nonce, + const siphash_key_t *key) +{ + struct { + union amt_addr addr; + __be16 port; + __be32 nonce; + } __packed in = { .addr = *addr, .port = port, .nonce = nonce }; + + return siphash(&in, sizeof(in), key) >> 16; +} + static void __amt_source_gc_work(void) { struct amt_source_node *snode; @@ -189,6 +215,23 @@ static bool amt_addr_equal(union amt_addr *a, union amt_addr *b) return !memcmp(a, b, sizeof(union amt_addr)); } +/* Bytes of an IPv6 source that make up its /64. */ +#define AMT_SRC_PREFIX6_LEN 8 + +/* Whether @a and @b are one source for the per-source tunnel cap. An IPv6 + * host normally owns a whole /64, so counting per address would let it + * reach the cap from each of its addresses and fill the table; the cap + * therefore counts per /64. For IPv4 a source is an address. Tunnels + * themselves are still found by their full endpoint. + */ +static bool amt_same_source(const struct amt_dev *amt, + const union amt_addr *a, const union amt_addr *b) +{ + if (amt_v6(amt)) + return !memcmp(&a->ip6, &b->ip6, AMT_SRC_PREFIX6_LEN); + return a->ip4 == b->ip4; +} + static u32 amt_source_hash(struct amt_tunnel_list *tunnel, union amt_addr *src) { u32 hash = jhash(src, sizeof(*src), tunnel->amt->hash_seed); @@ -701,10 +744,16 @@ static void __amt_update_relay_status(struct amt_tunnel_list *tunnel, { if (validate && tunnel->status >= status) return; - netdev_dbg(tunnel->amt->dev, - "Update Tunnel(IP = %pI4, PORT = %u) status %s -> %s", - &tunnel->ip4, ntohs(tunnel->source_port), - status_str[tunnel->status], status_str[status]); + if (amt_v6(tunnel->amt)) + netdev_dbg(tunnel->amt->dev, + "Update Tunnel(IP = %pI6c, PORT = %u) status %s -> %s", + &tunnel->addr.ip6, ntohs(tunnel->source_port), + status_str[tunnel->status], status_str[status]); + else + netdev_dbg(tunnel->amt->dev, + "Update Tunnel(IP = %pI4, PORT = %u) status %s -> %s", + &tunnel->addr.ip4, ntohs(tunnel->source_port), + status_str[tunnel->status], status_str[status]); tunnel->status = status; } @@ -1292,12 +1341,12 @@ static void amt_send_multicast_data(struct amt_dev *amt, memset(&fl4, 0, sizeof(struct flowi4)); fl4.flowi4_oif = amt->stream_dev->ifindex; - fl4.daddr = tunnel->ip4; + fl4.daddr = tunnel->addr.ip4; fl4.saddr = amt->local_ip; fl4.flowi4_proto = IPPROTO_UDP; rt = ip_route_output_key(amt->net, &fl4); if (IS_ERR(rt)) { - netdev_dbg(amt->dev, "no route to %pI4\n", &tunnel->ip4); + netdev_dbg(amt->dev, "no route to %pI4\n", &tunnel->addr.ip4); kfree_skb(skb); return; } @@ -2728,20 +2777,22 @@ static bool amt_membership_query_handler(struct amt_dev *amt, * race with amt_tunnel_expire() creates the replacement. */ static struct amt_tunnel_list *amt_tunnel_lookup(struct amt_dev *amt, - __be32 saddr, __be16 sport) + union amt_addr *saddr, + __be16 sport) { struct amt_tunnel_list *tunnel; list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) { - if (tunnel->ip4 == saddr && tunnel->source_port == sport && + if (amt_addr_equal(&tunnel->addr, saddr) && + tunnel->source_port == sport && !READ_ONCE(tunnel->dead)) return tunnel; } return NULL; } -/* Most tunnels one source address may hold: an eighth of the table, at - * least one and at most AMT_MAX_TUNNELS_PER_SRC. +/* Most tunnels one source (an IPv4 address or an IPv6 /64) may hold: an + * eighth of the table, at least one and at most AMT_MAX_TUNNELS_PER_SRC. */ static u32 amt_max_tunnels_per_src(const struct amt_dev *amt) { @@ -2756,10 +2807,10 @@ static u32 amt_max_tunnels_per_src(const struct amt_dev *amt) * bounds the number of *verified* gateways rather than the number of * unverified Requests anyone can send. A per-source cap derived from the * table, amt_max_tunnels_per_src(), additionally limits the tunnels one - * verified source address may hold. + * verified source (an IPv4 address or an IPv6 /64) may hold. */ static struct amt_tunnel_list *amt_tunnel_get_or_create(struct amt_dev *amt, - __be32 saddr, + union amt_addr *saddr, __be16 sport) { struct amt_tunnel_list *tunnel; @@ -2776,12 +2827,14 @@ static struct amt_tunnel_list *amt_tunnel_get_or_create(struct amt_dev *amt, * count how many tunnels this source already holds on the same walk. * Skip dead tunnels, as amt_tunnel_lookup() and the Request path do, so * a tunnel being freed neither stands in for its endpoint nor counts - * against its address. + * against its source. */ list_for_each_entry(tunnel, &amt->tunnel_list, list) { - if (tunnel->ip4 != saddr || READ_ONCE(tunnel->dead)) + if (!amt_same_source(amt, &tunnel->addr, saddr) || + READ_ONCE(tunnel->dead)) continue; - if (tunnel->source_port == sport) { + if (amt_addr_equal(&tunnel->addr, saddr) && + tunnel->source_port == sport) { spin_unlock_bh(&amt->lock); return tunnel; } @@ -2808,7 +2861,7 @@ static struct amt_tunnel_list *amt_tunnel_get_or_create(struct amt_dev *amt, } tunnel->source_port = sport; - tunnel->ip4 = saddr; + tunnel->addr = *saddr; tunnel->amt = amt; spin_lock_init(&tunnel->lock); for (i = 0; i < amt->hash_buckets; i++) @@ -2838,7 +2891,7 @@ static struct amt_tunnel_list *amt_tunnel_get_or_create(struct amt_dev *amt, * second amt_tunnel_get_or_create() call, which creates its replacement. */ static bool amt_update_tunnel(struct amt_dev *amt, struct sk_buff *skb, - __be32 saddr, __be16 sport, bool v6) + union amt_addr *saddr, __be16 sport, bool v6) { struct amt_tunnel_list *tunnel; int i; @@ -2878,12 +2931,13 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb) struct ethhdr *eth; struct iphdr *iph; unsigned int seq; + union amt_addr saddr; u64 response_mac; - __be32 saddr; __be32 nonce; __be16 sport; - saddr = ip_hdr(skb)->saddr; + /* Snapshot the outer source before any pull can move the header. */ + amt_outer_saddr(amt, skb, &saddr); hdr_size = sizeof(*amtmu) + sizeof(struct udphdr); if (!pskb_may_pull(skb, hdr_size)) @@ -2910,10 +2964,7 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb) } while (read_seqcount_retry(&amt->key_seq, seq)); for (i = 0; i < ARRAY_SIZE(key); i++) { - u64 mac = siphash_3u32((__force u32)saddr, - (__force u32)sport, - (__force u32)nonce, - &key[i]) >> 16; + u64 mac = amt_relay_mac(&saddr, sport, nonce, &key[i]); if (response_mac == mac) { verified = true; @@ -2947,7 +2998,7 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb) return true; } - if (!amt_update_tunnel(amt, skb, saddr, sport, false)) + if (!amt_update_tunnel(amt, skb, &saddr, sport, false)) return true; skb_push(skb, sizeof(struct ethhdr)); @@ -2966,7 +3017,7 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb) return true; } - if (!amt_update_tunnel(amt, skb, saddr, sport, true)) + if (!amt_update_tunnel(amt, skb, &saddr, sport, true)) return true; skb_push(skb, sizeof(struct ethhdr)); @@ -3165,8 +3216,8 @@ static bool amt_request_handler(struct amt_dev *amt, struct sk_buff *skb) struct amt_header_request *amtrh; struct amt_tunnel_list *tunnel; bool full, have = false; + union amt_addr saddr; struct udphdr *udph; - struct iphdr *iph; siphash_key_t key; u32 per_src = 0; u64 mac; @@ -3174,7 +3225,7 @@ static bool amt_request_handler(struct amt_dev *amt, struct sk_buff *skb) if (!pskb_may_pull(skb, sizeof(*udph) + sizeof(*amtrh))) return true; - iph = ip_hdr(skb); + amt_outer_saddr(amt, skb, &saddr); udph = udp_hdr(skb); amtrh = (struct amt_header_request *)(udp_hdr(skb) + 1); @@ -3198,10 +3249,12 @@ static bool amt_request_handler(struct amt_dev *amt, struct sk_buff *skb) */ rcu_read_lock(); list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) { - if (tunnel->ip4 != iph->saddr || READ_ONCE(tunnel->dead)) + if (!amt_same_source(amt, &tunnel->addr, &saddr) || + READ_ONCE(tunnel->dead)) continue; per_src++; - if (tunnel->source_port == udph->source) + if (amt_addr_equal(&tunnel->addr, &saddr) && + tunnel->source_port == udph->source) have = true; } rcu_read_unlock(); @@ -3210,15 +3263,12 @@ static bool amt_request_handler(struct amt_dev *amt, struct sk_buff *skb) if (!have && (full || per_src >= amt_max_tunnels_per_src(amt))) return true; - mac = siphash_3u32((__force u32)iph->saddr, - (__force u32)udph->source, - (__force u32)amtrh->nonce, - &key) >> 16; + mac = amt_relay_mac(&saddr, udph->source, amtrh->nonce, &key); if (!amtrh->p) - amt_send_igmp_gq(amt, iph->saddr, udph->source, amtrh->nonce, + amt_send_igmp_gq(amt, saddr.ip4, udph->source, amtrh->nonce, mac); else - amt_send_mld_gq(amt, iph->saddr, udph->source, amtrh->nonce, + amt_send_mld_gq(amt, saddr.ip4, udph->source, amtrh->nonce, mac); return false; diff --git a/include/net/amt.h b/include/net/amt.h index 52d77bc6b..117515f67 100644 --- a/include/net/amt.h +++ b/include/net/amt.h @@ -252,6 +252,14 @@ struct amt_relay_headers { }; } __packed; +/* ip6 is present without CONFIG_IPV6 too, so that code which only copies + * or compares addresses needs no #if; amt_v6() is then false. + */ +union amt_addr { + __be32 ip4; + struct in6_addr ip6; +}; + struct amt_tunnel_list { struct list_head list; /* Protect All resources under an amt_tunne_list */ @@ -273,18 +281,14 @@ struct amt_tunnel_list { */ bool dead; __be16 source_port; - __be32 ip4; + /* Outer source address of the gateway endpoint, in the device's + * outer family (amt_v6()). + */ + union amt_addr addr; struct rcu_head rcu; struct hlist_head groups[]; }; -union amt_addr { - __be32 ip4; -#if IS_ENABLED(CONFIG_IPV6) - struct in6_addr ip6; -#endif -}; - /* RFC 3810 * * When the router is in EXCLUDE mode, the router state is represented @@ -424,7 +428,7 @@ struct amt_dev { #define AMT_SECRET_TIMEOUT 60000 #define IANA_AMT_UDP_PORT 2268 #define AMT_MAX_TUNNELS 128 -/* Upper bound of amt_max_tunnels_per_src(), the per-address tunnel cap */ +/* Upper bound of amt_max_tunnels_per_src(), the per-source tunnel cap */ #define AMT_MAX_TUNNELS_PER_SRC 16 #define AMT_MAX_REQS 128 #define AMT_GW_HLEN (sizeof(struct iphdr) + \