Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3772903pxt; Tue, 10 Aug 2021 11:00:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFQzUJ46V0b/XWEERfPiFEXZCXKBYPtE2iLbMdOUbwjpeWQ3t6SGz1b7jKr0jKzYrU2c79 X-Received: by 2002:a17:906:fb09:: with SMTP id lz9mr13688439ejb.123.1628618404362; Tue, 10 Aug 2021 11:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628618404; cv=none; d=google.com; s=arc-20160816; b=cHNbuw/qJ9Zw3zUfSkUAyk2hqZqNKLlFEeUD3QIjDghOqZ4cpXY58DJUK4M699qOck ib1X7SyeFZJmd5Th2jMZ/iCj5omlXrczguTvukb1iBeCbu4vtseHR/u08fhJoBHtYBMK xqEFqsRBQ112jBTEuLbBIxx+33GcNLM6jzP/bZSKOJp1SD74ZSdAehYRo0JkqxI+CRbF xIa5BWJoHmrUKjSL5u+MvaI2eO7sczkoY4ZPe0V30jGDWnyXlDc23X7S2sLePQQpY28j 9YBdSnqzymhtQh+6dyrThu+HDazd8+wW09gE2SHUeU9HodzJRyxNAatXQ3QJkvo4V3ZV YGow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IRyuWwRgQNcwClAwLLLh6PcA1mvn1MRJgs5amGdjLMI=; b=CmnLtHdKo4f0yCHU/lkqcKK5rMngmkHp6LSqJgtQb5bQsQSNIYUgBI+yaPnNNB0dyp cp09iTwxqsYTRdN7PFAMJUXdV2Ak1CNpQv7RgoQAS2P3zwIpwudWKdACDBan9qI3GX6Y NpJ6hf9A/qd3a02YmRthQP5laqW6rXr61i81nb+VuyrlPr/5pGFgzJc1ifCxHQS3HyBL cgrcEjkkWsLvXodF+LySvkNIyre19EGI2b2Qu8j7mLg6UAFGoqm+iFPq45uL/2lFVcRK VI72fLKDAywAVX7vIEfC21ErSBDQvQfel5BB4dg+B8Q0C356+gDDDlD1PlwCpTNA1Mkm P8hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=va314uVP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si16994354ede.355.2021.08.10.10.59.38; Tue, 10 Aug 2021 11:00:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=va314uVP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236832AbhHJRzq (ORCPT + 99 others); Tue, 10 Aug 2021 13:55:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:50374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235073AbhHJRwX (ORCPT ); Tue, 10 Aug 2021 13:52:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4564D6128C; Tue, 10 Aug 2021 17:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617401; bh=1FUdKICor+Mn+DvDtJsxVUxXx0H8Pf0AYLAO4DR84xE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=va314uVPYeO8LkTBYWp2qqfu8rd6Vdwz7KG00bHeovWnDcjhezX2JIwk35DL9lj9U K5TMkiGOJdjhJoFoaHqQOvSi44pXToBZfSWkgYXR1bzlfG+UnTYZnwTc6bMbhCh8P0 TY1fzwW24YctAYbvLkydmQkhN1XFHvydQ2YLnUkM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.13 043/175] net: dsa: sja1105: ignore the FDB entry for unknown multicast when adding a new address Date: Tue, 10 Aug 2021 19:29:11 +0200 Message-Id: <20210810173002.367399861@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810173000.928681411@linuxfoundation.org> References: <20210810173000.928681411@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit 728db843df88753aeb7224314807a203afa8eb32 ] Currently, when sja1105pqrs_fdb_add() is called for a host-joined IPv6 MDB entry such as 33:33:00:00:00:6a, the search for that address will return the FDB entry for SJA1105_UNKNOWN_MULTICAST, which has a destination MAC of 01:00:00:00:00:00 and a mask of 01:00:00:00:00:00. It returns that entry because, well, it matches, in the sense that unknown multicast is supposed by design to match it... But the issue is that we then proceed to overwrite this entry with the one for our precise host-joined multicast address, and the unknown multicast entry is no longer there - unknown multicast is now flooded to the same group of ports as broadcast, which does not look up the FDB. To solve this problem, we should ignore searches that return the unknown multicast address as the match, and treat them as "no match" which will result in the entry being installed to hardware. For this to work properly, we need to put the result of the FDB search in a temporary variable in order to avoid overwriting the l2_lookup entry we want to program. The l2_lookup entry returned by the search might not have the same set of DESTPORTS and not even the same MACADDR as the entry we're trying to add. Fixes: 4d9423549501 ("net: dsa: sja1105: offload bridge port flags to device") Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/sja1105/sja1105_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 5e88632e10b9..edc9462c6d4e 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1446,14 +1446,19 @@ int sja1105pqrs_fdb_add(struct dsa_switch *ds, int port, } l2_lookup.destports = BIT(port); + tmp = l2_lookup; + rc = sja1105_dynamic_config_read(priv, BLK_IDX_L2_LOOKUP, - SJA1105_SEARCH, &l2_lookup); - if (rc == 0) { + SJA1105_SEARCH, &tmp); + if (rc == 0 && tmp.index != SJA1105_MAX_L2_LOOKUP_COUNT - 1) { /* Found a static entry and this port is already in the entry's * port mask => job done */ - if ((l2_lookup.destports & BIT(port)) && l2_lookup.lockeds) + if ((tmp.destports & BIT(port)) && tmp.lockeds) return 0; + + l2_lookup = tmp; + /* l2_lookup.index is populated by the switch in case it * found something. */ -- 2.30.2