From patchwork Sat Oct 22 07:22:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1092873wrr; Sat, 22 Oct 2022 00:55:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4k2MXwDlsLL962cXazP3+ImzMp5BXPbLD0nONX/EjYVBsz2SKxpjoBwu5xL3Ri+r6dhJq+ X-Received: by 2002:a05:6a00:174a:b0:562:781f:eca3 with SMTP id j10-20020a056a00174a00b00562781feca3mr22773518pfc.41.1666425325578; Sat, 22 Oct 2022 00:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425325; cv=none; d=google.com; s=arc-20160816; b=zrPFvNDcGXdSojg70T01IA23q9wlrKzqJXcdyUjpMFQOzsmZfntrb8pbUtLMgxv2CM 2/Xx/aoMrAY40nPAZ4WtrGsvYdMYY5YYUKJGwXRbzfL+oN+xtrzaRy2WuiP0l6awvW1f ctokS9+YaeTN7PWeM6D+QfX4r25DPETIhZm8ZB0jECPjdjkqb2X2K/YOnzyKFQLhx0fe Tlwkxs8uQzCtTcoQ6b5YgLdus64psL8bCjYLMhfr9lJjV6kpRe09akh+rD/lT/OjIkoL NokmQK3NSvM3tz1sy0G6U/fn1/gAwDwphQhTnGD2wxjEzr4t74S0PdwyrA5QwVJWaPKc P01g== 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=Bvxej/lvKFn6NJWJBgeNiVG/Jbo9SQ0H95FOpaNbiVI=; b=cOHxQAqHdlfr1qqj2U8TotG8JzpS5QOIxQFuKwwi2tNByQ6ewL6ecxTtJ8LAy/gzTm F1VZGI5ZCDej9rmio8QqrYhV9hvJsroaX60o8HfAN4GfxUeezJsIZB7m/D14niSsgYRf jvRPSBWrVc04gGLA45FWlRyMfwvainRCQ7IbxcKr+3WXpfGFYTqdlwP7KivdMmO6QVd6 xKTxqVTqTvQpRNZMMwx7F6DAb5CnqXHnBSEw/BKoFFrm4Pk3mscddkTxlqNH0dIlijv/ ztArgzE7+XtEYfVd+lKQNX+Yjslcupk5343qlYpwYCRTGgpJ5ClUxKyNmT1h8Tvi/EIT zx4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yauzaur7; 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 y7-20020a17090a784700b00212eb5485afsi414769pjl.77.2022.10.22.00.55.12; Sat, 22 Oct 2022 00:55:25 -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=yauzaur7; 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 S232070AbiJVHx4 (ORCPT + 99 others); Sat, 22 Oct 2022 03:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbiJVHvs (ORCPT ); Sat, 22 Oct 2022 03:51:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C65842C6E9D; Sat, 22 Oct 2022 00:46:42 -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 3186CB82E19; Sat, 22 Oct 2022 07:45:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E939C433C1; Sat, 22 Oct 2022 07:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424742; bh=/RIb42wHw1L9PcyyDmOwf1FOxZOlDFzTAebjEtF6xrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yauzaur7HEp3lYwooJuMt0aNocmn6yzuz/KQ/yCrWsIx98dAL2ASJLDFqVgkHMxMI LcBPUBbLzvdFg2Gnc2DTx0s5xRddmirzwUH07018Xfia3anfpkELFKoJzXbhWcy3/o WNuFEAUn3Dq/jkxejiDemWs8TwJReUhOdyDuWlFM= 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 5.19 258/717] flow_dissector: Do not count vlan tags inside tunnel payload Date: Sat, 22 Oct 2022 09:22:17 +0200 Message-Id: <20221022072500.377801790@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373602547669739?= X-GMAIL-MSGID: =?utf-8?q?1747373602547669739?= 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 bcba61ef5b37..ac6360433003 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1168,8 +1168,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,