From patchwork Wed Oct 19 08:26:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp213304wrs; Wed, 19 Oct 2022 02:09:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pZIsQMGyVzpZsXBfi3u2LuLshqYyQtmxRtf/6ARSwAbmNp8TVHyIqDAdvKP1D+9FqOGs2 X-Received: by 2002:a17:906:5a4b:b0:78d:8790:d4a1 with SMTP id my11-20020a1709065a4b00b0078d8790d4a1mr5847757ejc.329.1666170583235; Wed, 19 Oct 2022 02:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170583; cv=none; d=google.com; s=arc-20160816; b=zOkwndLBdGWTWuAteqMKWeHjF4F4zjE5Yk6HANCoqOGNHGbgoYRI9v7W4bd+uqEgdK BIgRXPF+BeoxLB7hVSFZ1kkLsQewLc954aTuZgseoEy/qiSozV5qQCwRR0US0k3CnzPg dDsBvRsY5y6nT4VH7z7f3fF9Etn/c7NO7QtREk7Ke/T/SnYIw27Fty66vj95pFohWqfK 0ru2c83NuiVVz2FESrAHAh1wKQDM1ySC8TUC780kGYpEKKweX3QsCkm9EO/kNY1CLkrK BE10QmWT6R91qqEAhDvv7IBUyBDVP3/qFsJm9ydcWY2Cs2nmVOMIPejrdCXm4lvjy90X T+1A== 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=NaJa3SgGdlrdmi7o/e+AsEyVY3xUf1e7eJ44Gj6LJTQ=; b=N5Ris3XDPGP4PydlDieGTuAaS25XmzflAxPPzdvYKH5kx9i3SRSUvufR0p7JiPlzgh 7spFnLneE2ZCcU+7mIKWyiSC/ZjkU3hNhpjVFma/l7qY/n7ogI8+50ps1kUydlXX9s5s q42rXUze9/7mpBCLPyc7EE1ETeyGJr4ZsZ8j5UADh1xwoMVbbWalU1RH1xHin1Nzg9sg gYOU7idU+uDxY4r3UbLEsA0ahaJK6NbpCvya4ePAN5OsQkMdbHOU34FmKBFC7mWDWSgH I9zfHUdsFTTVIoc24WB/d33imzqOuMFkZTkFUeVgTlSTDN/ELlRYryEvraf/FsR6+mSs 9G3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="fS2O/jUc"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg20-20020a170907a41400b007918f4994f4si9092277ejc.15.2022.10.19.02.09.17; Wed, 19 Oct 2022 02:09:43 -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="fS2O/jUc"; 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 S232356AbiJSJFm (ORCPT + 99 others); Wed, 19 Oct 2022 05:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232390AbiJSJEI (ORCPT ); Wed, 19 Oct 2022 05:04:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5275F2E690; Wed, 19 Oct 2022 01:57:10 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 3775F6187A; Wed, 19 Oct 2022 08:53:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48B5FC43144; Wed, 19 Oct 2022 08:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169587; bh=EtP+T23VdFQowWwzjB9/ws5vszh9Tjc6/grKZe9yz5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fS2O/jUcYY6x53pERcsiL5Z/V6Q2Nv9OXf7guhNIZeyOrUYb5XQzVcuLitiPA7pKF YmD+69G/2GDu1NIVBhOfiKcA0PNvAeRRZJGDAbNUi2FFvh2rQAQFLwM7RrMKhDSWdH QauLr4T3AkDVOIkwQB2MTYddHWQ9dFG6kQ5hGleQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qingqing Yang , Boris Sukholitko , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.0 305/862] flow_dissector: Do not count vlan tags inside tunnel payload Date: Wed, 19 Oct 2022 10:26:32 +0200 Message-Id: <20221019083303.487021389@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747106485708865086?= X-GMAIL-MSGID: =?utf-8?q?1747106485708865086?= From: Qingqing Yang [ Upstream commit 9f87eb4246994e32a4e4ea88476b20ab3b412840 ] We've met the problem that when there is a vlan tag inside GRE encapsulation, the match of num_of_vlans fails. It is caused by the vlan tag inside GRE payload has been counted into num_of_vlans, which is not expected. One example packet is like this: Ethernet II, Src: Broadcom_68:56:07 (00:10:18:68:56:07) Dst: Broadcom_68:56:08 (00:10:18:68:56:08) 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 100 Internet Protocol Version 4, Src: 192.168.1.4, Dst: 192.168.1.200 Generic Routing Encapsulation (Transparent Ethernet bridging) Ethernet II, Src: Broadcom_68:58:07 (00:10:18:68:58:07) Dst: Broadcom_68:58:08 (00:10:18:68:58:08) 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 200 ... It should match the (num_of_vlans 1) rule, but it matches the (num_of_vlans 2) rule. The vlan tags inside the GRE or other tunnel encapsulated payload should not be taken into num_of_vlans. The fix is to stop counting the vlan number when the encapsulation bit is set. Fixes: 34951fcf26c5 ("flow_dissector: Add number of vlan tags dissector") Signed-off-by: Qingqing Yang Reviewed-by: Boris Sukholitko Link: https://lore.kernel.org/r/20220919074808.136640-1-qingqing.yang@broadcom.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/core/flow_dissector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 5dc3860e9fc7..7105529abb0f 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1173,8 +1173,8 @@ bool __skb_flow_dissect(const struct net *net, nhoff += sizeof(*vlan); } - if (dissector_uses_key(flow_dissector, - FLOW_DISSECTOR_KEY_NUM_OF_VLANS)) { + if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_NUM_OF_VLANS) && + !(key_control->flags & FLOW_DIS_ENCAPSULATION)) { struct flow_dissector_key_num_of_vlans *key_nvs; key_nvs = skb_flow_dissector_target(flow_dissector,