Netdev List
 help / color / mirror / Atom feed
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 v7 1/2] vxlan: reset the remote's dst cache when snooping moves a MAC
Date: Fri, 27 Nov 2026 18:26:39 +0000	[thread overview]
Message-ID: <179580399973.3135.12029769847251459361@kernel.org> (raw)
In-Reply-To: <20261126182329.91058-2-ilskdw@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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 patch closes the deterministic case: a snooped migration
  now resets the cached route.

--

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

When vxlan_snoop() sees a known MAC arrive from a different remote, this
commit now resets the remote's dst_cache, updates remote_ifindex and
clears offloaded, matching what vxlan_fdb_replace() does. The early
return compares remote_ifindex only for IPv6 link-local sources. The
update runs under vxlan->hash_lock, and the entry is checked again once
the lock is held.

> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index d11028b374721..584d56d03b1c7 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
> @@ -1434,6 +1434,67 @@ 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)
> +{

[ ... ]

> +	rdst = first_remote_rcu(f);
> +	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;
> +	rdst->offloaded = false;

[Severity: Medium]
This fixes the deterministic case. Can a route for the previous remote
still end up in the cache after the migration, though?

hash_lock only serializes the writers. The TX path in vxlan_xmit_one()
reads the route key locklessly with plain loads, well before the cache
lookup:

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;
    ...
}

Then udp_tunnel_dst_lookup()->dst_cache_get_ip4() runs, and on a miss
dst_cache_per_cpu_get() stamps refresh_ts before the route lookup
happens:

net/core/dst_cache.c:dst_cache_per_cpu_get() {
    ...
fail:
	idst->refresh_ts = jiffies;
	return NULL;
}

Here is a possible interleaving:

CPU1 (TX)                          CPU2 (snoop)
vxlan_xmit_one()
  reads old remote_ifindex,
  old remote_ip into key
                                   vxlan_snoop_move()
                                     dst_cache_reset()  /* reset_ts = J0 */
                                     rdst->remote_ip = *src_ip;
                                     rdst->remote_ifindex = ifindex;
  /* jiffies moves to J0 + 1 */
  dst_cache_get_ip4()
    old entry rejected
    refresh_ts = J0 + 1
  route lookup with the old key
  dst_cache_set_ip4()

After this, every later lookup on CPU1 passes the
time_after(refresh_ts, reset_ts) check. That CPU keeps using the route
for the old remote while rdst->remote_ip holds the new address.

That gives the same next-hop mismatch or blackhole the commit message
describes. It lasts until the cache is reset again or the route goes
obsolete. Later packets from the new remote take the early return in
vxlan_snoop_should_move(), so nothing on the snoop path repairs it.

The same window also seems to allow a torn read of the 16-byte IPv6
remote_ip while the plain struct store is in progress.

Storing the fields first and resetting afterwards would not help, since
a TX that read the key before the store can still miss in a later
jiffy. vxlan_fdb_replace() uses the same reset-then-store order, so the
netlink path has this window too:

	dst_cache_reset(&rd->dst_cache);
	rd->remote_ip = *ip;

Would closing it fully need a different invalidation scheme? For
example, the rdst could be replaced under RCU, or a generation check
could be added.

> +	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/20261126182329.91058-1-ilskdw%40gmail.com

  reply	other threads:[~2026-11-27 18:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 18:23 [PATCH net v7 0/2] vxlan: reset the remote's dst cache when snooping moves a MAC Zhefu Peng
2026-11-26 18:23 ` [PATCH net v7 1/2] " Zhefu Peng
2026-11-27 18:26   ` netdev-bot+sashiko [this message]
2026-11-27 18:40     ` Zhefu Peng
2026-11-26 18:23 ` [PATCH net v7 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=179580399973.3135.12029769847251459361@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