From: netdev-bot+sashiko@kernel.org
To: ilskdw@gmail.com
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
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 [thread overview]
Message-ID: <179480495432.3136.17109064150958616332@kernel.org> (raw)
In-Reply-To: <20261115040609.61134-2-ilskdw@gmail.com>
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
next prev parent reply other threads:[~2026-11-16 4:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 4:06 [PATCH net v5 0/2] vxlan: reset the remote's dst cache when snooping moves a MAC Zhefu Peng
2026-11-15 4:06 ` [PATCH net v5 1/2] " Zhefu Peng
2026-11-16 4:55 ` netdev-bot+sashiko [this message]
2026-11-15 4:06 ` [PATCH net v5 2/2] selftests: net: add a test for vxlan snooping moving " Zhefu Peng
2026-11-16 4:55 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179480495432.3136.17109064150958616332@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=ilskdw@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=mschiffer@universe-factory.net \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox