From patchwork Thu Apr 14 12:51:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 12813496 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 3646EC433F5 for ; Thu, 14 Apr 2022 12:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243626AbiDNMyr (ORCPT ); Thu, 14 Apr 2022 08:54:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243629AbiDNMyl (ORCPT ); Thu, 14 Apr 2022 08:54:41 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D865A92327 for ; Thu, 14 Apr 2022 05:52:16 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id g11so3763771qke.1 for ; Thu, 14 Apr 2022 05:52:16 -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=Vxf2bnp5MyK457bWGLRm79FFdwVY+F5r9xX4hI/iqLM=; b=PzT6hGydJkMphtSnyGAAEBY5f8BUNw67lOg79scDkpgEVhy9KK0Ry9OOvh/N2Yx4qL UUpkLaXg3Ck4xEic71XplCoSuOBw2BA/Tj6CFqjuuvaub/NE1++X+H6xdmx4VdUnAFY1 cyz8LX4x/yOQRLhjhxc2W7IZPM+2vHNue/mBQ= 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=Vxf2bnp5MyK457bWGLRm79FFdwVY+F5r9xX4hI/iqLM=; b=SdBRd8hyY9OY+YfVS+ur/MoACOJtSzw3+LyHJEy4U3wEc0jNhMY5uI3PNzD68hLRqM fpb1Ot32btxbLeLiStq0LvSp51CBblzDWn15BRh825qLh4z3dpvRxskThR7lrls1mbhW rU6bKwsJjdkojyPe9Idxyobn3867BmLzQrmvKWm7PDyIv263u3pbzbA4hAPjs0Ly1tNf EPvaZ8i8UTJmrt5NFNX/bkby+kxOQGAShPBy6miqpW7oWHbnpu/OWttHXuGmLm0/2ca1 mDbk6w6p8oiG5o9PiCQUwdHO7N//88LtCiYNFfgjtPIhiOTDDF3fOzq1FYw+JpYSnWYy cFOA== X-Gm-Message-State: AOAM533Kt8BK8oDa16mWzX+5RofV7cvQLgu9zDtDBf1+avDOoVuCS5It PmWFLSptSGH/jVN+QdjO/6CK3qWL5EjjUtOFQd8x7ap8eJDgFBPT5TG6qM2T2Ktc5y9yeGPLKte LnAsXnMvIpWZDSC6cosgjJQkCltrY3r5WioQ77OA1y/v413pE66WUDCITFoQnyEYOUExghJYdRQ c0N7b0BIRL7g== X-Google-Smtp-Source: ABdhPJx0l6hVOs//CdQB0m0BXB78zj+eMYcOTxgsgoDyYCviaFs6aIPwpWNiexv5h/XRZAcDSv1pbg== X-Received: by 2002:ae9:f016:0:b0:69c:37ea:9b38 with SMTP id l22-20020ae9f016000000b0069c37ea9b38mr1629231qkg.335.1649940735661; Thu, 14 Apr 2022 05:52:15 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id o10-20020a05620a15ca00b0069c39e2970bsm875910qkm.80.2022.04.14.05.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 05:52:15 -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 v3 4/5] net/sched: flower: Add number of vlan tags filter Date: Thu, 14 Apr 2022 15:51:20 +0300 Message-Id: <20220414125121.13599-5-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220414125121.13599-1-boris.sukholitko@broadcom.com> References: <20220414125121.13599-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;