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 v6 1/2] vxlan: reset the remote's dst cache when snooping moves a MAC
Date: Mon, 23 Nov 2026 10:19:32 +0000 [thread overview]
Message-ID: <179542917290.3135.7119976710700884013@kernel.org> (raw)
In-Reply-To: <20261119095256.42005-2-ilskdw@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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] The patch does not close the stale dst_cache problem it says
it fixes.
- [Low] The re-check under the lock in vxlan_snoop_move() runs its tests
in a different order from the lockless fast path in vxlan_snoop().
--
vxlan: reset the remote's dst cache when snooping moves a MAC
When vxlan_snoop() sees a known MAC arrive from a different remote, it
now resets the remote's dst_cache, updates remote_ifindex and clears
offloaded, matching what vxlan_fdb_replace() does. It compares
remote_ifindex only for IPv6 link-local sources. The remote update now
runs in a new helper, vxlan_snoop_move(), which holds vxlan->hash_lock
and checks the entry again once the lock is taken.
> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index d11028b374721..8738be39e6019 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
> @@ -1434,6 +1434,51 @@ static int vxlan_fdb_get(struct sk_buff *skb,
[ ... ]
> +static enum skb_drop_reason vxlan_snoop_move(struct net_device *dev,
> + struct vxlan_fdb *f,
> + const u8 *src_mac,
> + union vxlan_addr *src_ip,
> + u32 ifindex)
> +{
> + struct vxlan_dev *vxlan = netdev_priv(dev);
> + struct vxlan_rdst *rdst;
> +
> + lockdep_assert_held(&vxlan->hash_lock);
> +
> + /* The entry may have changed before the lock was taken */
> + if (hlist_unhashed(&f->fdb_node))
> + return SKB_NOT_DROPPED_YET;
> +
> + if (rcu_access_pointer(f->nh) ||
> + (f->state & (NUD_PERMANENT | NUD_NOARP)))
> + return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS;
> +
> + rdst = first_remote_rcu(f);
> + if (vxlan_snoop_same_remote(rdst, src_ip, ifindex))
> + return SKB_NOT_DROPPED_YET;
[Severity: Low]
Is this check order intended? The lockless path in vxlan_snoop() calls
vxlan_snoop_same_remote() before the NUD_PERMANENT | NUD_NOARP test. Here
the static-state test runs first.
Consider this sequence:
CPU A in vxlan_snoop() sees a dynamic entry with a different remote and
calls spin_lock(&vxlan->hash_lock).
Before CPU A gets the lock, "bridge fdb replace <mac> dst <src_ip>
permanent" runs vxlan_fdb_update_existing() under hash_lock. That sets
f->state = NUD_PERMANENT, and vxlan_fdb_replace() sets
remote_ip = src_ip.
CPU A then takes the lock, and vxlan_snoop_move() returns
SKB_DROP_REASON_VXLAN_ENTRY_EXISTS.
The packet is dropped, even though it came from the remote the static
entry now points to. The lockless path would have accepted the same
packet.
Would it make sense to move the same-remote check ahead of the
static-state check? The nh check would have to stay first, since
first_remote_rcu() is not valid for nexthop entries.
> +
> + if (net_ratelimit())
> + netdev_info(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;
> + rdst->remote_ifindex = ifindex;
[Severity: Medium]
Does this fully close the stale dst_cache window the patch is meant to
fix?
vxlan_xmit_one() does not take hash_lock. It copies the remote into the
lookup key well before it looks at the dst_cache:
drivers/net/vxlan/vxlan_core.c: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;
...
}
Later it calls udp_tunnel_dst_lookup(), which does dst_cache_get_ip4(),
then ip_route_output_key() on a miss, then dst_cache_set_ip4().
Cache validity is purely time based:
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;
}
Here is a possible sequence:
CPU1 (vxlan_xmit_one) CPU2 (vxlan_snoop_move)
key.u.ipv4.dst = old remote A
dst_cache_reset() /* reset_ts = J0 */
rdst->remote_ip = B
<jiffy tick, now J0+1>
dst_cache_get_ip4()
miss, refresh_ts = J0+1
ip_route_output_key() for A
dst_cache_set_ip4(route for A)
After that, every later lookup on CPU1 passes the time_after(refresh_ts,
reset_ts) test. The IPv4 obsolete check only fails when the route genid
changes.
Would packets with outer daddr B then keep using the next hop chosen for
A? That is the blackhole the commit message describes, and it would
last until something like "ip route flush cache" or another reset.
Doing the stores before dst_cache_reset() does not seem to help, since
CPU1 can still read A before either of them. Would this need a re-check
or a generation check between the route lookup and dst_cache_set, or an
rdst replaced via RCU?
vxlan_fdb_replace() and the other dst_cache_reset() users follow the
same pattern.
> + rdst->offloaded = false;
> + vxlan_fdb_notify(vxlan, f, rdst, RTM_NEWNEIGH, true, NULL);
> +
> + return SKB_NOT_DROPPED_YET;
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119095256.42005-1-ilskdw%40gmail.com
next prev parent reply other threads:[~2026-11-23 10:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 9:52 [PATCH net v6 0/2] vxlan: reset the remote's dst cache when snooping moves a MAC Zhefu Peng
2026-11-19 9:52 ` [PATCH net v6 1/2] " Zhefu Peng
2026-11-23 10:19 ` netdev-bot+sashiko [this message]
2026-11-19 9:52 ` [PATCH net v6 2/2] selftests: net: add a test for vxlan snooping moving " Zhefu Peng
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=179542917290.3135.7119976710700884013@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