From patchwork Tue Apr 19 08:14:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 12817589 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 330F5C433FE for ; Tue, 19 Apr 2022 08:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349912AbiDSIS6 (ORCPT ); Tue, 19 Apr 2022 04:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349954AbiDSISQ (ORCPT ); Tue, 19 Apr 2022 04:18:16 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DDE8E0AD for ; Tue, 19 Apr 2022 01:15:18 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id n8so14714909plh.1 for ; Tue, 19 Apr 2022 01:15:18 -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:in-reply-to:references :mime-version; bh=Dv/gjXAbHV0aJeQBkiI22YJ46DKVdZ4jwHxAeGQVUnQ=; b=BxSYF11IfOsPy2aX6brnnZTp78qxq6jBDkOUxf7o/SLP4FGjRCuzQ9E4lOdnQiPbwo EXvmXrlVDnZXtAFWVGi9+E2uxOUGLwPYvrdpr0m276U62nkJF3g/iZQx8jn8fK3K0WK3 YmaiOqDSOZnej4dsQ3+sS78mW5pMVXlksoze0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=Dv/gjXAbHV0aJeQBkiI22YJ46DKVdZ4jwHxAeGQVUnQ=; b=lL1blnQ0lbyxCy616N4Ji8pNiu8i8aonrpDIF8pW7j2fhPRbie45O6eznMwUXLb4jd EAZJszcSCyAuUX5GrbwBHuI9le//2pf58cfbCSkbLu82xw5MZkU9oHnnDdxS6O3kkL7c AUz0xju74hdRzNwa+nSK4bDcHi1e5G1xRH3nlqKr1Vm0uW/pZrpq1a63fWSGOK69r0RF CMLhogrYfPTKg9YuHMYq4JksK/Wx7MLb7ZqaTiiiXR32Y/xl8EtAqgk79u7+qp1Klse8 kMWgFU1utSTTpthhqqZCyAAEBPf2NnK4o2stzb0t0C9lFIzWpLTf8tOKLCfApY/JdlWV mc4w== X-Gm-Message-State: AOAM532GO+S9Fmt5xTttug1xv4rCV5/+4uCOa+UsZFvNEDrYHSQHhIt7 zuPfeWwfQTuGL9LLP5pzM2QT+jI7jp3s/1qBWm4+s8+57kD69l8rLsbSKXN9FzevT9NclB3tNYV 32T2qnZ3AHuePBN5Fso7Ds6XnGgWU+sF3GNT6pgLn+3nYxX7lhDql0n59HRhO8FAONcZXyG2oOx uJek/lj05QtA== X-Google-Smtp-Source: ABdhPJziwPmH9ZaxQXiXWDc6OwqlvrnevXdrDqFwdezfT3TrQcKSqxMyaR4qCRG8iyOU8Iejn4ZHOQ== X-Received: by 2002:a17:902:7088:b0:156:1aa9:79eb with SMTP id z8-20020a170902708800b001561aa979ebmr14568780plk.71.1650356117575; Tue, 19 Apr 2022 01:15:17 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id cp19-20020a056a00349300b0050a890c8c16sm4284570pfb.19.2022.04.19.01.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 01:15:17 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "Gustavo A . R . Silva" , Vladimir Oltean , Eric Dumazet , zhang kai , Yoshiki Komachi , Paolo Abeni Cc: Ilya Lifshits , Boris Sukholitko Subject: [PATCH net-next v4 4/5] net/sched: flower: Add number of vlan tags filter Date: Tue, 19 Apr 2022 11:14:33 +0300 Message-Id: <20220419081434.5192-5-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220419081434.5192-1-boris.sukholitko@broadcom.com> References: <20220419081434.5192-1-boris.sukholitko@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These are bookkeeping parts of the new num_of_vlans filter. Defines, dump, load and set are being done here. Signed-off-by: Boris Sukholitko --- include/uapi/linux/pkt_cls.h | 2 ++ net/sched/cls_flower.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 404f97fb239c..9a2ee1e39fad 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -587,6 +587,8 @@ enum { TCA_FLOWER_KEY_HASH, /* u32 */ TCA_FLOWER_KEY_HASH_MASK, /* u32 */ + TCA_FLOWER_KEY_NUM_OF_VLANS, /* u8 */ + __TCA_FLOWER_MAX, }; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 86fd0420ac4f..4ec4d742e82f 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -72,6 +72,7 @@ struct fl_flow_key { } tp_range; struct flow_dissector_key_ct ct; struct flow_dissector_key_hash hash; + struct flow_dissector_key_num_of_vlans num_of_vlans; } __aligned(BITS_PER_LONG / 8); /* Ensure that we can do comparisons as longs. */ struct fl_flow_mask_range { @@ -712,6 +713,7 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = { [TCA_FLOWER_FLAGS] = { .type = NLA_U32 }, [TCA_FLOWER_KEY_HASH] = { .type = NLA_U32 }, [TCA_FLOWER_KEY_HASH_MASK] = { .type = NLA_U32 }, + [TCA_FLOWER_KEY_NUM_OF_VLANS] = { .type = NLA_U8 }, }; @@ -1615,6 +1617,11 @@ static int fl_set_key(struct net *net, struct nlattr **tb, fl_set_key_val(tb, key->eth.src, TCA_FLOWER_KEY_ETH_SRC, mask->eth.src, TCA_FLOWER_KEY_ETH_SRC_MASK, sizeof(key->eth.src)); + fl_set_key_val(tb, &key->num_of_vlans, + TCA_FLOWER_KEY_NUM_OF_VLANS, + &mask->num_of_vlans, + TCA_FLOWER_UNSPEC, + sizeof(key->num_of_vlans)); if (is_vlan_key(tb[TCA_FLOWER_KEY_ETH_TYPE], ðertype, key, mask)) { fl_set_key_vlan(tb, ethertype, TCA_FLOWER_KEY_VLAN_ID, @@ -1906,6 +1913,8 @@ static void fl_init_dissector(struct flow_dissector *dissector, FLOW_DISSECTOR_KEY_CT, ct); FL_KEY_SET_IF_MASKED(mask, keys, cnt, FLOW_DISSECTOR_KEY_HASH, hash); + FL_KEY_SET_IF_MASKED(mask, keys, cnt, + FLOW_DISSECTOR_KEY_NUM_OF_VLANS, num_of_vlans); skb_flow_dissector_init(dissector, keys, cnt); } @@ -2994,6 +3003,11 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net, sizeof(key->basic.n_proto))) goto nla_put_failure; + if (mask->num_of_vlans.num_of_vlans) { + if (nla_put_u8(skb, TCA_FLOWER_KEY_NUM_OF_VLANS, key->num_of_vlans.num_of_vlans)) + goto nla_put_failure; + } + if (fl_dump_key_mpls(skb, &key->mpls, &mask->mpls)) goto nla_put_failure;