From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8DC7D3D522C; Wed, 8 Apr 2026 18:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672600; cv=none; b=uCdDRwWA98cCY6QWVl1s+vPJU+mT9ULocKqzM9KGhYKIYjH2SN+4kT/iD/rLMORDhu+0ISs9ihWsLhn0iskeJCaM39IsQ9O63N+rcdbh+9ImeffVeegn4TX05B+cJQGqRH3U/vF83gUosO1OqIikw6KBWksgj2TkaxwqUPamcDk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672600; c=relaxed/simple; bh=IRt/fKMCQ/kUfzILNXiTPIfOA935sa47FVcAvuQlvNw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k/531mpYLlSZBJzzYOLBHnLURzkIIMHKDs13yRncMz3+r3/duO84if1nynB9+qc1KDoHIaGqthCnDZmPH2u+lRy4Y1DIomvuXS0OnBdjoaHuyVOQ1FMvbl/hJWMRaFqLE2vbZYlJmlGxH7sY0tvJgS1XPm2eF/QwsAu24UOPvnk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=a7kuxp7j; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="a7kuxp7j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21902C19421; Wed, 8 Apr 2026 18:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775672600; bh=IRt/fKMCQ/kUfzILNXiTPIfOA935sa47FVcAvuQlvNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a7kuxp7jKLW8Nk2LnfcBfXKeTSZdhCI//L+/Zu6W8VIFOg+IHTT8MfrTrD7c/lcv6 vJB+d2Gy0pOXmcQrEhCRPCktqBuru/FGp5GefzwSq1Nvmawkn9G6juSK1IS9MqUWS+ b8Qu9Uwy44r6YuuqBI6YI1hq6fBwB45RZJjEjris= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Luka Gejak , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 062/160] net: hsr: fix VLAN add unwind on slave errors Date: Wed, 8 Apr 2026 20:02:29 +0200 Message-ID: <20260408175915.521370334@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175913.177092714@linuxfoundation.org> References: <20260408175913.177092714@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luka Gejak [ Upstream commit 2e3514e63bfb0e972b1f19668547a455d0129e88 ] When vlan_vid_add() fails for a secondary slave, the error path calls vlan_vid_del() on the failing port instead of the peer slave that had already succeeded. This results in asymmetric VLAN state across the HSR pair. Fix this by switching to a centralized unwind path that removes the VID from any slave device that was already programmed. Fixes: 1a8a63a5305e ("net: hsr: Add VLAN CTAG filter support") Signed-off-by: Luka Gejak Link: https://patch.msgid.link/20260401092243.52121-3-luka.gejak@linux.dev Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/hsr/hsr_device.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 70e958caa956d..b34a9b680aab3 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -473,8 +473,8 @@ static void hsr_change_rx_flags(struct net_device *dev, int change) static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) { - bool is_slave_a_added = false; - bool is_slave_b_added = false; + struct net_device *slave_a_dev = NULL; + struct net_device *slave_b_dev = NULL; struct hsr_port *port; struct hsr_priv *hsr; int ret = 0; @@ -490,33 +490,35 @@ static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, switch (port->type) { case HSR_PT_SLAVE_A: if (ret) { - /* clean up Slave-B */ netdev_err(dev, "add vid failed for Slave-A\n"); - if (is_slave_b_added) - vlan_vid_del(port->dev, proto, vid); - return ret; + goto unwind; } - - is_slave_a_added = true; + slave_a_dev = port->dev; break; - case HSR_PT_SLAVE_B: if (ret) { - /* clean up Slave-A */ netdev_err(dev, "add vid failed for Slave-B\n"); - if (is_slave_a_added) - vlan_vid_del(port->dev, proto, vid); - return ret; + goto unwind; } - - is_slave_b_added = true; + slave_b_dev = port->dev; break; default: + if (ret) + goto unwind; break; } } return 0; + +unwind: + if (slave_a_dev) + vlan_vid_del(slave_a_dev, proto, vid); + + if (slave_b_dev) + vlan_vid_del(slave_b_dev, proto, vid); + + return ret; } static int hsr_ndo_vlan_rx_kill_vid(struct net_device *dev, -- 2.53.0