๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16950

Re: [PATCH net v5 1/2] vxlan: reset the remote's dst cache when snooping moves a MAC

#16950
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 04:55
138 lines
12860 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 2 ยท Low: 0

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] The new dst_cache_reset() in vxlan_snoop() does not fully stop
  a stale route from being cached for the new remote.
- [Medium] vxlan_snoop() now writes two dependent fields, rdst->remote_ip
  and rdst->remote_ifindex, as separate plain stores with no hash_lock.

--

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

When a learned MAC migrates to a new remote, vxlan_snoop() now resets the
remote's dst_cache, updates remote_ifindex and clears offloaded. This
matches what vxlan_fdb_replace() already does. The early return also
changes so that remote_ifindex is only compared for IPv6 link-local
sources.

> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index d11028b374721..1cfb34fa23604 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
> @@ -1470,7 +1470,7 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev,
>  			return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS;
>  
>  		if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip) &&
> -			   rdst->remote_ifindex == ifindex))
> +			   (!ifindex || rdst->remote_ifindex == ifindex)))
>  			return SKB_NOT_DROPPED_YET;
>  
>  		/* Don't migrate static entries, drop packets */
> @@ -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 transmitter on another CPU still cache the route to the old remote
after this reset?

vxlan_snoop() holds only RCU here. vxlan_xmit_one() reads the same fields
without a lock and then uses the cache:

drivers/net/vxlan/vxlan_core.c:vxlan_xmit_one() {
    ...
		ifindex = rdst->remote_ifindex;
    ...
			key.u.ipv4.dst = rdst->remote_ip.sin.sin_addr.s_addr;
    ...
		dst_cache = &rdst->dst_cache;
    ...
}

dst_cache_reset() only stores jiffies in reset_ts. A cached entry is
checked against that timestamp at jiffy granularity only:

net/core/dst_cache.c:dst_cache_per_cpu_get() {
    ...
	if (unlikely(!time_after(idst->refresh_ts,
				 READ_ONCE(dst_cache->reset_ts)) ||
    ...
fail:
	idst->refresh_ts = jiffies;
	return NULL;
}

On a cache hit, udp_tunnel_dst_lookup() returns the dst without comparing
it to key->u.ipv4.dst.

Consider this interleaving:

CPU1 (vxlan_xmit_one)             CPU0 (vxlan_snoop)
reads old rdst->remote_ip
                                  dst_cache_reset() at jiffy J
                                  rdst->remote_ip = *src_ip
dst_cache_get() at J+1, misses,
  refresh_ts = J+1
looks up route to old remote,
  caches it

After that, every transmit on CPU1 to this MAC uses the old remote's dst
with the new remote's address. Later packets from the new remote take the
early return, so snooping never resets the cache again.

Is that the same blackhole the commit message describes, just reached
through a race? Reordering the stores, even with smp_wmb(), doesn't seem
to close the window. vxlan_fdb_replace() does the same reset followed by
in-place stores, so it has the same window.

> +		rdst->remote_ifindex = ifindex;

[Severity: Medium]
Can concurrent snoops of the same MAC leave remote_ip and remote_ifindex
inconsistent?

These are two plain stores with no hash_lock. RX for one VXLAN device can
run on several CPUs at once, for example:

CPU1: snoop from fe80::1 on ifindex 5
CPU0: snoop from 2001:db8::1, ifindex 0

If the stores interleave, the entry can end up as {remote_ip =
2001:db8::1, remote_ifindex = 5}.

With the new early-return check:

	(!ifindex || rdst->remote_ifindex == ifindex)

later packets from 2001:db8::1 return early, so the stale ifindex is never
repaired. f->updated also keeps being refreshed, so the entry doesn't age
out.

vxlan_xmit_one() then uses ifindex 5 as the output interface for the
global address. If that address isn't routed via device 5, the route
lookup fails and traffic to the MAC is dropped.

This looks like the state the commit message says it fixes ("the remote
keeps the previous interface"). vxlan_fdb_replace(), which writes these
fields under hash_lock, can mix with this lockless snoop in the same way.

> +		rdst->offloaded = false;
>  		vxlan_fdb_notify(vxlan, f, rdst, RTM_NEWNEIGH, true, NULL);
>  	} else {
>  		/* learned new entry */

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115040609.61134-1-ilskdw%40gmail.com
Technical Details
Message-ID: <179480495432.3136.17109064150958616332@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364061-linux-kernel-netdev=dewy.ru
References: <20261115040609.61134-2-ilskdw@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364061-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v5 1/2] vxlan: reset the remote's dst cache when
 snooping moves a MAC
Date: Mon, 16 Nov 2026 04:55:54 +0000
Organization: Usenet Network
Message-ID: <179480495432.3136.17109064150958616332@kernel.org>
References: <20261115040609.61134-2-ilskdw@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1982187"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:crugZJErhm6BRa9FCka71+O9BPo= sha256:sqa6Kh8X3O+k6/+tUXEoBuBQFUjrkrNtZBXXf/tqh+Q=
	sha1:hor5XM7GvGTZfOMfRaWzyvjCvrQ= sha256:REleSI852cIZHLOPbBHH8kNqhJ9y1mDOoj2Q583xA50=
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 50A8D114B2C; Mon, 16 Nov 2026 07:56:17 +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 IaJ6QB8H1Tn0;
	Mon, 16 Nov 2026 07:56:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-364061-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 1C5AB114B29; Mon, 16 Nov 2026 07:56:03 +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 40D78309BF; Mon, 16 Nov 2026 04:55:57 +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=1794804957;
	b=PMpsTONzToNqueM7Gsena6u3A6UQcoTya/B//QUioXh1ReL71jUN6+HfisreqdJ/2lFr
	 lIHoSjm3OppPj/D7jkT4zqzyXMfkomt/yBoiITYI+CoVWCkYy+19K4OrInfWa/UnsyEGu
	 LH2Yq2Dzp+0f/huzUrv5kpa6tM91TTHAYs6nncvQdTNpZELI0W2x6aXNrJVoHoV24I+E8
	 2lL7YXjG5UFaauo4PuEnrDnh4g79tLuZzzWQDMatZKK/e+4SBgfX/ptrkcFF8rLEVHxKE
	 EIIEfDqIU0w4wrag9Eu6dWB4WtR8hbRWCxQhNnufRuB3UjNBevz7yVTOCZBijZibp5Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794804957;
	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=kbeLhk4kveCo14x8XWoRSKZ1A1Z6lHlwD7WTyW8dlbM=;
	b=GbYSzH92oSRc1qN9rJGmU8RRIHklMIxBbuolW8BcEIiu0wJHd101PuLvp9XGGCJuQxGx
	 7jj35mrSZOPaYNloywwU+NQq5WrpplTPBEmarzA42EuPxbIj+EIfapQOH//GJ+ndLBjRc
	 XAHWDwLva0ey09usLJxlAU56F+1KfWYRzmIupsl1KzfkhH5QcYF2UkEPFvs0Jehfimibq
	 bc/KJSASPwPLUMGxxAGPY5C8/H6ENYAdV29ZcuSZDoltlTb4mXEeSLJG4pV9zadQfcRcZ
	 BdOn2m9CkDcn082w93FNQqoHJa1JE/1MEWxKfk7z26hirnBeMaQXCJaseITpcWvuFwg==
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=lw2ofetG;
	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 E2262606A32F;
	Mon, 16 Nov 2026 04:55:56 +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=lw2ofetG
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=1794804956;
	b=GwZSrB+ZpZbfKC7Mo5mEHBwCbF/3xq4cCL5dabn9hR8mzaoPLmzJB2wSgO1I7bSeLpNM
	 FCOE94HhHxMVNKCwOvurocbeSfs2LriVvhc/3U8mtFx7GxU+EL765LXhRh/ZLCYzAcjRx
	 d38p0vkBvIu0o87Bcd9AH4Xx8mGrIOXxd4XgSaNFOfixJhBlATNMlCRenNO+MkGaO0xCg
	 YBzD3i3hxPbgX/CI+cF/VuUmwkrubpc70hGiO959RIgv3GNHFZ2TprZbbzlhn//KdOvNc
	 j7gaIzY0AfR75/kr5PMjebgYGdbjyd8DreMoLeRbFEXQJGe/cE+T2C5OTe+LiBZyQKw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794804956;
	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=kbeLhk4kveCo14x8XWoRSKZ1A1Z6lHlwD7WTyW8dlbM=;
	b=SRRj+QZhIc1uk00LmO5zpBUY4oMWd94ziQ2Ukon0MQv9Iuk5R3ggzjL2LlwDMlDJyblf
	 TEE6SimHE+ae6+NsofMe3lUVwOgF4rRQVDSTS5Y/w66MW9QobnLyC2ZvBTehpg0aKioT7
	 tT0BSnQ9DVC5VzE4MfJB7R2JtofuAVIoLrRPPSOxV7CBRTBifQ3Env8NhVIgYsC7N+DD/
	 L91i38RzdfbkleieNNr9CbH8602YpZsvXtdgehf6SyiBefBarni+f6UkL2iSD++KFCh2a
	 VNM2aKYA8lgEeS1HVcHleh9TkfyOJNjHy/sNO4lfmXqX0TmAaddGbDm6eqPVduy4QPA==
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=lw2ofetG;
	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 0AE4B606A31C;
	Mon, 16 Nov 2026 04:55:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDF0B1F000C4;
	Mon, 16 Nov 2026 04:55:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794804955;
	bh=kbeLhk4kveCo14x8XWoRSKZ1A1Z6lHlwD7WTyW8dlbM=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=lw2ofetG4cDmvHWE14nN9TnT6/h5l3Pb/a8buMjxTJDfjjqQxquddfDe9sK9I4ken
	 Bz+vuhDwuM1vgJg7jyDHEqJBJ4TiZd6L/w3p1MGNi24rKVz5S03Sv2xfL0iy81inX9
	 FBDs+6K+4Q7lrFrOeDgAkKdTZyve8gBg6dqcG/axXXJJbvVDyOjzyFtthPXVJhT4kp
	 tTo3XlVOUlqS6WLpbOXYvAETsXpPZ8ryCdOipBtRPwVHJCmCSHNW8BGN8BaQ0ky1br
	 ueFinberADJh02vjGiS75YXtmPKw/bUkzrH8/aP/XmhLYACIUpO3mGS0cZqRveNUL/
	 waoliR5KHhvzA==
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 kuniyu@google.com, mschiffer@universe-factory.net, nicolas.dichtel@6wind.com,
 shuah@kernel.org, linux-kselftest@vger.kernel.org
X-In-Reply-To: <20261115040609.61134-2-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