🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16526

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

#16526
From: Zhefu Peng
Date: Sun, 15 Nov 2026 04:06
70 lines
14013 bytes
vxlan_snoop() handles a known MAC that now arrives from another remote
by rewriting the remote's IP address in place. It leaves the remote's
dst_cache alone, so the next packet to that MAC is routed with the dst
cached for the previous remote. When the two remotes have different
next hops, the packet leaves the wrong way. For example, if the
previous remote was on-link and the new one is behind a router, the
device resolves the new remote's address on the local link, the
neighbour stays incomplete, and traffic to the MAC is blackholed until
the cached route is invalidated, such as by "ip route flush cache".

The same branch also leaves remote_ifindex unchanged, although the
early return compares it and vxlan_xmit_one() uses it as the output
interface. When a MAC moves between an IPv6 link-local and another
address, the remote keeps the previous interface, and every later
packet from that remote enters the migration branch again.

vxlan_fdb_replace(), which makes the same change through netlink,
already resets the cache, updates remote_ifindex and clears offloaded.
Do the same when snooping.

vxlan_snoop() knows the interface only for IPv6 link-local sources and
uses 0 for all others, but the early return compares remote_ifindex for
every source. A packet from the remote of a dynamic entry that was
added with a "via" device therefore enters the migration branch as
well, which would now reset the device to 0. Compare remote_ifindex
only for link-local sources.

The selftest added in the next patch moves a MAC from an on-link IPv4
remote to one behind a router, and from a global IPv6 remote to a
link-local one. Both cases fail without this patch and pass with it.
A third case checks that the "via" device of a dynamic entry stays set
when its remote sends traffic.

This was found by our AI-driven automated live migration tests. The fix
and this changelog were written with the help of an AI coding assistant.

Fixes: 0c1d70af924b ("net: use dst_cache for vxlan device")
Fixes: 87613de95041 ("vxlan: fix snooping for link-local IPv6 addresses")
Signed-off-by: Zhefu Peng <ilskdw@gmail.com>
---
 drivers/net/vxlan/vxlan_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index d11028b37..1cfb34fa2 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;
+		rdst->remote_ifindex = ifindex;
+		rdst->offloaded = false;
 		vxlan_fdb_notify(vxlan, f, rdst, RTM_NEWNEIGH, true, NULL);
 	} else {
 		/* learned new entry */
-- 
2.54.0
Technical Details
Message-ID: <20261115040609.61134-2-ilskdw@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363554-linux-kernel-netdev=dewy.ru
References: <20261115040609.61134-1-ilskdw@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363554-linux-kernel-netdev=dewy.ru
From: ilskdw@gmail.com (Zhefu Peng)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v5 1/2] vxlan: reset the remote's dst cache when snooping moves a MAC
Date: Sun, 15 Nov 2026 12:06:08 +0800
Organization: Usenet Network
Message-ID: <20261115040609.61134-2-ilskdw@gmail.com>
References: <20261115040609.61134-1-ilskdw@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1725612"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rl47NyXX/ND51IQNb2Fe0AqTDmA= sha256:wTe5RshcKC1AYyEYXi0vftaoIR9cTZbVOTY1edylAsU=
	sha1:VwtxoNCdQ66AY+LMP5nBgkiMq5o= sha256:8Vegdq+ckWH7uTMK+0GYSrnBFOa+s8Kp5PMDmquH7e0=
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 5FE33125D3B; Sun, 15 Nov 2026 07:06:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	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=gmail.com
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 b5yaEDqIBVDr;
	Sun, 15 Nov 2026 07:06:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-363554-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id DF36D125D3D; Sun, 15 Nov 2026 07:06:29 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 512863371E; Sun, 15 Nov 2026 04:06:28 +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=1794715588;
	b=RaYsRIuSnEruh4pSq5DpG+OppEl/+r8LuohhXbsW4THIXTF8SQxL7z/onAzXQOY32Jwl
	 5kQZ/9khETFCNa6DaKoTTrMy92imnI3eH1Z9aBzv8XQj078Mep59G/PAIBexIyuk2JQCh
	 bJdi7ehCh1Ag10+p7T9Cunf+Y3FzrVRGsXviu4hvYrPGTFM3fyIjv5ctbXMRNnxZvmScv
	 Yj+9b51p7ylMqpGLaJX+I/GLl8yJ0A3ZJnYCKbpA8DY5W6vM/1wQbKLVBJSJ5w0W9ugqK
	 vVod30FgpsPYpdLxJGywz1eSLO39u2aEv1Z/ln0Co92aYaY7S1UkX9rtu54FzA9znJw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794715588;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=bOChi6lheS4EHx0MIl9gs99kMirPUpdkvQRxAFefnDU=;
	b=VUvheDMx9Al5WM1ghd4tLRYTRsNBSmaPer6BTnkBA18GeHsTxupfRtbKvGWeSLFdjD6Q
	 wubDKMylGvmfU3kdDPQa9+DIasSssxrqYBRVrpIoDX8EzdJebb2uV4wbArLmTM+gWOlu3
	 4qfaZevLuQqR+XQ9CMzBtEMiSvxyDOnG9Izwjje4v8pLvIdoYYFE6im0oKX0gjmGgtOlL
	 xmR0ae0cmuCgqYditri68PGrO/crWjn4yzfT8xdaAyXYPCrZlnZ0k6ZARdi6QItE7AkdC
	 1uBzAG7p3Fs7dlSI+UMdsxUgkxSImQV/HCrQmnS+cSUaqM9S2iiRygrL9kcvGtI2B4g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=at7PFRq1;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	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 E2B53606A331;
	Sun, 15 Nov 2026 04:06:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=at7PFRq1
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.182
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794715587;
	b=Bz3rVrFRPFE04zJ1hkJa+OzBCZ/InxjFK8jqgyNvlL9HMtI2JwlM/IsEco9nqRcaU0Ef
	 vw+T5j5W//JtHayKOfpDAS/XpZOCpfbe917/VIibih7eKYCNjKHlBfsCIR+1U7F7nGpTv
	 Bhtb2t+hsYHawPRYeIxMTay8AYQzch11/b2QzcRFONCZDJgidLfP/ZLNlgNeLrR4WCxvE
	 BqD/9pKj4IF+fMiaXxbkDWJ7eGgcy8gexN8xWNvDKoldjR7BuHjapweetbVo1K+K2WmWF
	 VJeCevftQiBewIe3elVor+45pjlRpRily058xL9e3kpfGGufpLq/8t6D1NXlbUt9KuA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794715587;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=bOChi6lheS4EHx0MIl9gs99kMirPUpdkvQRxAFefnDU=;
	b=vVrtaZn+/jFbHm0KfkCS8JwW2Cl0ki+Wc/KSFDNVb4k7TKwoc5sMekxwyzQbghbay0ee
	 GA6tIPdprU8S6bm4X8LYAp6JsmxPiClvUJ+DqiKepMdWVftx519U3sJ+jPjFFo4LuZVYM
	 ZChj8ExSmBOz04rrJHxZZptEuX6C50rizXVppZ+Gpxqj6txyZ7ATZklznFGnhf4zS+UZF
	 yXQj0KqYW11HJD6A4Nia2n7T7lSwyh5UR440YFD2q3aPRbX/wK2nJAgsRjOcgKNuDkZIn
	 911XcQ9ukNBo9U1rQwIlC/0K3RmfncLfKrPsrGy+3KtXu1J05mYspCUjxCb6jQwdvOA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=at7PFRq1;
	arc=none smtp.remote-ip=209.85.215.182
X-Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 329F7606A327
	for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 04:06:26 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 329F7606A327
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-cddac941ed1so1090003a12.2
        for <netdev@vger.kernel.org>; Sat, 14 Nov 2026 20:06:26 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794715585; x=1795320385; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=bOChi6lheS4EHx0MIl9gs99kMirPUpdkvQRxAFefnDU=;
        b=at7PFRq10eTsdOt9uitGaczbNBTm1VR+fitPN/ymHwOw1TEmTAcr+X0ArQU6H+VWWL
         uatUjAkMDUx0ORSw/1s9cxRvWXIXeGcIWAGU83rZPLXPfDo+bkY6cU8a8wth5DhHlqpH
         4F+d3biIsVtdV3ii0lHfFTG+mhjmdlEvy9tCT0FzzUNb2zrNWd3IHCoLlSj/9lJP33aD
         0Dkgm8srah7mn5YOo+Z8E89/Ws8MQ1EZiEFi/KoFSIAFhBNxNyo5gNWyrZs0AZJjN7zC
         myrRVAndu7rlCFrynDAlYtg/tPgU5hU1PXjMz7ju5qcoV9ptDwEN6ld459M5W1l/G0dx
         nLjg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794715585; x=1795320385;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=bOChi6lheS4EHx0MIl9gs99kMirPUpdkvQRxAFefnDU=;
        b=wHRV+zBMtNEb7DEjXVu4KGUBPrAqVFf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aVSGsmvhi2vhUlgOebr4Bz
	oiSorX+V/oN6g4zUO6S37nSQdn5qK2PpCz3P+4cUHKtRmttFljohtCEiUe5kEGbUdFWBii9MEp2
	uatY=
X-Received: by 2002:a05:6a20:2584:b0:3e2:57b7:4d7e with SMTP id adf61e73a8af0-3f7a51b3164mr6894533637.10.1794715585250;
        Sat, 14 Nov 2026 20:06:25 -0800 (PST)
X-Received: from localhost.localdomain ([116.88.205.165])
        by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8bed12a8682sm2485668b3a.10.2026.11.14.20.06.19
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Sat, 14 Nov 2026 20:06:23 -0800 (PST)
X-Cc: 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-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261115040609.61134-1-ilskdw@gmail.com>
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