From patchwork Mon Jun 14 11:13:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 460154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_NO_TEXT, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72880C49EBB for ; Mon, 14 Jun 2021 11:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59691610A2 for ; Mon, 14 Jun 2021 11:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234380AbhFNLUq (ORCPT ); Mon, 14 Jun 2021 07:20:46 -0400 Received: from mail-pj1-f46.google.com ([209.85.216.46]:55895 "EHLO mail-pj1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235274AbhFNLR1 (ORCPT ); Mon, 14 Jun 2021 07:17:27 -0400 Received: by mail-pj1-f46.google.com with SMTP id k7so9503782pjf.5 for ; Mon, 14 Jun 2021 04:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:mime-version; bh=4mEPM/hkZyhpjS71lvgPrA6xJGFWf93wJ5GIjqE+KcQ=; b=TfM4jnhGMIHtBkOLxTNQBB6gpvXyut85Nr0qroG2RtYEZd0yqMuRWt6hcX+wCDuVAQ nblaGX+3LDB13ExqYmrNGOZY3GzajUh61eVPEMFRu12cojbM9K9wcVoG55kSoO9RcGuf yI3cM0bFFCIdhKSzs5+xnO/7FmrH+8lCOJYUQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=4mEPM/hkZyhpjS71lvgPrA6xJGFWf93wJ5GIjqE+KcQ=; b=nLFn7qpNRFRMhsx7o2JPsV2usyq02OyInysb26DnLzwptTkaIVDeVMNNQMSMbyHrYc s7zX1B+BPBuH/gUt9YADrb4j8J0MDoMn5AxSYVLEZOA0gTExTYAB9h0/UhCPiCpNKKAW ltWcAN6fSvSKfoOuQMU3dQPyJd2N8TgYu0KcUT+zj0HEK3iEdhJlXfOopX4uKtAE07Z3 WJHoYVNzEzR9Cw7mosTJO7N86e5gydo2qZnZ4TFRkYZ8QlOYu+j1v+uUlZVKXkKtcijj v68STv1eDpmYLNjQdTkX+Voq2p4GIo4wbWjCbaQrw2JvHrLnvkUOtuLSOu1o5GyXw5UO 0Y5Q== X-Gm-Message-State: AOAM533Dlnn0lkkhKEJRuqt9J6qOIGW4YStYbcd33HjyPS1urInMfCWM 7GzIQRwU23sTNkQdvWXuO4yzidYc8uOOVeGheM4MA3J4jFoB1UzXTj4I37iDf5M7mqNv7/TH6sq 2cJsfDhYDbehSPbrYwgKUiVcPvxkQbLEVFRMBecZxsbffHGBWuxTXV3/lGXyt4RC0LBSKjLJdcW bP6J5M X-Google-Smtp-Source: ABdhPJwyA5klQ8PeHPVRtr47VLREE2CEx6oc0/WUXigoIe4LJp/LSJH1nQnsU2u4I3E3TgtozjH0Bw== X-Received: by 2002:a17:90a:af90:: with SMTP id w16mr7778883pjq.129.1623669264225; Mon, 14 Jun 2021 04:14:24 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id q9sm8850226pjd.9.2021.06.14.04.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 04:14:23 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, Jamal Hadi Salim , Jiri Pirko , Cong Wang Cc: "David S . Miller" , Jakub Kicinski , Ilya Lifshits , Boris Sukholitko Subject: [PATCH net-next] net/sched: cls_flower: Remove match on n_proto Date: Mon, 14 Jun 2021 14:13:22 +0300 Message-Id: <20210614111322.26914-1-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.29.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The following flower filters fail to match packets: tc filter add dev eth0 ingress protocol 0x8864 flower \ action simple sdata hi64 tc filter add dev eth0 ingress protocol 802.1q flower \ vlan_ethtype 0x8864 action simple sdata "hi vlan" The protocol 0x8864 (ETH_P_PPP_SES) is a tunnel protocol. As such, it is being dissected by __skb_flow_dissect and it's internal protocol is being set as key->basic.n_proto. IOW, the existence of ETH_P_PPP_SES tunnel is transparent to the callers of __skb_flow_dissect. OTOH, in the filters above, cls_flower configures its key->basic.n_proto to the ETH_P_PPP_SES value configured by the user. Matching on this key fails because of __skb_flow_dissect "transparency" mentioned above. In the following, I would argue that the problem lies with cls_flower, unnessary attempting key->basic.n_proto match. There are 3 close places in fl_set_key in cls_flower setting up mask->basic.n_proto. They are (in reverse order of appearance in the code) due to: (a) No vlan is given: use TCA_FLOWER_KEY_ETH_TYPE parameter (b) One vlan tag is given: use TCA_FLOWER_KEY_VLAN_ETH_TYPE (c) Two vlans are given: use TCA_FLOWER_KEY_CVLAN_ETH_TYPE The match in case (a) is unneeded because flower has no its own eth_type parameter. It was removed by Jamal Hadi Salim in commit 488b41d020fb06428b90289f70a41210718f52b7 in iproute2. For TCA_FLOWER_KEY_ETH_TYPE the userspace uses the generic tc filter protocol field. Therefore the match for the case (a) is done by tc itself. The matches in cases (b), (c) are unneeded because the protocol will appear in and will be matched by flow_dissector_key_vlan.vlan_tpid. Therefore in the best case, key->basic.n_proto will try to repeat vlan key match again. The below patch removes mask->basic.n_proto setting and resets it to 0 in case (c). Signed-off-by: Boris Sukholitko --- net/sched/cls_flower.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index d7869a984881..2e704c7a105a 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1531,14 +1531,13 @@ static int fl_set_key(struct net *net, struct nlattr **tb, &mask->basic.n_proto, TCA_FLOWER_UNSPEC, sizeof(key->basic.n_proto)); + mask->basic.n_proto = cpu_to_be16(0); } else { key->basic.n_proto = ethertype; - mask->basic.n_proto = cpu_to_be16(~0); } } } else { key->basic.n_proto = ethertype; - mask->basic.n_proto = cpu_to_be16(~0); } }