From patchwork Tue Apr 12 10:02:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 12810514 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 D87C6C433F5 for ; Tue, 12 Apr 2022 11:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243582AbiDLLTR (ORCPT ); Tue, 12 Apr 2022 07:19:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244144AbiDLLPh (ORCPT ); Tue, 12 Apr 2022 07:15:37 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE99F97284 for ; Tue, 12 Apr 2022 03:03:24 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id e8-20020a17090a118800b001cb13402ea2so2430633pja.0 for ; Tue, 12 Apr 2022 03:03:24 -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=jOJGBqZEtyYsHkVJQZiFwNhz1g9+NKml4SymNE647KM=; b=cDvMf/anklz/UYVLF5/+HSj8O2C4ypnVWt8GEnQcq+l/QIk7GERExDGaEAaFYP7NXX AdIFXxWFIvtIJ/lZJ3S4/TX+VEyh3zDlLNq+y3X6YOmu8ntvGMK/RLVVMf4iFPgnabr4 BhWVROlaR+MpRt77x9nBSw+HbN4hzT6KMj2Go= 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=jOJGBqZEtyYsHkVJQZiFwNhz1g9+NKml4SymNE647KM=; b=TokVWoCDsJg1nXTPnf3O4nE0cA9SazqMsA6RxisyRpF1GuIfpQDpgwZkTcXiLGKDrV 8k2TUk/p4BuxdnQbQ2hEMMiqtVgN4fCCc/nZJfZ5k2sQhED6YVaxj4V20SGfQpETTNc+ nSFi0w5bdaWOji0M37Eqg/oX9HJmmbxOsqjcmTNbMv3OAYwwihL87QISiVS10OUmx/np BH5zMY1U8oFUDF0Zf4yVF5XdZqYpIsdRnL5hnUSq2yxyZLjThXKHHzTv/78yvmwy6sHn Rp9lvKxoHJlURpXYMbmwbB9l7JJONCVdQIZv90QhmHtE6a/mneTjaZHlTJ9/5HQoSYYV dPGQ== X-Gm-Message-State: AOAM5338Z3TMzL/5D9PSw+HsNZjJG5rZUX7/mqQOv2hVORTMoWtrrnCQ gaeF7RC2dRfmO4qdel4AImNWyNkcJ8JKfmq0ckGj3mh/1kp2oQCKViIXPapUmh24OK1jrLGcXVF 4KtmC6ThVhIxwv7I9uLC9OryC8FhpTNhmaPIdaJvSni4MUu0SQWoKbag0hR62BGuPXQUQZisJ1z yGWmRIjSUWWA== X-Google-Smtp-Source: ABdhPJzJjo+e3SFgPHBsf0X+Gj8zb/OEAxvBgc1LkeQI4hM7QwAX4iYbsWRvdvM8dSW6xXcfbcQCyg== X-Received: by 2002:a17:902:b941:b0:14d:af72:3f23 with SMTP id h1-20020a170902b94100b0014daf723f23mr37457188pls.6.1649757803760; Tue, 12 Apr 2022 03:03:23 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id u17-20020a056a00159100b004faef351ebcsm37020020pfk.45.2022.04.12.03.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 03:03:23 -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 Cc: Ilya Lifshits , Boris Sukholitko Subject: [PATCH net-next v2 4/5] net/sched: flower: Add number of vlan tags filter Date: Tue, 12 Apr 2022 13:02:35 +0300 Message-Id: <20220412100236.27244-5-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220412100236.27244-1-boris.sukholitko@broadcom.com> References: <20220412100236.27244-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 8725aa1bb21e..fafb74198c8d 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 }, }; @@ -1609,6 +1611,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, @@ -1898,6 +1905,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); } @@ -2986,6 +2995,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;