From patchwork Thu Apr 14 12:51:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 12813492 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 F17AAC433F5 for ; Thu, 14 Apr 2022 12:52:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243624AbiDNMy3 (ORCPT ); Thu, 14 Apr 2022 08:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240566AbiDNMy2 (ORCPT ); Thu, 14 Apr 2022 08:54:28 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A842192331 for ; Thu, 14 Apr 2022 05:52:03 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id e22so3872765qvf.9 for ; Thu, 14 Apr 2022 05:52:03 -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:mime-version; bh=l/Be0j8kQKEHRXrZVbK6yNh2UaU7mBE9OZzQUjjIs38=; b=WqdEeMFXn3AeL1Qh33Y2MaGLb1/BEuAlx1zs5I5eHMP8sBhBmGJL+YHYDUNIS8AJRw pTVqKUoxjWJJ/4vyxVtr3Ge/pvMXc22CrF1y+hdPXnsvSjJH2ZkQJVx9U5lW11K6l2Zp S909Z3E+cNAL7kLkr8H5RiE4R7Q/kXriGRlqE= 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:mime-version; bh=l/Be0j8kQKEHRXrZVbK6yNh2UaU7mBE9OZzQUjjIs38=; b=1aOfCMu8Z+/oF/4pOW76jHw4F9KJP5WgEb2JZzWdcg4I8FiaDQpZeu2a90OQfDX1Zq 7sxQJtZXGNsIL1LHHvUarTfZ2D5ulFGf2aJRfJpIvIw3R2qDUtMdcSp4+JsKrtSSbO4J BhHwdq2nygbm2MlxVP1VqoSnTtpqDdDN0GMntZdLp02Ji6jDb/5NPm+0eQcC3ptrWm06 QmesGQyLGlymn5m/LGDnZOSD4/rSvur6q4ZEUMHIsN2vOoyI7ZoxjcvGVKY9fIEPjnd6 Pu33ULYi7Ng6Dte5FnUJpFRikw0Yt88D3w4sWSPknkhkyQQNa78upGQcg9Xds9Is6O6Z 6A5A== X-Gm-Message-State: AOAM530VezDV6vinFB0/gve6oZx1wFZ3SIm/gIn5P3Bq4G3q04dZF1WU I9JsZdNqWeELvcaNdFjk8ksJU7KilmVd8RLSGB6rF+dhLSSAYxvrsACzDpSvZwUJbT33Sp/oaRo pkcGA2eWvHbY+//nbbT4XgFBG+WO4I9WfrfVjSxAeZsV37kg0SGyoMH8ffGldF5BWewRzrjBC+5 NxzGfksa/Y+A== X-Google-Smtp-Source: ABdhPJxYGiwhiEWrL2MsqbZurRFtzAXyG+3kOgiLSdJk/niyfiwhnXkAoHqvkbZvctiB2OOMfidLAQ== X-Received: by 2002:a05:6214:2607:b0:444:3e1c:9491 with SMTP id gu7-20020a056214260700b004443e1c9491mr3207255qvb.12.1649940722449; Thu, 14 Apr 2022 05:52:02 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id o10-20020a05620a15ca00b0069c39e2970bsm875910qkm.80.2022.04.14.05.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 05:52:01 -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 0/5] net/sched: flower: match on the number of vlan tags Date: Thu, 14 Apr 2022 15:51:16 +0300 Message-Id: <20220414125121.13599-1-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Hi, Our customers in the fiber telecom world have network configurations where they would like to control their traffic according to the number of tags appearing in the packet. For example, TR247 GPON conformance test suite specification mostly talks about untagged, single, double tagged packets and gives lax guidelines on the vlan protocol vs. number of vlan tags. This is different from the common IT networks where 802.1Q and 802.1ad protocols are usually describe single and double tagged packet. GPON configurations that we work with have arbitrary mix the above protocols and number of vlan tags in the packet. The following patch series implement number of vlans flower filter. They add num_of_vlans flower filter as an alternative to vlan ethtype protocol matching. The end result is that the following command becomes possible: tc filter add dev eth1 ingress flower \ num_of_vlans 1 vlan_prio 5 action drop Also, from our logs, we have redirect rules such that: tc filter add dev $GPON ingress flower num_of_vlans $N \ action mirred egress redirect dev $DEV where N can range from 0 to 3 and $DEV is the function of $N. Also there are rules setting skb mark based on the number of vlans: tc filter add dev $GPON ingress flower num_of_vlans $N vlan_prio \ $P action skbedit mark $M More about the patch series: - patches 1-2 remove duplicate code by introducing is_key_vlan helper. - patch 3, 4 implement num_of_vlans in the dissector and in the flower. - patch 5 uses the num_of_vlans filter to allow further matching on vlan attributes. Complementary iproute2 patches are being sent separately. Thanks, Boris. - v3: - more example commands in patch 3 description (request by Jamal) - patch 5 description made clearer (thanks to Jiri) - v2: - add suitable subject prefixes - more evolved patch 5 description Boris Sukholitko (5): net/sched: flower: Helper function for vlan ethtype checks net/sched: flower: Reduce identation after is_key_vlan refactoring flow_dissector: Add number of vlan tags dissector net/sched: flower: Add number of vlan tags filter net/sched: flower: Consider the number of tags for vlan filters include/net/flow_dissector.h | 9 ++++ include/uapi/linux/pkt_cls.h | 2 + net/core/flow_dissector.c | 20 +++++++++ net/sched/cls_flower.c | 86 +++++++++++++++++++++++------------- 4 files changed, 86 insertions(+), 31 deletions(-)