From patchwork Mon Apr 11 13:30:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 12809107 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 B44E4C433EF for ; Mon, 11 Apr 2022 13:31:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241803AbiDKNeJ (ORCPT ); Mon, 11 Apr 2022 09:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346507AbiDKNeC (ORCPT ); Mon, 11 Apr 2022 09:34:02 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15BBE3BBC3 for ; Mon, 11 Apr 2022 06:31:48 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id z128so14216530pgz.2 for ; Mon, 11 Apr 2022 06:31:48 -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=Wx8ep305yjHFiSP++PmsCE+3L8e4J5OhxQAcm9o7JjU=; b=fPg0KoEeDqBOh+k7EHbFL3TzRk6AEiAOIkcTHVk+EQG7qbXgV873Ce8Kel8CMTGLmp nbqo5ioErsO6p3YIqX3deWceOMozWBlOxe1ZckAjqOIAWjWBfGSrp+wIBkZ1sIe6zNcf afh6dgdKY7D8ODIJk/bwZtgDNyR5uuW/fcrfc= 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=Wx8ep305yjHFiSP++PmsCE+3L8e4J5OhxQAcm9o7JjU=; b=Nq6ev6LCa2QX7vkcqxqGCinesfHBiguVB8cz8lCkoAf+b76UABj0+7EfPpfMroqorQ UbTHqxfRBy6YTYLG5K1pnnMh2VC6oMW7olUa+BC/pXEl5ZvVQf8339L0HPxd7z9NJ9N1 SVFoWZm8dLcWtcZ+Vd3QAg9AOsOhygboiy+REwWZAu2FxRvuUkByMKDSNNQ+aZb2mueV TngSykkb8qJdEsR/A4a7HKzJq51RVpQUkVLlmuMzhZO++9c6vAC5rZ8tcs1FvUfkUwis A5FiTA5tyAUnL2S41ZHsuWY9flr13K5eiXUmoHjOcuTNbfNsdZup0Ywl/8F/REWwBiuX kBew== X-Gm-Message-State: AOAM532XDl7q8RLwKZEnzIDDORDMLtGodZSyPOXsqRR9EKAo2jarp6Ik fkwcLZ/dIcDn23Qqx+DeQ+MZE02PlDCEipNMqxBngWH2ptF6mbxeh34/z9+cfFvLYvvtbobomLg 5qr4lwbNXKP9/JGA7ld+uTCWTv6pobJMi5KPQIvWzL/vT72Rpr1GDSCeloaU3kkjaMDlgByznf5 nr9I7CLyGRFQ== X-Google-Smtp-Source: ABdhPJypUPQCb8eNwKjoAwGO0+RgJ3RpjKddrQ7w90P+wGX8ak62mz1TXNBKdJAbEul4RgGWtWOhaQ== X-Received: by 2002:a63:d906:0:b0:39c:c4ca:32b1 with SMTP id r6-20020a63d906000000b0039cc4ca32b1mr18512851pgg.408.1649683907886; Mon, 11 Apr 2022 06:31:47 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f70d5e92basm35716311pfx.34.2022.04.11.06.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:31:47 -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: Mon, 11 Apr 2022 16:30:59 +0300 Message-Id: <20220411133100.18126-5-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220411133100.18126-1-boris.sukholitko@broadcom.com> References: <20220411133100.18126-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;