From patchwork Wed Mar 23 10:56:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 12789676 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 4C4C4C433F5 for ; Wed, 23 Mar 2022 10:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243658AbiCWK65 (ORCPT ); Wed, 23 Mar 2022 06:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237751AbiCWK6z (ORCPT ); Wed, 23 Mar 2022 06:58:55 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CCEA5E15A for ; Wed, 23 Mar 2022 03:57:25 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id c23so1183941plo.0 for ; Wed, 23 Mar 2022 03:57: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:in-reply-to:references :mime-version; bh=TP9lZYu9/4UOvGogYOUdC98gvB2K8ztoBK9THxnsg6c=; b=AZwBT9IfS8m/iPFVf+m3739+kKa3gndOE8d85oNoKHl8LVY4zrAdvfoyup0s0HNvGb ev1Kz9gw77chjqZ+/0zDwdU2Hht69pzvKTilWfzeBadpGwsTUUGsNTlu8lFqnh/8Ql6m JAt/bdLxwxS2j2AAmABunJ0e0V2X3vIRwEdpo= 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=TP9lZYu9/4UOvGogYOUdC98gvB2K8ztoBK9THxnsg6c=; b=UnaIP9DbLN8Fn/RzHuhNbrF5aMxL4aYmqx9JhPb5MqHK/VkaxXFUL8aqDmUasEi+XH hBjqVfea/aTKT38fnLtKoWpyug1tRENnwu2sybUpy7Kuilq1gM6b/IesksIGErANA132 l0eNZaiUP6pV+sTG2Gx9OLP/y8g/SxEWjkhJoCYVgkCge8gvin/S2o/4NC+g94nV/J2O opBZHZZHfgTaYJyAolOrCKhTURah7CQT2CdGY8j1Fac2bA+Xft9A0iOhzcNdovmEoo79 /othIr+94iaNdf4ahK/9En/4Q1KPZShbzBLUkT/JkoxCNERXuB+wUrC7kd1b6UAygYgy 2qWw== X-Gm-Message-State: AOAM532AfAtYMExBbpLGIHE2U3k9ti+SAmWUE4QdWTM8OFm1B8RED5SY qOXUTj/j107z524onFAP2Uw+gAth+aZnZ4I5SxJKoRVwmE6OSaI6CO/U5lfJV7Opzz5zB/yNROp ovBY1D4scK3ZyZAsxCJ6O+DB7SS794u8PMnBIjjxC+kFb6qYa8w61NR6GzdSjasZqdXvGQnXQJb hTI0+Czp4eYA== X-Google-Smtp-Source: ABdhPJxqLBsTe7fuNArzgeDyzR78sKxUo5bcSUIvCx2Ee7mJESapflyYCVNrVqoPyDzGjrPwccoyTQ== X-Received: by 2002:a17:90b:1d84:b0:1c7:880b:9efc with SMTP id pf4-20020a17090b1d8400b001c7880b9efcmr3437359pjb.90.1648033044344; Wed, 23 Mar 2022 03:57:24 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d11-20020aa7868b000000b004f768dfe93asm25535927pfo.176.2022.03.23.03.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 03:57:24 -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 4/5] Add number of vlan tags filter to the flower Date: Wed, 23 Mar 2022 12:56:01 +0200 Message-Id: <20220323105602.30072-5-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220323105602.30072-1-boris.sukholitko@broadcom.com> References: <20220323105602.30072-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 ee38b35c3f57..5b14380adb2b 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 e073787dfd1d..42dd84f5a037 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -71,6 +71,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 { @@ -713,6 +714,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 }, }; @@ -1528,6 +1530,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, @@ -1817,6 +1824,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); } @@ -2872,6 +2881,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;