From patchwork Tue Apr 19 08:14:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 12817583 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 85911C433F5 for ; Tue, 19 Apr 2022 08:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229580AbiDSISX (ORCPT ); Tue, 19 Apr 2022 04:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349948AbiDSISN (ORCPT ); Tue, 19 Apr 2022 04:18:13 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 145AF65DA for ; Tue, 19 Apr 2022 01:14:58 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id n43so3892921pfv.10 for ; Tue, 19 Apr 2022 01:14:58 -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=HnZ169+hdxEEhEWXUVCgxToz/0/vSv2yswgbUCjCCrA=; b=BRDT1WU72ebFbSyGLJSa0jmCwqZpswJEwvqj0nvVVGkMpunGzIv5AbQKAIzhFD65bl jYoao2j/1kouoUDsV8IMJV8E3URc7nc2fytXPFfUuC12gEFTyFeYUQ8/MIKDAIfExB/k m+9FMfCRbqYWE71zOA7iyFmj678eZj259zexI= 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=HnZ169+hdxEEhEWXUVCgxToz/0/vSv2yswgbUCjCCrA=; b=3AGbrG9OlzKtrI08E795dVS1BrtOq7m6iTWjB6L1Zf0XdSETDGqqQI7FPCuA/J+L3S xwGuXIFa+m02nm9eFNdvSdCd9CX+W1NjjNOaP3Pg4+/vmKExd5Wn47557uIKkijN7pxp U2cF9AWDFWxl5slQehmtu2/FGXJXFmBQ73VGnvVdu2XjyoT91pBeDA89wlDNoYLlu1Qy dimeHyTaeX2LtdhMHE1QeuDAfpI7B9fqGJQkfWMfQUL5KQojgr39MtrziohmUqgL4zw9 qaXOUoVvCW33LPy6FZ0wblFdPNxHeGU2A+gylEjBwB6a19vPay6P6yHD1aT9r2MY7W93 FPsw== X-Gm-Message-State: AOAM530uPmw6TWAB9W33Uu6krdZHJEHy60s8xKn7ZQbrAkV9/YOGLC9f nnv3HOmjtgTQMMhqtmMNQvhO6ijZ6TNM0EBGsjjYlHnQyYl57BExebwjapwMgeX7rOuT/kD6Sfu /otmZV8S4Xi4tGhHFfIWCarto4yEgoC0AS0NgWhN1KVo8JmRWpnThSmMMtv23NlDBJ0FhdseNhD g5CRoFfu0UhQ== X-Google-Smtp-Source: ABdhPJzu1BaQ3ZlcuumfAz/WU/LrZ7Vb3Ue8BSwKB+juymUfB0ErRDIVrB8YfIW90XIEez+xb6wEJQ== X-Received: by 2002:a63:5560:0:b0:399:4e32:42 with SMTP id f32-20020a635560000000b003994e320042mr13642323pgm.164.1650356097173; Tue, 19 Apr 2022 01:14:57 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id cp19-20020a056a00349300b0050a890c8c16sm4284570pfb.19.2022.04.19.01.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 01:14:55 -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 v4 0/5] net/sched: flower: match on the number of vlan tags Date: Tue, 19 Apr 2022 11:14:29 +0300 Message-Id: <20220419081434.5192-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. - v4: rebased to the latest net-next - 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 | 90 +++++++++++++++++++++++------------- 4 files changed, 88 insertions(+), 33 deletions(-)