From patchwork Sat May 6 23:05:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1778088 X-Patchwork-Delegate: sander@svanheule.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=RBJ+8cib; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=OUJQJ8Uc; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QDNXX2Cmvz214X for ; Sun, 7 May 2023 09:08:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ttm4vUY/94nVuuvKZruBiUdvdN2GwYU+yC3tt6r1iFE=; b=RBJ+8cib9ePsBk D42cauO2irJaVKKfX7ZbuO7awYeB9EGAZs5gzlJd6luLtNAcsgU7DR8uSxZiA1DIBP1BDd7oxcLCG HTIosNtQtiuVJ3p7LGRq6pkSGrJnbBdX2L1BeWe8jkGAARpiXZbDyRJQjtTAtyBe+coS8ePsGSd5a 0YdCT76CAiT9U8rcE0W74zoHkFkIqLYOlan7wFqn7TN2QcUhJcH6JByBYCjZ0huZdDaGAFf/H3/oI /fH6+cae9hOlQhGi117g6+yfJ7gol5pGUM2sxe/+C6L+sJrTU+Zr2qsAL1k5lrNVG4V+a015KFsdu nuBzmLHuEKCYXaS52z1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pvQzB-00EXJr-27; Sat, 06 May 2023 23:06:41 +0000 Received: from srv4.3e8.eu ([2001:67c:12a0:200::2]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pvQz8-00EXJD-10 for openwrt-devel@lists.openwrt.org; Sat, 06 May 2023 23:06:39 +0000 Received: from localhost.localdomain (p200300c6cf1962a00858ededb4df0c9f.dip0.t-ipconnect.de [IPv6:2003:c6:cf19:62a0:858:eded:b4df:c9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 716ED40BDD; Sun, 7 May 2023 01:06:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1683414369; 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=ZAwKh/PZIr3CSsT100LBxaE+bn/sJkQLbzRy61dyTms=; b=OUJQJ8UczwJKmtRiwEYpDSdK7a+zCHWdUDqXf3jHyJMXx9wlKAbu/Mbi1BisJI9RomIWaP RHubRiGLXH/mVIEZg+pbI7RlWl/KJRlPX18sS/HkZj6Mfy973Cyq7Y3VSaZIaj5qIr0mu/ oiOldUJINlEtRLZ3/9lq+yPdS2RhS42EMbEMf3EK9QX2KqnW48FVo/fB2zN2ESF26jIXZs h9wx5S/J5Grldi84GyguYBiabyyGdSGVgxLuL8/juMHRmGNxrZ/YtwYTo0Ii6TiW3O/7By 18nTHKv0v8HQ3Kl+iLhNL64p/wJynH48PeTpoHq4Crsx8pOEfwDakoB8mGQSTQ== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org, Sander Vanheule Cc: Jan Hoffmann Subject: [PATCH v2 1/6] realtek: fix writing/deletion of CAM entries Date: Sun, 7 May 2023 01:05:30 +0200 Message-Id: <20230506230535.1150881-2-jan@3e8.eu> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230506230535.1150881-1-jan@3e8.eu> References: <20230506230535.1150881-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230506_160638_495284_D2680F2C X-CRM114-Status: GOOD ( 10.26 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Actually use the index returned by rtl83xx_find_l2_cam_entry. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann --- .../realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 8 ++++---- .../realtek/files-5.15 [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Actually use the index returned by rtl83xx_find_l2_cam_entry. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann --- .../realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 8 ++++---- .../realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 63461ff57348..fee63c36faa1 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1662,7 +1662,7 @@ static int rtl83xx_port_fdb_add(struct dsa_switch *ds, int port, } // Hash buckets full, try CAM - rtl83xx_find_l2_cam_entry(priv, seed, false, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { rtl83xx_setup_l2_uc_entry(&e, port, vid, mac); @@ -1698,7 +1698,7 @@ static int rtl83xx_port_fdb_del(struct dsa_switch *ds, int port, } /* Check CAM for spillover from hash buckets */ - rtl83xx_find_l2_cam_entry(priv, seed, true, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, true, &e); if (idx >= 0) { e.valid = false; @@ -1800,7 +1800,7 @@ static void rtl83xx_port_mdb_add(struct dsa_switch *ds, int port, } // Hash buckets full, try CAM - rtl83xx_find_l2_cam_entry(priv, seed, false, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { if (e.valid) { @@ -1860,7 +1860,7 @@ int rtl83xx_port_mdb_del(struct dsa_switch *ds, int port, } /* Check CAM for spillover from hash buckets */ - rtl83xx_find_l2_cam_entry(priv, seed, true, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, true, &e); if (idx >= 0) { portmask = rtl83xx_mc_group_del_port(priv, e.mc_portmask_index, port); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index 83a0441ce27c..f9980ccacee1 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -1642,7 +1642,7 @@ static int rtl83xx_port_fdb_add(struct dsa_switch *ds, int port, } /* Hash buckets full, try CAM */ - rtl83xx_find_l2_cam_entry(priv, seed, false, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { rtl83xx_setup_l2_uc_entry(&e, port, vid, mac); @@ -1680,7 +1680,7 @@ static int rtl83xx_port_fdb_del(struct dsa_switch *ds, int port, } /* Check CAM for spillover from hash buckets */ - rtl83xx_find_l2_cam_entry(priv, seed, true, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, true, &e); if (idx >= 0) { e.valid = false; @@ -1776,7 +1776,7 @@ static int rtl83xx_port_mdb_add(struct dsa_switch *ds, int port, } /* Hash buckets full, try CAM */ - rtl83xx_find_l2_cam_entry(priv, seed, false, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { if (e.valid) { @@ -1839,7 +1839,7 @@ int rtl83xx_port_mdb_del(struct dsa_switch *ds, int port, } /* Check CAM for spillover from hash buckets */ - rtl83xx_find_l2_cam_entry(priv, seed, true, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, true, &e); if (idx >= 0) { portmask = rtl83xx_mc_group_del_port(priv, e.mc_portmask_index, port); From patchwork Sat May 6 23:05:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1778091 X-Patchwork-Delegate: sander@svanheule.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=dZkdBBaO; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=R9t+4a+g; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QDNXX1KJzz213r for ; Sun, 7 May 2023 09:08:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=La8L/nXEKg5aESYTRFLXPxJXmRgXkaVsPpVwnDAbKTM=; b=dZkdBBaO1YHS2p b3fLAjGFp8y7pJdGyvnejfRYNTvbTpKtXfIIgObk9O7nqjh7bTMoih+NMJ/ta+gOHse4oOZ+Nw0xU VPDN5Iu7988NwG9l1a+Ui/M102yKIhFUcuMFVzL1VhF+iIeUDtM6b54mJr9nM7uJk1+MRZLIp5bIT KMtv2ktBqmFqUkVXESYYqh2FeCCB8fsebKu6+pDE0KW5asfQLIxm50HDbAU3xngug0HIbG19FyebB 7H10+8NTruegO6wBLffatmZJNsG0Fxq0BLVk3MGAlrtHI8b+6dvxY3uNUl8W+DUH0DJh9jsNj4y7V kzJt7o/M9YLjYif1fIMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pvQzR-00EXLH-0c; Sat, 06 May 2023 23:06:57 +0000 Received: from srv4.3e8.eu ([193.25.101.238]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pvQzN-00EXKk-2C for openwrt-devel@lists.openwrt.org; Sat, 06 May 2023 23:06:55 +0000 Received: from localhost.localdomain (p200300c6cf1962a00858ededb4df0c9f.dip0.t-ipconnect.de [IPv6:2003:c6:cf19:62a0:858:eded:b4df:c9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id CBCE140C9C; Sun, 7 May 2023 01:06:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1683414369; 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=QQJVlIkL85iGWuVPQrv1YcbecsSuMmW08OYJtDjH3Wo=; b=R9t+4a+gazAypk1ed5aetYzP+YLuKp/URpp/eIOrJs0QCQ58+fZqa27oVUOb0+WX+zhQCG a4FV7f0F+BoHj1iWhhkSZba0ZBBfX89gv20AF5ORYU5khFL8NxBguavlEt4UENzCZPkNmc DlpfnZ/1MVAHJRCvs0lm4mOTXn//LrOI2Cmt0I6g9+xmAzAwaCZ/FmHhZFfJ3TtVMfLrO8 5W5GgRbnU9AzRh92MK7WjchCl/35O7RkpV/pSKF2HARlTGqiJ1LOaJKG347OD4NZmPBXE6 5TTRwwyytH+hA0CN6kALQdl3txTks62mBh5sOvrhO9fzgOqdusiFuUJ3is4TrQ== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org, Sander Vanheule Cc: Jan Hoffmann Subject: [PATCH v2 2/6] realtek: don't treat first multicast portmask entry as reserved Date: Sun, 7 May 2023 01:05:31 +0200 Message-Id: <20230506230535.1150881-3-jan@3e8.eu> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230506230535.1150881-1-jan@3e8.eu> References: <20230506230535.1150881-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230506_160653_867799_AFA82C79 X-CRM114-Status: GOOD ( 12.00 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: There doesn't appear to be a reason to do this, as only the last entry is actually reserved for unknown multicast. This also fixes two issues: - As the increment happened after the bounds check, the value of the actually reserved last entry could be overwritten. - On deletion of entries, a corresponding decrement [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org There doesn't appear to be a reason to do this, as only the last entry is actually reserved for unknown multicast. This also fixes two issues: - As the increment happened after the bounds check, the value of the actually reserved last entry could be overwritten. - On deletion of entries, a corresponding decrement was missing, causing the wrong entry to be marked as free. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann --- target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 1 - target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 1 - 2 files changed, 2 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index fee63c36faa1..a9de70531237 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -987,7 +987,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - mc_group++; // We cannot use group 0, as this is used for lookup miss flooding portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); priv->r->write_mcast_pmask(mc_group, portmask); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index f9980ccacee1..90a6d6766051 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -974,7 +974,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - mc_group++; /* We cannot use group 0, as this is used for lookup miss flooding */ portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); priv->r->write_mcast_pmask(mc_group, portmask); From patchwork Sat May 6 23:05:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1778087 X-Patchwork-Delegate: sander@svanheule.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gvPaHkhS; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=EmaxPs1p; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QDNXX3v1gz214Z for ; Sun, 7 May 2023 09:09:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7baq2K0EN3mfTECBuIfhPumVcTP/EuCWav8Y6U8oV9A=; b=gvPaHkhSfNY/rZ qCDhJYV/Nsu+wzqi2x5xZOJz0hCOMkzFFDj0y96GcPxNgATlFvUzEM2QEJR07RNTJgU81Zwm39Nyo 0dvwwQ927Ogd33TROA/D+Rmtv9h6E5xhGfgcwj/Awi/J8SX/CGU+juEAfAU1uuofus/bW0eq6GUfc e5SazTnT1y5FeojKXP49EtpSe0EoIfLTNkE3Ac8VaImvbJkP4A21N+UuZNjUD4hd0c+mTSDWkrymU 0SU4StuH2zsRnt2MbCGtLYCjJxb+EWGvC6V9GW8Zx7up06PasTusEE/wozsLemFEMCN3tKSJSSZ3f dN6Q7E04Z+mTW/rsXv4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pvQza-00EXMk-21; Sat, 06 May 2023 23:07:06 +0000 Received: from srv4.3e8.eu ([193.25.101.238]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pvQzX-00EXM9-23 for openwrt-devel@lists.openwrt.org; Sat, 06 May 2023 23:07:05 +0000 Received: from localhost.localdomain (p200300c6cf1962a00858ededb4df0c9f.dip0.t-ipconnect.de [IPv6:2003:c6:cf19:62a0:858:eded:b4df:c9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 00D7340CDB; Sun, 7 May 2023 01:06:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1683414370; 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=4WHeLARsyL8JDUN57y+K0BtIVSSPEXVtI3+ztuoaTqM=; b=EmaxPs1piCGJnI6Ay1eNBC/oMpscokINQBarXvkn40PS14cMvZ2iVa81koknDjPMReoGLJ q0Rq9EVMG0OPrnZ6MsPTC4lPZTX5f2e3nWYowpNse/vzH5N3sYwGGO3Jl0MDrq65vkHFwj /vDqLhaFGOozXgnvWoomqV9Z9mqIZP2zKxu9bNGmUy2QZje1dJYLPQCQbHyZWqMoOSUF+Q frcVUwFj1Kwo5m3QuU4UE4I3lNNnK4Nul/tdtWWg+EUM75e6HD6cIvGt7AczAFZB+8Jgyr zokZHgElFheIE/LcoDDHDqltAV4WSb5oFuRiPCv/pyOfWI4yp40yhqA35i31uw== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org, Sander Vanheule Cc: Jan Hoffmann Subject: [PATCH v2 3/6] realtek: actually remove port from multicast portmask Date: Sun, 7 May 2023 01:05:32 +0200 Message-Id: <20230506230535.1150881-4-jan@3e8.eu> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230506230535.1150881-1-jan@3e8.eu> References: <20230506230535.1150881-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230506_160703_841759_7CFEBAFA X-CRM114-Status: UNSURE ( 6.98 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann --- target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 1 [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann --- target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 1 + target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 1 + 2 files changed, 2 insertions(+) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index a9de70531237..79a5c5eea289 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1017,6 +1017,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr pr_info("%s: %d is lag slave. ignore\n", __func__, port); return portmask; } + portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); if (portmask == BIT_ULL(priv->cpu_port)) { portmask &= ~BIT_ULL(priv->cpu_port); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index 90a6d6766051..f3b1cd08acb3 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -1004,6 +1004,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr pr_info("%s: %d is lag slave. ignore\n", __func__, port); return portmask; } + portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); if (portmask == BIT_ULL(priv->cpu_port)) { portmask &= ~BIT_ULL(priv->cpu_port); From patchwork Sat May 6 23:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1778089 X-Patchwork-Delegate: sander@svanheule.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Xo1oFo+R; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=PwBDDIrm; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QDNXX2Wzcz214Y for ; Sun, 7 May 2023 09:08:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XSSlxRnsue83XVSjIFMMSZXwzlcV4cR3A/nPIdvrbL8=; b=Xo1oFo+RIdte/f o+s5YmCtkeKFnVBClYFEKXl9vPOQEqiJKy7rwi1MyPK7AcVaD0nzKZhpk1XgatpGjmCEozc3UAcP4 ymNJFKEKH070HbBO98vaOun4mATkCiPN74nBLd/7vUzmj7m6ZBO/UXrPMiNeRhdj7jQ1iF47ULe+G VHzHwSCsmZz4C+fdmc86rcNCqbpYdjUap7E6FaYwLKQBWH5iuGlKqXk4ha0+qnKtc3+0wBmLM3fBj E5CoxHJvwja99bwUr+85BF0jp9dk4FuIaTs0Eu7fiaO7FK+qKmO+jUEJc0f8henKlMQPCqniflVoJ 8jjZmm0F3bZzZiWbfM0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pvQzl-00EXPG-0I; Sat, 06 May 2023 23:07:17 +0000 Received: from srv4.3e8.eu ([2001:67c:12a0:200::2]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pvQzh-00EXOQ-2E for openwrt-devel@lists.openwrt.org; Sat, 06 May 2023 23:07:15 +0000 Received: from localhost.localdomain (p200300c6cf1962a00858ededb4df0c9f.dip0.t-ipconnect.de [IPv6:2003:c6:cf19:62a0:858:eded:b4df:c9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 2A5CF40D81; Sun, 7 May 2023 01:06:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1683414370; 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=R2fgW0Io8mkKoOYXMpf5M+0CAdnp8fLaTbAxXY8srkM=; b=PwBDDIrmQVfA5kYiAaEcm4lkyDHJ3ybIRAA+7JqAxQJbJTaA155SiU/FIXIqyqB5dR9kDW a0mKZK2ApDj9wA1+HTzUf5pbJd3IkI37Iyr77agOY7s5cFgMweZlTDNl2Hc9agYdHJsMRB OAVEJKMCu3y69IA6LzQ73Kb8EgBxC8a6qC/ydd6Ct2eyFF3redaNEzCGDP5+22qWMjLfJj Ni0KO6NDM8JocJiKJRJtcRPAhuWVwFSz+lUoxgyd2rOuKjFyg8TZzE0tQnTR1gECg0H6bl OQoI9N+m+pcZC6hb/1gvSjZX20RXbFPysG2iA/msiFZL7hWU5Wrvl9IRhrrZGA== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org, Sander Vanheule Cc: Jan Hoffmann Subject: [PATCH v2 4/6] realtek: don't add CPU port to multicast portmasks Date: Sun, 7 May 2023 01:05:33 +0200 Message-Id: <20230506230535.1150881-5-jan@3e8.eu> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230506230535.1150881-1-jan@3e8.eu> References: <20230506230535.1150881-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230506_160713_877318_57E0460B X-CRM114-Status: UNSURE ( 9.63 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: There shouldn't be any reason to forward all multicast to the CPU. The original commit message also doesn't provide a reason for this seemingly unrelated change. The current implementation of the delete method is also broken, as it entirely removes any entry when the portmask contains only the CPU port, even if it was explicitly created. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org There shouldn't be any reason to forward all multicast to the CPU. The original commit message also doesn't provide a reason for this seemingly unrelated change. The current implementation of the delete method is also broken, as it entirely removes any entry when the portmask contains only the CPU port, even if it was explicitly created. Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann --- .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 7 ++----- .../linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 79a5c5eea289..9aaa255d2639 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -987,7 +987,7 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); + portmask = BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); return mc_group; @@ -1019,11 +1019,8 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr } portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); - if (portmask == BIT_ULL(priv->cpu_port)) { - portmask &= ~BIT_ULL(priv->cpu_port); - priv->r->write_mcast_pmask(mc_group, portmask); + if (!portmask) clear_bit(mc_group, priv->mc_group_bm); - } return portmask; } diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index f3b1cd08acb3..f99736af24ee 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -974,7 +974,7 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); + portmask = BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); return mc_group; @@ -1006,11 +1006,8 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr } portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); - if (portmask == BIT_ULL(priv->cpu_port)) { - portmask &= ~BIT_ULL(priv->cpu_port); - priv->r->write_mcast_pmask(mc_group, portmask); + if (!portmask) clear_bit(mc_group, priv->mc_group_bm); - } return portmask; } From patchwork Sat May 6 23:05:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1778090 X-Patchwork-Delegate: sander@svanheule.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=lL9ql/f8; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=KkDjJOLg; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QDNXX1PcLz214V for ; Sun, 7 May 2023 09:09:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9nwAwUFo6lSyCMXzbNlTBts73Rnct3n50FIgKTm5hbA=; b=lL9ql/f8qHkYK+ wGO+Tx/D83R43yOv8Ror+I45riaNlViP1RMUdgCzAV926Y3sM4sUFnJGxI9txcxpw9GgQxfSlycVY gs7JL648e6WEAGuJeNqLpkNlzGur/3lRi87FKSvgxnyafd0GvnubEgvt8II/QvZFLbuA8DgxP88/w B2zEdVTIAe6KVJqdosANpk145FHk//5nnwyK8t5YO7f1/Zp1kLhf8xtr5+MuvLUIWI4s6vBbLW8so JxeUHeA+yY3pTI1JUfJ+5cfSqxQoXYBB6FoYXCUCeJ6a0WoKaf8mR/0dmFaG7R6WwUYweaYZTuSIe J371Nb59nxPr469D6l1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pvQzv-00EXTE-0s; Sat, 06 May 2023 23:07:27 +0000 Received: from srv4.3e8.eu ([2001:67c:12a0:200::2]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pvQzr-00EXRs-2s for openwrt-devel@lists.openwrt.org; Sat, 06 May 2023 23:07:25 +0000 Received: from localhost.localdomain (p200300c6cf1962a00858ededb4df0c9f.dip0.t-ipconnect.de [IPv6:2003:c6:cf19:62a0:858:eded:b4df:c9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 5434A40D9A; Sun, 7 May 2023 01:06:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1683414370; 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=Qs+4gcuazaZY6km9PpawtDkOcQUieP+9I70tOn8jSYs=; b=KkDjJOLg3x2dE8V62yS67WqTqs2HOEHITK9fk9gxujf47kxtcw3H2ncZQhidm9ihngumv4 bGl08n82GhndeoROYyVG0ET6PLwUUE7bArkIqrxqJH/NitsoNIS8618FIV4943Hy3muE1/ T2onlMOxloI9zutcwberfItXzaQfiMlV8eL8vtxhHRJ2/vVIU8f/dfBhrLuYkCpSpo3Cwt ZWpwA1FHVdSwdU14fEzBDRA62tYHnAakg1c8WPH1kZSy7qvxrufR4BOFPkQ8DNVdm91H3Y le7ct/k5y1Tx6gKpATnysdabTFnQhMRKujiGVwEX8R7dfZTIXOzIKDjOYpcn3g== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org, Sander Vanheule Cc: Jan Hoffmann Subject: [PATCH v2 5/6] realtek: remove store_mcgroups/load_mcgroups Date: Sun, 7 May 2023 01:05:34 +0200 Message-Id: <20230506230535.1150881-6-jan@3e8.eu> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230506230535.1150881-1-jan@3e8.eu> References: <20230506230535.1150881-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230506_160724_084666_4CAD2ABA X-CRM114-Status: GOOD ( 13.77 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The current implementation only works when store and load are called for the same port without any other calls in between. This is because the store function only saves a single port number instead of [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The current implementation only works when store and load are called for the same port without any other calls in between. This is because the store function only saves a single port number instead of a portmask for each group. It also doesn't take into account that the allocation of multicast group entries might change between store/load calls. As a result, the multicast port mask table gets corrupted. This also includes the reserved entry for unknown multicast, which gets corrupted even when no other mdb entries have been added. Remove the code for storing/loading multicast groups entirely, as the original commit message doesn't offer a convincing reason why this would be necessary in the first place. Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 30 ------------------- .../drivers/net/dsa/rtl83xx/rtl838x.h | 1 - .../files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 26 ---------------- .../drivers/net/dsa/rtl83xx/rtl838x.h | 1 - 4 files changed, 58 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 9aaa255d2639..7661ecd8f21a 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1025,31 +1025,6 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr return portmask; } -static void store_mcgroups(struct rtl838x_switch_priv *priv, int port) -{ - int mc_group; - - for (mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) { - u64 portmask = priv->r->read_mcast_pmask(mc_group); - if (portmask & BIT_ULL(port)) { - priv->mc_group_saves[mc_group] = port; - rtl83xx_mc_group_del_port(priv, mc_group, port); - } - } -} - -static void load_mcgroups(struct rtl838x_switch_priv *priv, int port) -{ - int mc_group; - - for (mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) { - if (priv->mc_group_saves[mc_group] == port) { - rtl83xx_mc_group_add_port(priv, mc_group, port); - priv->mc_group_saves[mc_group] = -1; - } - } -} - static int rtl83xx_port_enable(struct dsa_switch *ds, int port, struct phy_device *phydev) { @@ -1068,8 +1043,6 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port, /* add port to switch mask of CPU_PORT */ priv->r->traffic_enable(priv->cpu_port, port); - load_mcgroups(priv, port); - if (priv->is_lagmember[port]) { pr_debug("%s: %d is lag slave. ignore\n", __func__, port); return 0; @@ -1105,7 +1078,6 @@ static void rtl83xx_port_disable(struct dsa_switch *ds, int port) // BUG: This does not work on RTL931X /* remove port from switch mask of CPU_PORT */ priv->r->traffic_disable(priv->cpu_port, port); - store_mcgroups(priv, port); /* remove all other ports in the same bridge from switch mask of port */ v = priv->r->traffic_get(port); @@ -1205,7 +1177,6 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port, port_bitmap |= BIT_ULL(i); } } - load_mcgroups(priv, port); /* Add all other ports to this port matrix. */ if (priv->ports[port].enable) { @@ -1246,7 +1217,6 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, port_bitmap &= ~BIT_ULL(i); } } - store_mcgroups(priv, port); /* Add all other ports to this port matrix. */ if (priv->ports[port].enable) { diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h index 19049e4c957a..fc3d3f7b9777 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h @@ -1072,7 +1072,6 @@ struct rtl838x_switch_priv { struct notifier_block fib_nb; bool eee_enabled; unsigned long int mc_group_bm[MAX_MC_GROUPS >> 5]; - int mc_group_saves[MAX_MC_GROUPS]; int n_pie_blocks; struct rhashtable tc_ht; unsigned long int pie_use_bm[MAX_PIE_ENTRIES >> 5]; diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index f99736af24ee..ad2ad6e8f72a 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -1012,27 +1012,6 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr return portmask; } -static void store_mcgroups(struct rtl838x_switch_priv *priv, int port) -{ - for (int mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) { - u64 portmask = priv->r->read_mcast_pmask(mc_group); - if (portmask & BIT_ULL(port)) { - priv->mc_group_saves[mc_group] = port; - rtl83xx_mc_group_del_port(priv, mc_group, port); - } - } -} - -static void load_mcgroups(struct rtl838x_switch_priv *priv, int port) -{ - for (int mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) { - if (priv->mc_group_saves[mc_group] == port) { - rtl83xx_mc_group_add_port(priv, mc_group, port); - priv->mc_group_saves[mc_group] = -1; - } - } -} - static int rtl83xx_port_enable(struct dsa_switch *ds, int port, struct phy_device *phydev) { @@ -1051,8 +1030,6 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port, /* add port to switch mask of CPU_PORT */ priv->r->traffic_enable(priv->cpu_port, port); - load_mcgroups(priv, port); - if (priv->is_lagmember[port]) { pr_debug("%s: %d is lag slave. ignore\n", __func__, port); return 0; @@ -1088,7 +1065,6 @@ static void rtl83xx_port_disable(struct dsa_switch *ds, int port) /* BUG: This does not work on RTL931X */ /* remove port from switch mask of CPU_PORT */ priv->r->traffic_disable(priv->cpu_port, port); - store_mcgroups(priv, port); /* remove all other ports in the same bridge from switch mask of port */ v = priv->r->traffic_get(port); @@ -1190,7 +1166,6 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port, port_bitmap |= BIT_ULL(i); } } - load_mcgroups(priv, port); /* Add all other ports to this port matrix. */ if (priv->ports[port].enable) { @@ -1230,7 +1205,6 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, port_bitmap &= ~BIT_ULL(i); } } - store_mcgroups(priv, port); /* Add all other ports to this port matrix. */ if (priv->ports[port].enable) { diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h index a4bfc285a60c..7053697bd882 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h @@ -1068,7 +1068,6 @@ struct rtl838x_switch_priv { struct notifier_block fib_nb; bool eee_enabled; unsigned long int mc_group_bm[MAX_MC_GROUPS >> 5]; - int mc_group_saves[MAX_MC_GROUPS]; int n_pie_blocks; struct rhashtable tc_ht; unsigned long int pie_use_bm[MAX_PIE_ENTRIES >> 5]; From patchwork Sat May 6 23:05:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1778092 X-Patchwork-Delegate: sander@svanheule.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=AZzVpG96; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=TXuPf3ar; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QDNXb3m8dz214b for ; Sun, 7 May 2023 09:09:03 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iPT2vpRYpFyUC5w7D6dzeUkvu3Lj25zUSTO3myOA1Nw=; b=AZzVpG96xVToVE 7hf1JdsBiVg1teEnjb+zJ6mnJosFv5soSlEXifeoEKsI2PT2iCXyi2lZESfg63bGfxNbLgG7lSrQS yNZEPgOXO3mbh5Mgs0VHuR7ELOLNZiEohxh3QYPlbW+9CTrCG7E/LOLKdjMJvWIVg/u0R3G7TwpgB dfQNdkEJjZOGoFFqggX7EhV0MpOQX5MF+KFFyhtLST3U3XOYAL9GOit20jQypOdfa9UV3kzWU2NkR d//msnV/DHWYGXIruB9EJxTiDR8mW0PlMozGIooJXbMbZhRWbBbylEf1hTviDuYSbo2hmQ4gb9IL3 xMSQA062IbTXGF5m/4vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pvR04-00EXWT-2Q; Sat, 06 May 2023 23:07:36 +0000 Received: from srv4.3e8.eu ([193.25.101.238]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pvR02-00EXVG-0z for openwrt-devel@lists.openwrt.org; Sat, 06 May 2023 23:07:35 +0000 Received: from localhost.localdomain (p200300c6cf1962a00858ededb4df0c9f.dip0.t-ipconnect.de [IPv6:2003:c6:cf19:62a0:858:eded:b4df:c9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 7C9B140D9D; Sun, 7 May 2023 01:06:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1683414370; 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=K3BVtrZhZwKYwwOqJwO1VBPHB3rgDwNOZb479maJJMM=; b=TXuPf3ary4xfxWKMkPdCi/IA9xgwqvuynlIdlIR/+L0sKXUZygOTIqt+bIJRsWCQuJ5r/c KIQGtffGl7+qTL4NtiZl3yZMu+fEZQJ8FEu9k7fVSA6n2dvpFywKb2k/ixnry5A4jarCjO ONm4rEApaup9AKgrIxoXhnb2sNeG4BTj/ymkeccJBA7NzFsNiY9++9f7VT0qgEY00LAi8I s1oMKTmDPSnbDxz+AchuZ3usqejTUr3G+UQV4T+Qx0Zw6jNssi+ttIUp1oXHIE0OeIIVDf B/nSbCiBc9GdDsYJtvd7xBK20hsqO62A5NgrDJIaAYgmTITE8UpHc91vKYxnRA== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org, Sander Vanheule Cc: Jan Hoffmann Subject: [PATCH v2 6/6] realtek: remove redundant is_lagmember checks Date: Sun, 7 May 2023 01:05:35 +0200 Message-Id: <20230506230535.1150881-7-jan@3e8.eu> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230506230535.1150881-1-jan@3e8.eu> References: <20230506230535.1150881-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230506_160734_496656_7BB6225E X-CRM114-Status: UNSURE ( 9.05 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: All callers of the rtl83xx_mc_group_* functions already do the same check, so these aren't needed. For rtl83xx_mc_group_alloc, this branch also incorrectly returned 0 instead of a negative value. If the branch wasn't effectively dead code anyway, this could potentially have caused bugs, as 0 is a v [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org All callers of the rtl83xx_mc_group_* functions already do the same check, so these aren't needed. For rtl83xx_mc_group_alloc, this branch also incorrectly returned 0 instead of a negative value. If the branch wasn't effectively dead code anyway, this could potentially have caused bugs, as 0 is a valid multicast group entry index. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 15 ++------------- .../files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 15 ++------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 7661ecd8f21a..5dd69c8d6541 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -981,11 +981,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) if (mc_group >= MAX_MC_GROUPS - 1) return -1; - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return 0; - } - set_bit(mc_group, priv->mc_group_bm); portmask = BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -998,10 +993,7 @@ static u64 rtl83xx_mc_group_add_port(struct rtl838x_switch_priv *priv, int mc_gr u64 portmask = priv->r->read_mcast_pmask(mc_group); pr_debug("%s: %d\n", __func__, port); - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return portmask; - } + portmask |= BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -1013,10 +1005,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr u64 portmask = priv->r->read_mcast_pmask(mc_group); pr_debug("%s: %d\n", __func__, port); - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return portmask; - } + portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); if (!portmask) diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index ad2ad6e8f72a..b6a21f611fdf 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -968,11 +968,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) if (mc_group >= MAX_MC_GROUPS - 1) return -1; - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return 0; - } - set_bit(mc_group, priv->mc_group_bm); portmask = BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -985,10 +980,7 @@ static u64 rtl83xx_mc_group_add_port(struct rtl838x_switch_priv *priv, int mc_gr u64 portmask = priv->r->read_mcast_pmask(mc_group); pr_debug("%s: %d\n", __func__, port); - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return portmask; - } + portmask |= BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -1000,10 +992,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr u64 portmask = priv->r->read_mcast_pmask(mc_group); pr_debug("%s: %d\n", __func__, port); - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return portmask; - } + portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); if (!portmask)