Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3361111iob; Mon, 16 May 2022 20:39:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnSMSn74npLAA+faV8jAvkQz3qtKfLtRkE+6sk9PN9qFQv3RqWk7mP5po2hrtMhzHl8qA9 X-Received: by 2002:a17:906:7d5:b0:6f3:a6a5:28c6 with SMTP id m21-20020a17090607d500b006f3a6a528c6mr18548272ejc.11.1652758798290; Mon, 16 May 2022 20:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652758798; cv=none; d=google.com; s=arc-20160816; b=W1coy8N68YIJ4h6uwhRcYnawODNNvFeii2fmgjtL3WhA9IPKASW8ElWTyPHCrSqcGf eN1tDRNKlE1aiNjSlkFPCGQPQK+vrVErSI48odyUO8uVuEBjHLJGwSICYUlrgjj3H8b9 ns2Rd2S+r5LFReVC10+WWCCiIuwytK0H6bXpae7ul66ALaR4TU59VneH1SMi7jIQ346n 16hX5xoUxitsmnHm6u4dDWRQAevUK5Q4pb0Z0sKyvP7qv9NxY6vWQfZBrCKaYAnkvR++ WnnO2OQi8DrTsqjgymEGgO0ZIhAThY6Uzz3oIaOaUibS1V+CoU/PFe8BzSzUdxBWM5sn 8s3g== 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=T/PbyA6WvlZ92F+K+rJp3gp1oUXO446ewzVFBk4O2WE=; b=O6ZwaepsVj454Bt5NRy5v2+rtrlSj/Mpye6Gin9M4XaXfmiXca/KzeJXFN7VvNUvJ7 tVotgxyaX2tWZb2uAj23tGbnrcx9ec35czgoTnANbBsBOuBoHrVkhrgg5BbMroTTLaEl Kc3mIHW+FFBePWwWzy/stNItjYYjGuteJa95HCCBsDoqHvvT8TTKLCDPVeZD8oZmLjdG PAhi8tsCRdVxDV386225GeWjLFKJZPYljbcHKilhPgUhTz9CS2/yX6xhL+p7ykj7ihy7 QR6AJeMIxzWI2ckK8xixPAQ5F08xoRXPq8RDhaKI2fnlzFnQ7NLv2MUlQpOhH7s5iSLl So1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EAAyZOnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a056402351000b00425e87ced9esi13819572edd.512.2022.05.16.20.39.33; Mon, 16 May 2022 20:39:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EAAyZOnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1349479AbiEPUii (ORCPT + 99 others); Mon, 16 May 2022 16:38:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350558AbiEPUBV (ORCPT ); Mon, 16 May 2022 16:01:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E84234A931; Mon, 16 May 2022 12:55:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 88FADB81613; Mon, 16 May 2022 19:55:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D80B8C385AA; Mon, 16 May 2022 19:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730919; bh=8F2+mQuyKJsVZ+YRZ5vP0LDsn3RVwXnNtAs05DEbjno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EAAyZOnK5AsOW70mVs1STXGYyHWK5cd3Jr45eKIGzNB2RssBpey0ZvAaglPYZDOnx 0lPkeensYLB2xOq1sxrrSlLrjqyfmlzwUoFN3k0Zo6eDgpeUCUtZlcH5W1padPt9rw LtXs51LL3HhbrYM140tN+nb2dAeW3bx0oGynlGSk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 008/114] net: mscc: ocelot: fix VCAP IS2 filters matching on both lookups Date: Mon, 16 May 2022 21:35:42 +0200 Message-Id: <20220516193625.736092657@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193625.489108457@linuxfoundation.org> References: <20220516193625.489108457@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit 6741e11880003e35802d78cc58035057934f4dab ] The VCAP IS2 TCAM is looked up twice per packet, and each filter can be configured to only match during the first, second lookup, or both, or none. The blamed commit wrote the code for making VCAP IS2 filters match only on the given lookup. But right below that code, there was another line that explicitly made the lookup a "don't care", and this is overwriting the lookup we've selected. So the code had no effect. Some of the more noticeable effects of having filters match on both lookups: - in "tc -s filter show dev swp0 ingress", we see each packet matching a VCAP IS2 filter counted twice. This throws off scripts such as tools/testing/selftests/net/forwarding/tc_actions.sh and makes them fail. - a "tc-drop" action offloaded to VCAP IS2 needs a policer as well, because once the CPU port becomes a member of the destination port mask of a packet, nothing removes it, not even a PERMIT/DENY mask mode with a port mask of 0. But VCAP IS2 rules with the POLICE_ENA bit in the action vector can only appear in the first lookup. What happens when a filter matches both lookups is that the action vector is combined, and this makes the POLICE_ENA bit ineffective, since the last lookup in which it has appeared is the second one. In other words, "tc-drop" actions do not drop packets for the CPU port, dropped packets are still seen by software unless there was an FDB entry that directed those packets to some other place different from the CPU. The last bit used to work, because in the initial commit b596229448dd ("net: mscc: ocelot: Add support for tcam"), we were writing the FIRST field of the VCAP IS2 half key with a 1, not with a "don't care". The change to "don't care" was made inadvertently by me in commit c1c3993edb7c ("net: mscc: ocelot: generalize existing code for VCAP"), which I just realized, and which needs a separate fix from this one, for "stable" kernels that lack the commit blamed below. Fixes: 226e9cd82a96 ("net: mscc: ocelot: only install TCAM entries into a specific lookup and PAG") Signed-off-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/mscc/ocelot_vcap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.c b/drivers/net/ethernet/mscc/ocelot_vcap.c index e650afef12af..6c643936c675 100644 --- a/drivers/net/ethernet/mscc/ocelot_vcap.c +++ b/drivers/net/ethernet/mscc/ocelot_vcap.c @@ -373,7 +373,6 @@ static void is2_entry_set(struct ocelot *ocelot, int ix, OCELOT_VCAP_BIT_0); vcap_key_set(vcap, &data, VCAP_IS2_HK_IGR_PORT_MASK, 0, ~filter->ingress_port_mask); - vcap_key_bit_set(vcap, &data, VCAP_IS2_HK_FIRST, OCELOT_VCAP_BIT_ANY); vcap_key_bit_set(vcap, &data, VCAP_IS2_HK_HOST_MATCH, OCELOT_VCAP_BIT_ANY); vcap_key_bit_set(vcap, &data, VCAP_IS2_HK_L2_MC, filter->dmac_mc); -- 2.35.1