From patchwork Tue Nov 19 10:18:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Woudstra X-Patchwork-Id: 13879592 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 324AAD62067 for ; Tue, 19 Nov 2024 10:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=yO7sxQUafAYucRUkN2IjUq6IUra83MUQ/OQ0OsuEu30=; b=L73OLiXXmnyc86YmX9rjGQxva0 w/s0PNXFsnhiqZlL/Lu/mhdrrsTwWwHGpgGOneK/CXqIBcyKOTBcjGlauRYc7Cs70C/iS9Kpu11s/ 59LOh/8TpWngjpjXhHJKWca1FT81qAf2sddPc3dPPyM1OZdHx/cX3CLb9icHGSa+12f/Qxlfvbe00 hi/WOC0m+SbhP0fbHjbFHqMy1h50HFbGmNJoQ0aKMKhPUvxfHiAnhQBBc6uilr/027jbKhE9LuJZA iaQRrYDqYkI21UVrPFd1S62uojf7dDVhGD2QoDvjClrsOxAVUt5piNfiwIgDeDB8+ZL0trJs8itVQ hDHtAmcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tDLLI-0000000C1HL-2g0M; Tue, 19 Nov 2024 10:20:20 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tDLKL-0000000C0xb-07rW; Tue, 19 Nov 2024 10:19:22 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-aa20944ce8cso939393766b.0; Tue, 19 Nov 2024 02:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732011559; x=1732616359; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yO7sxQUafAYucRUkN2IjUq6IUra83MUQ/OQ0OsuEu30=; b=NQSSD1CtVkKecW//3XfTSKePMuWtOjkThE8t+gLy+TAYgqjSbeA1llgqrmUHVfxT3q f8fX3Bv7wgoqTzghbO3eFH7UzEbD4zMs10FNTI29/IqVaF0Zq4mXmjaJjvGG6LulVon5 +J1JxYgzQ8dMqs0UOutoVRfRFjhovNAYh1b4TNmuNej/VFkKEVPPgaaShJ936N9PvmS4 JEbsq1moaKwoWXaqg7jrexBIPNdQHnfl1T+tor8s/FoS7oLfok7kpxGEn6n4ihI9jdqn wNJtC7kbkzVrA+RUboKchzFNvIOS+GCg9Ec3woPLO57jSJhuaujlpCel7mr27Sf+fmDt JcDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732011559; x=1732616359; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yO7sxQUafAYucRUkN2IjUq6IUra83MUQ/OQ0OsuEu30=; b=SNUJkxFXB5+pKbajqQw6uND+p06g+HUA5x+BY/LbCejlsnfnUaTAa8cCe76W8RJTHB 45XLsMMuXRX//DCd6hssn/oen0Mpgx8GUE7WyhyuOks4DEqaTH7EceAJEAabKPjXgAYs cvm7Av8WwwTTYu9SaDqt5g3F4GQokKq6fZ43FLRJTLlEXw+TgY6QkESlFfVQLLaaM3wF xiW7xTDeRk8vcNOQMp4SDu4E8PGwFCW6OGElRTm8ILFbtrqwAYfD7BN68Z+d0WLwTWvt SFNH+WkUFTiw4RI+oMqzAgJ+FTj1ECOKyjTKtQdRBYx26pQCa1ZhqXVMVZoLfMQu7tou YK1w== X-Forwarded-Encrypted: i=1; AJvYcCU4gPltlVVesJ+zIcjLjOFetmuGBmZQYgpRlOfRq/IrNaDfW0N3hBg3PWfxFg3o+NYF+ZqGsfwRiejfV1xWaoGA@lists.infradead.org, AJvYcCWYYlloaQfqjOBZMtmuSEU9NdPhaTe3uBCtBfZnLxO2jPXB9P4FXmmmoNnS1sFbuXZ2/sR5X3eDTR+5ISK8sQM=@lists.infradead.org X-Gm-Message-State: AOJu0YyDZ0eCfuEleQOpGdG3px9o992xbclOgGvslsA/3N4LjUuEsKcI tFqkDbXZwZuLcFD8v9OpAMtDAZkF2ZHKcygRELXo8fT1Sdocqm9V X-Google-Smtp-Source: AGHT+IHfClA1OO+Sq3mruClnwoe/BR7xI+sjeG3UEZ/v9gqMrSpB7FHcIFZ2f2w6kLP2kZj+vPyc1w== X-Received: by 2002:a17:907:97c9:b0:a99:facf:cfc with SMTP id a640c23a62f3a-aa4c7e48f63mr248549566b.17.1732011558440; Tue, 19 Nov 2024 02:19:18 -0800 (PST) Received: from corebook.localdomain (2001-1c00-020d-1300-1b1c-4449-176a-89ea.cable.dynamic.v6.ziggo.nl. [2001:1c00:20d:1300:1b1c:4449:176a:89ea]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20e081574sm634875566b.179.2024.11.19.02.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 02:19:17 -0800 (PST) From: Eric Woudstra To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Pablo Neira Ayuso , Jozsef Kadlecsik , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Nikolay Aleksandrov , Matthias Brugger , AngeloGioacchino Del Regno , David Ahern , Sebastian Andrzej Siewior , Lorenzo Bianconi , Joe Damato , Alexander Lobakin , Vladimir Oltean , "Frank Wunderlich" , Daniel Golle Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, bridge@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Eric Woudstra Subject: [PATCH RFC v2 net-next 00/14] bridge-fastpath and related improvements Date: Tue, 19 Nov 2024 11:18:52 +0100 Message-ID: <20241119101906.862680-1-ericwouds@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241119_021921_066629_EBC49AEA X-CRM114-Status: GOOD ( 20.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patchset makes it possible to set up a software fastpath between bridged interfaces. This also creates the possibility to have a hardware offloaded fastpath between bridged interfaces. To set up the fastpath with offloading, add this extra flowtable: table bridge filter { flowtable fb { hook ingress priority filter devices = { lan0, lan1, lan2, lan3, lan4, wlan0, wlan1 } flags offload } chain forward { type filter hook forward priority filter; policy accept; ct state established flow add @fb } } Creating a separate fastpath for bridges. forward fastpath bypass .----------------------------------------. / \ | IP - forwarding | | / \ v | / wan ... | / | | | | | brlan.1 | | | +-------------------------------+ | | vlan 1 | | | | | | brlan (vlan-filtering) | | +---------------+ | | | DSA-SWITCH | | | | | vlan 1 | | | | to | | | vlan 1 | untagged | | +---------------+---------------+ . / \ ------>lan0 wlan1 . ^ ^ . | | . \_________________/ . bridge fastpath bypass . ^ vlan 1 tagged packets While testing direct transmit in the software forward-fastpath, it is useful to enslave the wan interface to another bridge, brwan. This will make sure both directions of the software forward-fastpath use direct transmit. To have the ability to handle xmit direct with outgoing encaps in the bridge fastpass bypass, we need to be able to handle them without going through vlan/pppoe devices. So I've applied, amended and squashed wenxu's patchset. This patch also makes it possible to egress from vlan-filtering brlan to lan0 with vlan tagged packets, if the bridge master port is doing the vlan tagging, instead of the vlan-device. Without this patch, this is not possible in the bridge-fastpath and also not in the forward-fastpath, as seen in the figure above. There are also some more fixes for filling in the forward path. These fixes also apply to for the forward-fastpath. They include handling DEV_PATH_MTK_WDMA in nft_dev_path_info(). There are now 2 patches for avoiding ingress_vlans bit set for bridged dsa user ports and foreign (dsa) ports. Another patch introduces DEV_PATH_BR_VLAN_KEEP_HW, needed for the bridge-fastpath only. Conntrack bridge only tracks untagged and 802.1q. To make the bridge fastpath experience more similar to the forward fastpath experience, I've added double vlan, pppoe and pppoe-in-q tagged packets to bridge conntrack and to bridge filter chain. I am sending RFC v2 as I previously only owned a dsa device. I now have obtained a switchdev supporting SWITCHDEV_OBJ_ID_PORT_VLAN, and found there was more to do to handle the ingress_vlans bit and corresponding vlan encap. Changes in v2: - Introduce DEV_PATH_BR_VLAN_KEEP_HW for use in the bridge-fastpath only. It is needed for switchdevs supporting SWITCHDEV_OBJ_ID_PORT_VLAN. - Different approach for handling BR_VLFLAG_ADDED_BY_SWITCHDEV in br_vlan_fill_forward_path_mode() for foreign devices. Introduce SWITCHDEV_F_NO_FOREIGN, BR_VLFLAG_TAGGING_BY_SWITCHDEV and br_switchdev_port_vlan_no_foreign_add(). The latter function can be used to make sure the vlan was added to a switchdev native device. When that fails, adding the vlan with br_switchdev_port_vlan_add() means it was added to a switchdev foreign device. - Clear ingress_vlans bit and corresponding encap for dsa user ports. - Add check for ingress_vlans bit to nft_dev_fill_bridge_path(). - Adapted cover letter description to make clear the patches apply to software fastpath, making hardware-offloaded fastpath possible. - Fixed clang error for vlan_hdr * and struct ppp_hdr * by adding block. - Updated !CONFIG_BRIDGE_VLAN_FILTERING version of br_vlan_fill_forward_path_pvid(). - Removed erroneous check netif_is_bridge_master(ctx->dev) from dev_fill_bridge_path(). - Cosmetic changes. Eric Woudstra (14): netfilter: nf_flow_table_offload: Add nf_flow_encap_push() for xmit direct netfilter: bridge: Add conntrack double vlan and pppoe netfilter: nft_chain_filter: Add bridge double vlan and pppoe bridge: br_vlan_fill_forward_path_pvid: Add port to port bridge: br_fill_forward_path add port to port net: core: dev: Add dev_fill_bridge_path() netfilter :nf_flow_table_offload: Add nf_flow_rule_bridge() netfilter: nf_flow_table_inet: Add nf_flowtable_type flowtable_bridge netfilter: nft_flow_offload: Add NFPROTO_BRIDGE to validate netfilter: nft_flow_offload: Add DEV_PATH_MTK_WDMA to nft_dev_path_info() netfilter: nft_flow_offload: No ingress_vlan forward info for dsa user port bridge: No DEV_PATH_BR_VLAN_UNTAG_HW for dsa foreign bridge: Introduce DEV_PATH_BR_VLAN_KEEP_HW for bridge-fastpath netfilter: nft_flow_offload: Add bridgeflow to nft_flow_offload_eval() include/linux/netdevice.h | 3 + include/net/netfilter/nf_flow_table.h | 3 + include/net/switchdev.h | 1 + net/bridge/br_device.c | 23 ++- net/bridge/br_private.h | 5 + net/bridge/br_switchdev.c | 15 ++ net/bridge/br_vlan.c | 29 +++- net/bridge/netfilter/nf_conntrack_bridge.c | 88 +++++++++-- net/core/dev.c | 66 ++++++-- net/netfilter/nf_flow_table_inet.c | 13 ++ net/netfilter/nf_flow_table_ip.c | 96 +++++++++++- net/netfilter/nf_flow_table_offload.c | 13 ++ net/netfilter/nft_chain_filter.c | 20 ++- net/netfilter/nft_flow_offload.c | 166 +++++++++++++++++++-- net/switchdev/switchdev.c | 2 +- 15 files changed, 490 insertions(+), 53 deletions(-)