🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16721

Re: [PATCH net v3] vxlan: reset the remote's dst cache when snooping moves a MAC

#16721
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 18:22
205 lines
15790 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In vxlan_snoop() (drivers/net/vxlan/vxlan_core.c), the patch
  writes the snoop-derived `ifindex` into rdst->remote_ifindex (line…
- [Medium] The stale-dst_cache bug the patch claims to fix can still
  happen through a race with a concurrent transmitter.
- [Medium] vxlan_snoop() now clears rdst->offloaded
  (drivers/net/vxlan/vxlan_core.c line 1488) right before…
- [Low] vxlan_snoop() (drivers/net/vxlan/vxlan_core.c, lines 1485-1488)
  now writes rdst->remote_ifindex and rdst->offloaded from RX softirq…

--

vxlan: reset the remote's dst cache when snooping moves a MAC

When vxlan_snoop() migrates a learned FDB entry to a new remote, this patch
resets the remote's dst_cache, sets remote_ifindex to the snooped ifindex
and clears the offloaded flag, the same way vxlan_fdb_replace() does. The
goal is to stop traffic being routed through a stale cached dst after a MAC
move, and to stop repeated migrations for IPv6 link-local remotes.

> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index d11028b374721..6bc54642e7f45 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
> @@ -1482,7 +1482,10 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev,
>  				    "%pM migrated from %pIS to %pIS\n",
>  				    src_mac, &rdst->remote_ip.sa, &src_ip->sa);
>  
> +		dst_cache_reset(&rdst->dst_cache);
>  		rdst->remote_ip = *src_ip;

[Severity: Medium]
Can a concurrent transmitter still put the old remote's dst back into the
cache after this reset?

vxlan_xmit_one() reads the remote without any synchronization:

vxlan_xmit_one() {
    ...
	ifindex = rdst->remote_ifindex;

	if (addr_family == AF_INET) {
		key.u.ipv4.src = cfg->saddr.sin.sin_addr.s_addr;
		key.u.ipv4.dst = rdst->remote_ip.sin.sin_addr.s_addr;
    ...
	dst_cache = &rdst->dst_cache;
    ...
}

On a miss, dst_cache_per_cpu_get() sets refresh_ts when the lookup
happens, not when the new dst is stored:

fail:
	idst->refresh_ts = jiffies;
	return NULL;

The entry then counts as valid as long as refresh_ts is after reset_ts.
So this sequence seems possible:

CPU1 (TX)                          CPU0 (vxlan_snoop)
reads old remote_ip/ifindex
                                   dst_cache_reset()   /* reset_ts = J1 */
                                   rdst->remote_ip = *src_ip;
                                   rdst->remote_ifindex = ifindex;
<jiffies ticks>
udp_tunnel_dst_lookup()
  dst_cache_get_ip4() misses, refresh_ts = J2 > J1
  routes to the old remote
  dst_cache_set_ip4() stores the old remote's dst

After this, packets sent on CPU1 carry the new remote_ip but use the old
remote's dst. That is the same blackhole the changelog describes, and it
lasts until the dst goes obsolete or the cache is flushed.

The plain stores also let the TX side read a remote_ip from one remote and
a remote_ifindex from the other.

vxlan_fdb_replace() has the same window. Does this patch fully close the
case it targets?

> +		rdst->remote_ifindex = ifindex;

[Severity: Medium]
Does this clear an egress interface that user space configured for a
remote that is not link-local?

In vxlan_snoop(), ifindex is non-zero only for IPv6 link-local sources:

	if (src_ip->sa.sa_family == AF_INET6 &&
	    (ipv6_addr_type(&src_ip->sin6.sin6_addr) & IPV6_ADDR_LINKLOCAL))
		ifindex = src_ifindex;

However, vxlan_fdb_parse() accepts NDA_IFINDEX for any remote address
family, and vxlan_fdb_add() accepts dynamic (NUD_REACHABLE) entries.

Take a dynamic entry added with "via <dev>" for an IPv4 or global IPv6
remote A, on a device with learning enabled. The first packet from A then
fails the early return:

	if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip) &&
		   rdst->remote_ifindex == ifindex))
		return SKB_NOT_DROPPED_YET;

It fails because remote_ifindex holds the user's value while ifindex is 0.
The entry is not static, so the code logs "migrated from A to A" and this
new line sets remote_ifindex to 0.

>From then on, vxlan_xmit_one() sees ifindex == 0 and falls back to the
socket's bound device for the route lookup:

	if (!ifindex)
		ifindex = sock4->sk->sk_bound_dev_if;

RTM_NEWNEIGH also stops reporting NDA_IFINDEX for this entry.

Before this patch, this case sent a notification on every packet but kept
the configured interface. Could remote_ifindex be compared and overwritten
only when the old or the new remote is IPv6 link-local?

> +		rdst->offloaded = false;

[Severity: Medium]
Can clearing offloaded here leave a stale entry in the mlxsw hardware
FDB?

At this point the ASIC may still have a tunnel FDB entry for this MAC that
points at the old remote. vxlan_fdb_switchdev_notifier_info() copies the
flag into every switchdev notification:

	fdb_info->offloaded = rd->offloaded;

mlxsw_sp_switchdev_vxlan_fdb_del() skips the hardware removal when that
copy is false:

	vxlan_fdb_info = &switchdev_work->vxlan_fdb_info;
	if (!vxlan_fdb_info->offloaded)
		return;

The new remote is programmed later, from deferred work in
mlxsw_sp_switchdev_vxlan_fdb_add(). That function can return without
setting offloaded back to true, either when br_fdb_find_port() does not
return the vxlan device or when mlxsw_sp_port_fdb_tunnel_uc_op() fails.

There is a second case. If the vxlan FDB entry is deleted after the snoop
but before the ADD work runs, the DEL captures offloaded == false. The ADD
then programs the hardware, and vxlan_fdb_offloaded_set() finds no entry
to mark.

In both cases a later DEL skips the hardware removal. The ASIC then keeps a
static MAC to VTEP entry that software no longer tracks, until FID/NVE
teardown. Before this patch the snoop path left offloaded set, so a later
DEL removed the hardware entry by MAC/FID.

vxlan_fdb_replace() and new entry creation follow the same pattern. This
patch adds a trigger driven by received packets, and mlxsw supports
VXLAN_F_LEARN for an IPv4 underlay.

>  		vxlan_fdb_notify(vxlan, f, rdst, RTM_NEWNEIGH, true, NULL);

[Severity: Low]
A related question about locking: this branch runs in the RX softirq
without vxlan->hash_lock. The other code that writes remote_ifindex and
offloaded holds that lock: vxlan_fdb_offloaded_set(), vxlan_fdb_replace()
through vxlan_fdb_update_existing(), and vxlan_fdb_clear_offload().

Can this race with vxlan_fdb_offloaded_set()? Under hash_lock it looks up
the rdst using the old (remote_ip, port, vni, remote_ifindex) tuple:

	rdst = vxlan_fdb_find_rdst(f, &fdb_info->remote_ip,
				   fdb_info->remote_port,
				   fdb_info->remote_vni,
				   fdb_info->remote_ifindex);
	if (!rdst)
		goto out;

	rdst->offloaded = fdb_info->offloaded;

If the snoop rewrites the tuple and clears offloaded between that lookup
and the store, the clear is lost. The new remote then shows as offloaded.

A concurrent "bridge fdb replace" is similar. If vxlan_fdb_replace() runs
after the snoop has passed the f->state check, the rdst can end up with
remote_ip from one writer and remote_ifindex from the other. If the
replace made the entry static, the snoop path never touches it again and
the mixed state stays.

The unlocked remote_ip store was there before this patch. This patch adds
two more fields to it, while the vxlan_fdb_replace() code it copies runs
under hash_lock.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111180001.2475-1-ilskdw%40gmail.com
Technical Details
Message-ID: <179476692608.3136.1555292091406016703@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363791-linux-kernel-netdev=dewy.ru
References: <20261111180001.2475-1-ilskdw@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363791-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3] vxlan: reset the remote's dst cache when snooping
 moves a MAC
Date: Sun, 15 Nov 2026 18:22:06 +0000
Organization: Usenet Network
Message-ID: <179476692608.3136.1555292091406016703@kernel.org>
References: <20261111180001.2475-1-ilskdw@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1870482"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:iLEbgZereKp3B3sWO70Sk3U5/Yo= sha256:T3llKrIWn8lPz9PnmvWcOhFGka7EcQKUMYtWs5WE3mk=
	sha1:5B+RHwMeXPGLzkWAIEFE8VyHrwI= sha256:6dCasybia5KklK65g792ekPqzOfvRjmWx5AYFBSB+Vs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 2527C114A2A; Sun, 15 Nov 2026 21:22:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Xw_RENnjh-Ig;
	Sun, 15 Nov 2026 21:22:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363791-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 5DEE9114A0F; Sun, 15 Nov 2026 21:22:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 4B32139060; Sun, 15 Nov 2026 18:22:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794766928;
	b=GuCwx6hK6brNmxWRkVn6DJf8M8bZIgvvc2vxmHwMI6TBjThgSfl3ho2Ci7SHCmT/wpzY
	 Vv/nKn2I1TaRDCeSGMCO7tXDmNBl3beO8WVVmI1gJKhnfADcpNZ87FVw9qB1zLqDS8+rs
	 rpschkaqyftnRnkpDi/bIu1sM8QKnmZ6NHDD6215fRJDeSda/t88WRWbor9XApxbvy95t
	 lb8QyyBBQ71Hfok1+IS5CWh3YYBE8uFjAm/Lxa5PjHFyPvhhExTk5Jkn7hbovwMo2gTu9
	 XAPrnUbF18ww2+RJ+eMEZ352qP8av/a73ZSbsZfn67heqtvDBJcRfNZpAFisKhJxnIA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794766928;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=SRqp5mooACPAzd2gHIUg+QDQfae5E/MU1m2NjYPrGBU=;
	b=sWDvqy2ptXW3nEjFPM4a6BTxOBRpv/yjopymScPTxnvSM1LEKH8ZfKsCRhRFWFE6MQm7
	 ezR/sjMei2CQqTjVtE9INTOkboihY1FWdGzXVVDUSCtqbmTLxqIE/mYtViJKGvdigEdHI
	 PP8udZuAzgZyXxQ6DpcbwE6OEAKUhOQMrBfrvmROi61oLV6QdiBenFQuVlU9Q2OttVMos
	 IO8XQ4N45crhZGqnjD/3wcNKqI7mazPnn7fQl95YDMAEk0ImS4wgkuK4cntGItcpHwsfD
	 g0kCm0DcXRPBbSPwjVYcCu1fqb32xCUTrGkbgWOJfUwBMI4byjD731gVdf3HAAKllGA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CaEAhSB8;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 448DC606A329;
	Sun, 15 Nov 2026 18:22:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CaEAhSB8
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794766927;
	b=mRDA/5l94FOOm7LhyffF7SQ3aCp6WAmxBXfVUngA5hb+eFwum/GTtfuxbv32W3BGa4uB
	 3IqMS2W+4Tz+Q6lyzAo7boR9TMJAe8rdvm1NDOpo3xrxdR5kQLXBjZnNZU1tb0hZ5lYj8
	 cN9FDDVniBzdsupWAoAdL+Z33axp2Bb7gtQTg0ATgJ2xYm22K/KCz62Z1G5hID3sCR8D4
	 cu8UKzOOoqkqDAQMrRA/5yAZpL9REMzAoMmlTtX2euXonWm15oR5X2pAFfE1slqIIw15n
	 z6Tj1+gkT67E0Z981yVAY3XPZmyElQ+ILQVHYdVE0b7E6denTTy/OuUS5ym3oGccAxg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794766927;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=SRqp5mooACPAzd2gHIUg+QDQfae5E/MU1m2NjYPrGBU=;
	b=fOulJduz0olhwkm/Ca8ESYfIQO8woZtymJ9rtaiSeOOMD8SAxOCW2jbpGCBGeIJ6qsI2
	 7zlXcn0n1q8N8sLZGBnJPSzmzDmzG9pWe9vmUSLuPkU0A6tRAS6dQCa84HZjyA9vM0mQz
	 X5tP/UNz8q8vCCKHaGvtLkkEE2E7FYZ7V3znf/PlwaImGaUoKEuApRJAezb9jEXPrOV6D
	 uXaKeNPEVqLq3rb6LujZn3oHA7YSV8KJczPeapYjLORceJUW5AAqNM+swvtjvbQu1BWAq
	 Jl3chgIJ0YO7v4NqdP46Vt6Tp62ob+414jYMZ+BSLRw3yeWsuBYUfft9Nj35RO/Dsdg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CaEAhSB8;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6237E606A31F
	for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 18:22:07 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 820B61F000C4;
	Sun, 15 Nov 2026 18:22:06 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794766927;
	bh=SRqp5mooACPAzd2gHIUg+QDQfae5E/MU1m2NjYPrGBU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=CaEAhSB8XRa5vE4XbV/yT6HYSLDpdxQd6SdFaGmPbKgyFmiKCEpmnqfaRxnKIbLQ/
	 ZUARpZCbj2CIjzDP9baOXA4zxN9huxQQ9FL4xCuTe1UonO37ngOxRJPnMn+qicm2mC
	 54oRD5wWijhOFUZgtyl+55eSoHkZTvTe5WDXrVZgcZBWfydQbnMzmMInFzMV9zRCoy
	 slflHGV9rrT/TSp7UTdXfrbpx0CM7AJlGyejplr9/18FAp4ZkJV7aJJfULdD7YE+Rw
	 bi83zmYWI8IeuKvEZfxTS9PW8FAUujT5t2cU4JP0EV4UdvLWcaS6IFsyi3GJ8nrY5p
	 PC3tboA7TNgBQ==
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, kuniyu@google.com,
 mschiffer@universe-factory.net, nicolas.dichtel@6wind.com
X-In-Reply-To: <20261111180001.2475-1-ilskdw@gmail.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list