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=1796185938; b=wZNp1S0+PIQMMoOY1SPbI2v2zckiWM54GOz4UTtrqTmC5/tzxKfc8GZbl73kIDfEMU8p g5WmDGaxy/kfmjXz29OKgYhCtJUbXu+o3/Pj3frM+BVBToYr6YEnOY+TpsMLbRsJWm1cI A9tPe3Hub3K8oGDHJ16LpIx0Fn6eVf6j5lDW+VYDoxBzROiK3rFuXQH1UrOZATD5FOIxP PLbKmH+jjGA8aEpdzHwyXrWRqk3yrQMhdFqjasMIGxlZam1FQmLvfAIWZHLfDWIg1IoZw Wv19cPKJ31flX7MQZ0hoPHE6Niht/exuCZh1dD+eVDWoNaRDCrO4IOE9rHDBA9R0xJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796185938; 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=0J7Wt1pyIfCWghH9i+2X47JDf5tGXK0gFp5xUv0cCXA=; b=M0YexXBkUKAbl8a7w+VD4nl/VbTzsrXJQeD+dRarMfdUVrFJlHtdSUN4kr91VDyR0E3I 5AeQWGvv8k3VcGs3CPadRH6g0nQyhGOISAOQd5RNR3jCnnHdXvfvZZhOpepOWiE8DfOOu LD86hTNcpVVUnQvCWwDKXIIYl1OrTBS931iN3PPm3JJVmAzOmhBOunn9qr9Jx+ArRA6nF wM0a5lju3nI95ShfXv91j6xDCcigrlLLKq01ZhIsjoossgwP5vlF+rhAYYqHs+qNg3O2M gM3yfP1cuzRlao+BNqeCSGrjOG1KBQn2LADp2NWf4E4tBcI5a7o8HDTXmn6X/nCU2Pg== 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=pC9DM6Kh; 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 D2B57606A329 for ; Wed, 2 Dec 2026 04:32:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D2B57606A329 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=pC9DM6Kh Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-386c336eab8so10133601eec.0 for ; Tue, 01 Dec 2026 20:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockcast.net; s=google; t=1796185937; x=1796790737; 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=0J7Wt1pyIfCWghH9i+2X47JDf5tGXK0gFp5xUv0cCXA=; b=pC9DM6KhEPYr1Q5n2qJ8C1MDP5CVR05QVMYhGGPmEuwyMrbew9hNfQ3quA1UbnRHsO +Ql+U+hi4WMtpNMM2JM7c0z4gUfV0Q4r8Y+54uPI7h3wDaYQuicV09TRJ/o+VmolK/NP vLs5MaKNfSAS8/g7MoSoqGSqioSQKn0tgwe0ya5v8ukMtstGdEQWgX+NcDTfM/9VnKUW zOVyUxYf0mIl33M296BVFlalEWQ3Mkk0W7g0H3oRN+wEgW+5anv94Mjma7zlKcyakyFi ce4f2kn15RQ/1DMqmNW1Xe3D9imIYiEXjolardACs/xbRE4hffw5iipZZbsDfVs9YE4+ UL2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796185937; x=1796790737; 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=0J7Wt1pyIfCWghH9i+2X47JDf5tGXK0gFp5xUv0cCXA=; b=lza/+8NG1Ki/xqzZI3JIcdhtnpIKy5jg8RaqVsbxZ+1d+xgekcQ+zjCrD4qIUY7XqB mz2VDzqjyNZlyDfhraWvgl38byzJK5L7Ccy8tGRKCWCPLEMHNTBrm812SgWvHtRt41Ww jybAp139fISw5Hp5SvAT4dV6b8GLWfLQ1ffRY5LHlC2PYRK8zBX5lD29UzXgbWf5PXL8 7oh0f9ZVPta5uWpOfRmOFVlPlauDrM2MYff5LXxpuDyLWQ4Yhx7pTG0YDAahwKbH1zwI qV8ljbUflQzdYXnyKpFIXRFe0LyqisspDR3EJ0hfbLeOn1wqIiAvp52KBtNBRHnMzHQT Mxqg== X-Forwarded-Encrypted: i=1; AL+hErG+TJ2uyOpyHK+zoV5t81S2/UC6C6/R5MGX7nOD3iLYfrqikHIPMpZeh3uKo8Jt41yGehvwMhs=@vger.kernel.org X-Gm-Message-State: APuU4Z8TieaDdQLxp0nlR5GxBuq27yJoaB2dUg1cTWfFbPk8dgCTUkS2 UihvsrSsY6GAHTJjdUwI6J8F2jzIKHU2PDL+rny2FsxoCa++4BVIkxFyOeYZrL+tuHc= X-Gm-Gg: AZFdTZcZlKYnC+7kkBsV6JFCZwDvIrhIfr3WMInGvjibE7bAQtR3CxPkImWAhdMtApI uLb7R+UcgWAFjps2UCGE5W1o+vJMYRmKqFNRue8IAUSCBKf53+BNq9wN00s4WmZGWS3dzr3CPto VEsPiIGmLrO9jBsUc/F9x1cTTtnrIDOTg5Yy//sW9waf8hhC0k5tZ71zuQUiqH+AvptUI9xkeWl E0vnSr+wTYNHsjaGd0sPs5xkkn2VLRYyXVFPXqoB5e/pPNVFqSEFiwNJmKk52zYXA3iS6OGfbEK 647/e0BKVgP4vO6W0mpntUSSsOLxfkxcks29g0pmsgTL/nqW8HK5wNsmfEE/o4J0RAfTtWJ+RKb +n09rQshW8gzOwlKGs6U+9P4PQcwkgzlCNKKp5OhOTBLL8SFLO5U/St0/cwNN5Eqq9U6F0qoH7g 82bl+BSH8ocxZST2L6ezK2iQxGeoQZhBFTB2ePC0RKhQbVh/wQoYo/sEisvU10sLfNi7gYrNqn6 yUPmVgBiSRiMlloeB4QoZe9bZ6UPsUUd3/pGdJ0gsRI7aALo7lnP4SlJt3nnL1Vwi/4tc9rnmBd z/Cp2SWOA5nKq0bwJpdalt+y5o/sprkkMmyQkxo/Ucdtz76ef7dSETvl5sZ65OlkZe5mL8hpe35 e7uFjNJ6gJmlADpwEZbztLMxXcMw= X-Received: by 2002:a05:7301:dd8e:b0:386:6c8e:b4f7 with SMTP id 5a478bee46e88-3866c8ebd4bmr37303107eec.12.1796185936807; Tue, 01 Dec 2026 20:32:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 20:32:16 -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 08/12] amt: receive the AMT gateway control plane over IPv6 Date: Wed, 2 Dec 2026 04:31:56 +0000 Message-ID: <20261202043200.286260-9-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: netdev@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 previous patch added the IPv6 senders of a gateway, but amt_rcv() could not take the replies: it checks the outer source with ip_hdr(skb)->saddr, which on an IPv6 header is four bytes from the middle of the address, and amt_advertisement_handler() parses only the IPv4 form. amt_rcv() takes the outer source by value with amt_outer_saddr() before amt_parse_type() pulls, and checks it with amt_from_relay(): the discovery address for an Advertisement, the learned relay address otherwise, in the device's family, and nothing matches while the relay is not known. amt_membership_query_handler() repeats the check for a queued Query. The IPv4 half is "amt: reject a gateway Query or Data from 0.0.0.0" in net. IPv6 input delivers a packet from ::, which would match a cleared relay address and, with a zero nonce, inject a Query or have a relay create a tunnel, so amt_rcv() drops it in either mode. amt_advertisement_handler() pulls the 24-byte form on an IPv6 gateway and refuses an unspecified, loopback, multicast or IPv4-mapped relay address; the V6ONLY socket could not reach the last. An IPv6 gateway takes only the exact 24-byte form, which is this driver's policy: s5.1.2.5 only has a gateway tell the forms apart by length. An IPv4 gateway keeps its minimum-length check. The learned relay address is written from the event worker (the Advertisement handler, and amt_clear_remote() when called from amt_event_send_request()) and in process context (amt_dev_open() and amt_dev_stop() call amt_clear_remote()), and read in softirq and, from the next patch on, by amt_fill_info(), which no longer relies on RTNL. A struct in6_addr is not copied in one access, so a reader could see half of an old and half of a new address. It is published with amt_set_remote_ipv6() under a seqlock, remote_ipv6_lock, and read with amt_get_remote_ipv6(), one snapshot per packet, without a lock. amt_clear_remote() forgets the relay in both families in the three places that reset it, so a gateway taken down and up neither accepts traffic from its previous relay nor, once amt_fill_info() reports it, keeps reporting it. IPv4 input refuses a source that is one of the host's own addresses as a martian when it comes from the wire; IPv6 input delivers it, an anycast address too. A relay answers a Discovery and a Request to their source, so a forged one from the relay's own address would make it send to itself over lo, where a rule such as "-i lo -j ACCEPT" lets it in. A relay's amt_rcv() therefore drops such a packet. amt_saddr_is_local() looks a unicast address up with ipv6_chk_addr() in the L3 domain of the stream device, so an address on a slave of its VRF is found, a link-local one only on the stream device itself and a tentative one not, and an anycast address with ipv6_chk_acast_addr() in the whole namespace. That function is not exported, so this patch exports it from net/ipv6/anycast.c, as ipv6_chk_addr() is. A packet that arrives over lo comes from the host itself and is not dropped, as for IPv4, so a gateway on the relay's host still works. In a VRF every packet arrives on the VRF device, so that exception cannot apply there. A gateway must accept a zero UDP checksum on Multicast Data (RFC 7450 s5.2.3.3; a relay may use the RFC 6936 exception to RFC 8200 s8.1), so an IPv6 gateway's socket does, and still verifies a non-zero one. amt_rcv() drops a zero checksum on every other message (RFC 6936 s5). A relay's socket keeps requiring it. The Query and Multicast Data handlers dispatch on the inner family and need no change. amt_v6() is still false for every device, because nothing sets local_ipv6 until the netlink attributes of the next patch, so none of this runs yet and the receive path of an IPv4 gateway is unchanged. Assisted-by: LLM Signed-off-by: Omar Ramadan --- drivers/net/amt.c | 161 ++++++++++++++++++++++++++++++++++++++------- include/net/amt.h | 2 + net/ipv6/anycast.c | 1 + 3 files changed, 140 insertions(+), 24 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 40481b0f9..c2126c7ba 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -767,6 +767,10 @@ static struct dst_entry *amt_route6(struct amt_dev *amt, struct sock *sk, { struct flowi6 fl6; + /* A gateway that just forgot its relay publishes ::. */ + if (ipv6_addr_any(daddr)) + return ERR_PTR(-EINVAL); + memset(&fl6, 0, sizeof(fl6)); fl6.flowi6_oif = amt->stream_dev->ifindex; fl6.flowi6_proto = IPPROTO_UDP; @@ -829,6 +833,69 @@ out: return err; } +/* Written from the event worker and process context, read in softirq. A + * struct in6_addr is not stored in one access, so it goes under a seqlock + * and each consumer takes one snapshot per packet. + */ +static void amt_set_remote_ipv6(struct amt_dev *amt, + const struct in6_addr *addr) +{ + write_seqlock_bh(&amt->remote_ipv6_lock); + amt->remote_ipv6 = *addr; + write_sequnlock_bh(&amt->remote_ipv6_lock); +} + +static void amt_get_remote_ipv6(const struct amt_dev *amt, + struct in6_addr *addr) +{ + unsigned int seq; + + do { + seq = read_seqbegin(&amt->remote_ipv6_lock); + *addr = amt->remote_ipv6; + } while (read_seqretry(&amt->remote_ipv6_lock, seq)); +} + +static void amt_clear_remote(struct amt_dev *amt) +{ + WRITE_ONCE(amt->remote_ip, 0); + amt_set_remote_ipv6(amt, &in6addr_any); +} + +/* Whether a gateway's message came from its relay: the discovery address + * for an Advertisement, the learned relay address otherwise. An unknown + * relay (::) matches nothing. + */ +static bool amt_from_relay(const struct amt_dev *amt, + const union amt_addr *saddr, bool discovery) +{ + __be32 relay4; + + if (amt_v6(amt)) { + struct in6_addr relay; + + if (discovery) + relay = amt->discovery_ipv6; + else + amt_get_remote_ipv6(amt, &relay); + return !ipv6_addr_any(&relay) && + ipv6_addr_equal(&saddr->ip6, &relay); + } + relay4 = discovery ? amt->discovery_ip : READ_ONCE(amt->remote_ip); + return relay4 && saddr->ip4 == relay4; +} + +/* A unicast address is looked up in the stream device's L3 domain (a + * link-local one only on the device itself), an anycast address in the + * whole namespace. A gateway has no reason to send from either. + */ +static bool amt_saddr_is_local(const struct amt_dev *amt, + const struct in6_addr *a) +{ + return ipv6_chk_addr(amt->net, a, amt->stream_dev, 0) || + ipv6_chk_acast_addr(amt->net, NULL, a); +} + static void amt_send_discovery_v6(struct amt_dev *amt) { struct amt_header_discovery amtd = { @@ -850,9 +917,11 @@ static void amt_send_request_v6(struct amt_dev *amt, bool v6) .p = v6, .nonce = amt->nonce, }; + struct in6_addr remote6; - amt_send_ctrl_v6(amt, &amt->local_ipv6, &amt->remote_ipv6, - amt->gw_port, amt->relay_port, &amtrh, sizeof(amtrh)); + amt_get_remote_ipv6(amt, &remote6); + amt_send_ctrl_v6(amt, &amt->local_ipv6, &remote6, amt->gw_port, + amt->relay_port, &amtrh, sizeof(amtrh)); } static void amt_send_discovery(struct amt_dev *amt) @@ -1248,7 +1317,7 @@ static void amt_event_send_request(struct amt_dev *amt) amt->qi = AMT_INIT_REQ_TIMEOUT; WRITE_ONCE(amt->ready4, false); WRITE_ONCE(amt->ready6, false); - WRITE_ONCE(amt->remote_ip, 0); + amt_clear_remote(amt); amt_update_gw_status(amt, AMT_STATUS_INIT, false); amt->req_cnt = 0; amt->nonce = 0; @@ -1398,7 +1467,7 @@ static bool amt_send_membership_update(struct amt_dev *amt, else skb_set_inner_protocol(skb, htons(ETH_P_IPV6)); if (amt_v6(amt)) - remote.ip6 = amt->remote_ipv6; + amt_get_remote_ipv6(amt, &remote.ip6); else remote.ip4 = remote_ip; if (amt_udp_xmit(amt, sk, skb, &remote, amt->gw_port, @@ -2664,27 +2733,45 @@ static bool amt_advertisement_handler(struct amt_dev *amt, struct sk_buff *skb) struct amt_header_advertisement *amta; int hdr_size; - hdr_size = sizeof(*amta) + sizeof(struct udphdr); + hdr_size = sizeof(struct udphdr) + + (amt_v6(amt) ? sizeof(struct amt_header_advertisement_v6) : + sizeof(*amta)); if (!pskb_may_pull(skb, hdr_size)) return true; - amta = (struct amt_header_advertisement *)(udp_hdr(skb) + 1); - if (!amta->ip4) + /* The forms differ only in length. An IPv6 gateway accepts only its + * own: driver policy, not the RFC's. + */ + if (amt_v6(amt) && ntohs(udp_hdr(skb)->len) != hdr_size) return true; + amta = (struct amt_header_advertisement *)(udp_hdr(skb) + 1); if (amta->reserved || amta->version) return true; - if (ipv4_is_loopback(amta->ip4) || ipv4_is_multicast(amta->ip4) || - ipv4_is_zeronet(amta->ip4)) - return true; - if (amt->status != AMT_STATUS_SENT_DISCOVERY || amt->nonce != amta->nonce) return true; - WRITE_ONCE(amt->remote_ip, amta->ip4); - netdev_dbg(amt->dev, "advertised remote ip = %pI4\n", &amta->ip4); + if (amt_v6(amt)) { + const struct in6_addr *ip6; + + ip6 = &((struct amt_header_advertisement_v6 *)amta)->ip6; + if (ipv6_addr_any(ip6) || ipv6_addr_loopback(ip6) || + ipv6_addr_is_multicast(ip6) || ipv6_addr_v4mapped(ip6)) + return true; + + amt_set_remote_ipv6(amt, ip6); + netdev_dbg(amt->dev, "advertised remote ipv6 = %pI6c\n", ip6); + } else { + if (!amta->ip4 || ipv4_is_loopback(amta->ip4) || + ipv4_is_multicast(amta->ip4) || ipv4_is_zeronet(amta->ip4)) + return true; + + WRITE_ONCE(amt->remote_ip, amta->ip4); + netdev_dbg(amt->dev, "advertised remote ip = %pI4\n", + &amta->ip4); + } mod_delayed_work(amt_wq, &amt->req_wq, 0); amt_update_gw_status(amt, AMT_STATUS_RECEIVED_ADVERTISEMENT, true); @@ -2769,6 +2856,7 @@ static bool amt_membership_query_handler(struct amt_dev *amt, struct ethhdr *eth, *oeth; struct igmpv3_query *ihv3; u8 h_source[ETH_ALEN]; + union amt_addr saddr; struct iphdr *iph; int hdr_size, len; u64 response_mac; @@ -2782,7 +2870,8 @@ static bool amt_membership_query_handler(struct amt_dev *amt, return true; /* A deferred query may outlive a relay address change. */ - if (ip_hdr(skb)->saddr != READ_ONCE(amt->remote_ip)) + amt_outer_saddr(amt, skb, &saddr); + if (!amt_from_relay(amt, &saddr, false)) return true; if (amtmq->nonce != amt->nonce) @@ -3404,9 +3493,8 @@ drop: static int amt_rcv(struct sock *sk, struct sk_buff *skb) { + union amt_addr saddr; struct amt_dev *amt; - __be32 remote_ip; - __be32 saddr; int type; bool err; @@ -3417,10 +3505,28 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) kfree_skb(skb); goto out; } - remote_ip = READ_ONCE(amt->remote_ip); skb->dev = amt->dev; - saddr = ip_hdr(skb)->saddr; + /* Snapshot the outer source before amt_parse_type() pulls. */ + amt_outer_saddr(amt, skb, &saddr); + /* IPv6 input delivers a packet from ::. */ + if (amt_v6(amt) && ipv6_addr_any(&saddr.ip6)) { + err = true; + goto drop; + } + /* IPv4 input refuses a source that is one of this host's own addresses + * as a martian, IPv6 input does not. Answering a forged one would send + * to ourselves over lo. A packet over lo is from this host, as for + * IPv4, so a gateway on the relay's host still works; in a VRF the + * incoming interface is the VRF device, so that exception cannot apply + * there. + */ + if (amt_v6(amt) && amt->mode == AMT_MODE_RELAY && + skb->skb_iif != amt->net->loopback_dev->ifindex && + amt_saddr_is_local(amt, &saddr.ip6)) { + err = true; + goto drop; + } type = amt_parse_type(skb); if (type == -1) { err = true; @@ -3428,9 +3534,15 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) } if (amt->mode == AMT_MODE_GATEWAY) { + /* RFC 6936 s5: a zero checksum only on Multicast Data. */ + if (amt_v6(amt) && !udp_hdr(skb)->check && + type != AMT_MSG_MULTICAST_DATA) { + err = true; + goto drop; + } switch (type) { case AMT_MSG_ADVERTISEMENT: - if (saddr != amt->discovery_ip) { + if (!amt_from_relay(amt, &saddr, true)) { netdev_dbg(amt->dev, "Invalid Relay IP\n"); err = true; goto drop; @@ -3442,7 +3554,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) } goto out; case AMT_MSG_MULTICAST_DATA: - if (!remote_ip || saddr != remote_ip) { + if (!amt_from_relay(amt, &saddr, false)) { netdev_dbg(amt->dev, "Invalid Relay IP\n"); err = true; goto drop; @@ -3453,7 +3565,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) else goto out; case AMT_MSG_MEMBERSHIP_QUERY: - if (!remote_ip || saddr != remote_ip) { + if (!amt_from_relay(amt, &saddr, false)) { netdev_dbg(amt->dev, "Invalid Relay IP\n"); err = true; goto drop; @@ -3598,7 +3710,7 @@ static struct sock *amt_create_sock(const struct amt_dev *amt) 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.use_udp6_rx_checksums = amt->mode == AMT_MODE_RELAY; udp_conf.ipv6_v6only = true; } else { udp_conf.family = AF_INET; @@ -3667,7 +3779,7 @@ static int amt_dev_open(struct net_device *dev) } amt->req_cnt = 0; - WRITE_ONCE(amt->remote_ip, 0); + amt_clear_remote(amt); amt->nonce = 0; amt->status = AMT_STATUS_INIT; @@ -3716,7 +3828,7 @@ static int amt_dev_stop(struct net_device *dev) amt->ready4 = false; amt->ready6 = false; amt->req_cnt = 0; - WRITE_ONCE(amt->remote_ip, 0); + amt_clear_remote(amt); /* Mark every tunnel dead first, so a concurrent amt_tunnel_expire() * sees ->dead and bails instead of freeing a tunnel in parallel; this @@ -3886,6 +3998,7 @@ static int amt_newlink(struct net_device *dev, amt->max_tunnels = AMT_MAX_TUNNELS; spin_lock_init(&amt->lock); + seqlock_init(&amt->remote_ipv6_lock); seqcount_spinlock_init(&amt->key_seq, &amt->lock); amt->max_groups = AMT_MAX_GROUP; amt->max_sources = AMT_MAX_SOURCE; diff --git a/include/net/amt.h b/include/net/amt.h index 967acaf38..823623b99 100644 --- a/include/net/amt.h +++ b/include/net/amt.h @@ -387,6 +387,8 @@ struct amt_dev { __be32 remote_ip; /* Outer remote ipv6 (learned from the Advertisement; :: in v4 mode) */ struct in6_addr remote_ipv6; + /* Publishes remote_ipv6, which is too wide for a single access */ + seqlock_t remote_ipv6_lock; /* Outer discovery ip */ __be32 discovery_ip; /* Outer discovery ipv6 (v6 gateway only; :: in v4 mode) */ diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c index be6dac8a8..4adc6f316 100644 --- a/net/ipv6/anycast.c +++ b/net/ipv6/anycast.c @@ -513,6 +513,7 @@ bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev, rcu_read_unlock(); return found; } +EXPORT_SYMBOL(ipv6_chk_acast_addr); /* check if this anycast address is link-local on given interface or * is global