From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.simonwunderlich.de (mail.simonwunderlich.de [23.88.38.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35D3143DA23 for ; Fri, 15 May 2026 09:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=23.88.38.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778838962; cv=none; b=i+YO4l9GI2BikbVBwQbIoLuaik3JsD752SxqeTjzj/+ko+epKloaep1jfFJVDX74fs4caarRe3+ozLTYYlkgY/We+D8FqB2SgfYPyp5YsYf+WN8hTRd26XAcbZmqDdXbHV13jRt/et/725TLLLAQsDd1VKL2nIDGg9Sp/Efz/3s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778838962; c=relaxed/simple; bh=4KaiGV31VY6nwZmMfhTyDfCcFB1eD0rsghZrRPc2iKo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z9B587apSkFWaq6uhVWBgMwcD7zM4Hi4XvhofW0ptLHOUurVlcdeHnLgPMQvloHYSMvKY43kSUZztgkeplCh3ZA2VHPqy6cXRgkgCZFz1df5iEojF+OA549PCPZMx760yeNoEn7EM0UGCqwcA+RJXFhfimenfkv6ye04qEz1RTA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=simonwunderlich.de; spf=pass smtp.mailfrom=simonwunderlich.de; dkim=pass (2048-bit key) header.d=simonwunderlich.de header.i=@simonwunderlich.de header.b=kuXYf9Oc; arc=none smtp.client-ip=23.88.38.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=simonwunderlich.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=simonwunderlich.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=simonwunderlich.de header.i=@simonwunderlich.de header.b="kuXYf9Oc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=simonwunderlich.de; s=09092022; t=1778838955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MD7N++K/ODC3M1fZeSj71WXES304/gYjuuvWCHBoPkI=; b=kuXYf9OcuM4E/PVrqnysbJ4fQ8zUSSGuI0z/fDOx1R56paTQYkVq8Ye9CcmV/CsZiNTseW stnMRWM8ltb5K8C4xhiXy3GM/DBFEKmPltH/mxrPvtXf2L7KBP+617akmPP7TwEiFkJIAX SfTt7HEIBQZK+HIGJdHATn6lntsKLOLBd/wplD3kKUhW5G6Vz4JZRL2EmCK5dKfHQIouDl vzLu9sqRB2QVOxtxQGl3KIuKIuRZvxfyPeX8pg4yvlo3iV8Qhh+w+MM3StbbS/+lm/ycGJ /fA9ettrY9l9QoMppfOVdZ6FkgkV3CB6iC5tFquTXBgBTh5naqjynMzo6Xd76Q== From: Simon Wunderlich To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , b.a.t.m.a.n@lists.open-mesh.org, Ruijie Li , stable@kernel.org, Yuan Tan , Yifan Wu , Juefei Pu , Xin Liu , Zhanpeng Li , Ren Wei , Sven Eckelmann , Simon Wunderlich Subject: [PATCH net 10/14] batman-adv: clear current gateway during teardown Date: Fri, 15 May 2026 11:55:35 +0200 Message-ID: <20260515095540.325586-11-sw@simonwunderlich.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260515095540.325586-1-sw@simonwunderlich.de> References: <20260515095540.325586-1-sw@simonwunderlich.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ruijie Li batadv_gw_node_free() removes the gateway list entries during mesh teardown, but it does not clear the currently selected gateway. This leaves stale gateway state behind across cleanup and can break a later mesh recreation. Clear bat_priv->gw.curr_gw before walking the gateway list so the selected gateway reference is dropped as part of teardown. Fixes: 2265c1410864 ("batman-adv: gateway election code refactoring") Cc: stable@kernel.org Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Xin Liu Signed-off-by: Ruijie Li Signed-off-by: Zhanpeng Li Signed-off-by: Ren Wei Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/gateway_client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 51e9c081a2a4e..a9d0346e8332e 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -478,10 +478,14 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv, */ void batadv_gw_node_free(struct batadv_priv *bat_priv) { + struct batadv_gw_node *curr_gw; struct batadv_gw_node *gw_node; struct hlist_node *node_tmp; spin_lock_bh(&bat_priv->gw.list_lock); + curr_gw = rcu_replace_pointer(bat_priv->gw.curr_gw, NULL, true); + batadv_gw_node_put(curr_gw); + hlist_for_each_entry_safe(gw_node, node_tmp, &bat_priv->gw.gateway_list, list) { hlist_del_init_rcu(&gw_node->list); -- 2.47.3