{"id":2221424,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2221424/?format=json","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/1.0/projects/26/?format=json","name":"Netfilter Development","link_name":"netfilter-devel","list_id":"netfilter-devel.vger.kernel.org","list_email":"netfilter-devel@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<f1964680a3b5e7daa81a07be18f9e91af199102f.1775739840.git.daniel@makrotopia.org>","date":"2026-04-09T13:07:38","name":"[RFC,net-next,2/4] nf_flow_table: track sub-interface and bridge ifindex in flow tuple","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"29f5de5740a037a88bdf8ddd2f1a3a0d6c99d109","submitter":{"id":64091,"url":"http://patchwork.ozlabs.org/api/1.0/people/64091/?format=json","name":"Daniel Golle","email":"daniel@makrotopia.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/f1964680a3b5e7daa81a07be18f9e91af199102f.1775739840.git.daniel@makrotopia.org/mbox/","series":[{"id":499290,"url":"http://patchwork.ozlabs.org/api/1.0/series/499290/?format=json","date":"2026-04-09T13:07:22","name":"improve hw flow offload byte accounting","version":1,"mbox":"http://patchwork.ozlabs.org/series/499290/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221424/checks/","tags":{},"headers":{"Return-Path":"\n <netfilter-devel+bounces-11765-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","netfilter-devel@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11765-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=185.142.180.65","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=makrotopia.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=makrotopia.org"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fs0cC6x7qz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 23:08:27 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id EB8B730231F4\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  9 Apr 2026 13:08:00 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id D0BD63CF039;\n\tThu,  9 Apr 2026 13:07:48 +0000 (UTC)","from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id CAAC43CF03E;\n\tThu,  9 Apr 2026 13:07:46 +0000 (UTC)","from local\n\tby pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256)\n\t (Exim 4.99)\n\t(envelope-from <daniel@makrotopia.org>)\n\tid 1wAp6j-000000001kZ-0rCL;\n\tThu, 09 Apr 2026 13:07:41 +0000"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775740068; cv=none;\n b=Vl4D2+4jiVxH8c/o6GIcjAUszhlVddT6wIOo3miPcJRgyMiU9il+gYy1Zyb126WRuRiykVmi3wvQsjaEG4VbOj6YsqFbL8wwHvJtefk53bJFk+VzjfA2X3c+xa00UOJQXCMj+BYafWfwTDwPXnqWFFbrCVynzrQxREwJNmy9j90=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775740068; c=relaxed/simple;\n\tbh=V8yWgEIDw3Aej3VaRFD1FMwXyNe1Q8zT/fES3H1tciU=;\n\th=Date:From:To:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=N/M7rrizYePDp/pOD2G1hLdYUEzd4vVqec4xn0nftZxFZjUTbvHjuOTD2a3/H1jUWRIlNQ506D28GoSpX35ZqoU7GfONV1r+SvQQ8KPzg4Qwi4SV8Yl2cwPD+Dl0b49UJI8A9v3208jKHfO5IYMQ0L7q83aCteMWbAtL2MahT6g=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=makrotopia.org;\n spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65","Date":"Thu, 9 Apr 2026 14:07:38 +0100","From":"Daniel Golle <daniel@makrotopia.org>","To":"Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>,\n\tLorenzo Bianconi <lorenzo@kernel.org>,\n\tAndrew Lunn <andrew+netdev@lunn.ch>,\n\t\"David S. Miller\" <davem@davemloft.net>,\n\tEric Dumazet <edumazet@google.com>,\n\tJakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,\n\tMatthias Brugger <matthias.bgg@gmail.com>,\n\tAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>,\n\tSimon Horman <horms@kernel.org>,\n\tPablo Neira Ayuso <pablo@netfilter.org>,\n\tFlorian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,\n\tnetdev@vger.kernel.org, linux-kernel@vger.kernel.org,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinux-mediatek@lists.infradead.org, netfilter-devel@vger.kernel.org,\n\tcoreteam@netfilter.org","Subject":"[PATCH RFC net-next 2/4] nf_flow_table: track sub-interface and\n bridge ifindex in flow tuple","Message-ID":"\n <f1964680a3b5e7daa81a07be18f9e91af199102f.1775739840.git.daniel@makrotopia.org>","References":"<cover.1775739840.git.daniel@makrotopia.org>","Precedence":"bulk","X-Mailing-List":"netfilter-devel@vger.kernel.org","List-Id":"<netfilter-devel.vger.kernel.org>","List-Subscribe":"<mailto:netfilter-devel+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:netfilter-devel+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<cover.1775739840.git.daniel@makrotopia.org>"},"content":"Store the net_device ifindex alongside each encap entry and for\nbridge devices during path discovery so the flow offload stats\npath can later update sub-interface (VLAN, PPPoE, bridge)\ncounters for hw-offloaded flows.\n\nThe indices are placed below __hash so they do not affect flow\ntuple lookups.\n\nNo functional change -- the indices are stored but not yet used.\n\nSigned-off-by: Daniel Golle <daniel@makrotopia.org>\n---\n include/net/netfilter/nf_flow_table.h | 5 +++++\n net/netfilter/nf_flow_table_core.c    | 2 ++\n net/netfilter/nf_flow_table_path.c    | 8 ++++++++\n 3 files changed, 15 insertions(+)","diff":"diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h\nindex b09c11c048d51..ec1a18cfd9621 100644\n--- a/include/net/netfilter/nf_flow_table.h\n+++ b/include/net/netfilter/nf_flow_table.h\n@@ -148,6 +148,9 @@ struct flow_offload_tuple {\n \t/* All members above are keys for lookups, see flow_offload_hash(). */\n \tstruct { }\t\t\t__hash;\n \n+\tint\t\t\t\tencap_ifidx[NF_FLOW_TABLE_ENCAP_MAX];\n+\tint\t\t\t\tbridge_ifidx;\n+\n \tu8\t\t\t\tdir:2,\n \t\t\t\t\txmit_type:3,\n \t\t\t\t\tencap_num:2,\n@@ -221,11 +224,13 @@ struct nf_flow_route {\n \t\t\tstruct {\n \t\t\t\tu16\t\tid;\n \t\t\t\t__be16\t\tproto;\n+\t\t\t\tint\t\tifindex;\n \t\t\t} encap[NF_FLOW_TABLE_ENCAP_MAX];\n \t\t\tstruct flow_offload_tunnel tun;\n \t\t\tu8\t\t\tnum_encaps:2,\n \t\t\t\t\t\tnum_tuns:2,\n \t\t\t\t\t\tingress_vlans:2;\n+\t\t\tint\t\t\tbridge_ifindex;\n \t\t} in;\n \t\tstruct {\n \t\t\tu32\t\t\tifindex;\ndiff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c\nindex 2c4140e6f53c5..9bc8be177b392 100644\n--- a/net/netfilter/nf_flow_table_core.c\n+++ b/net/netfilter/nf_flow_table_core.c\n@@ -115,6 +115,7 @@ static int flow_offload_fill_route(struct flow_offload *flow,\n \tfor (i = route->tuple[dir].in.num_encaps - 1; i >= 0; i--) {\n \t\tflow_tuple->encap[j].id = route->tuple[dir].in.encap[i].id;\n \t\tflow_tuple->encap[j].proto = route->tuple[dir].in.encap[i].proto;\n+\t\tflow_tuple->encap_ifidx[j] = route->tuple[dir].in.encap[i].ifindex;\n \t\tif (route->tuple[dir].in.ingress_vlans & BIT(i))\n \t\t\tflow_tuple->in_vlan_ingress |= BIT(j);\n \t\tj++;\n@@ -123,6 +124,7 @@ static int flow_offload_fill_route(struct flow_offload *flow,\n \tflow_tuple->tun = route->tuple[dir].in.tun;\n \tflow_tuple->encap_num = route->tuple[dir].in.num_encaps;\n \tflow_tuple->tun_num = route->tuple[dir].in.num_tuns;\n+\tflow_tuple->bridge_ifidx = route->tuple[dir].in.bridge_ifindex;\n \n \tswitch (route->tuple[dir].xmit_type) {\n \tcase FLOW_OFFLOAD_XMIT_DIRECT:\ndiff --git a/net/netfilter/nf_flow_table_path.c b/net/netfilter/nf_flow_table_path.c\nindex 6bb9579dcc2ab..c5817cb96a9f6 100644\n--- a/net/netfilter/nf_flow_table_path.c\n+++ b/net/netfilter/nf_flow_table_path.c\n@@ -79,8 +79,10 @@ struct nft_forward_info {\n \tstruct id {\n \t\t__u16\tid;\n \t\t__be16\tproto;\n+\t\tint\tifindex;\n \t} encap[NF_FLOW_TABLE_ENCAP_MAX];\n \tu8 num_encaps;\n+\tint bridge_ifindex;\n \tstruct flow_offload_tunnel tun;\n \tu8 num_tuns;\n \tu8 ingress_vlans;\n@@ -136,12 +138,15 @@ static void nft_dev_path_info(const struct net_device_path_stack *stack,\n \t\t\t\t\tpath->encap.id;\n \t\t\t\tinfo->encap[info->num_encaps].proto =\n \t\t\t\t\tpath->encap.proto;\n+\t\t\t\tinfo->encap[info->num_encaps].ifindex =\n+\t\t\t\t\tpath->dev->ifindex;\n \t\t\t\tinfo->num_encaps++;\n \t\t\t}\n \t\t\tif (path->type == DEV_PATH_PPPOE)\n \t\t\t\tmemcpy(info->h_dest, path->encap.h_dest, ETH_ALEN);\n \t\t\tbreak;\n \t\tcase DEV_PATH_BRIDGE:\n+\t\t\tinfo->bridge_ifindex = path->dev->ifindex;\n \t\t\tif (is_zero_ether_addr(info->h_source))\n \t\t\t\tmemcpy(info->h_source, path->dev->dev_addr, ETH_ALEN);\n \n@@ -156,6 +161,7 @@ static void nft_dev_path_info(const struct net_device_path_stack *stack,\n \t\t\t\t}\n \t\t\t\tinfo->encap[info->num_encaps].id = path->bridge.vlan_id;\n \t\t\t\tinfo->encap[info->num_encaps].proto = path->bridge.vlan_proto;\n+\t\t\t\tinfo->encap[info->num_encaps].ifindex = path->dev->ifindex;\n \t\t\t\tinfo->num_encaps++;\n \t\t\t\tbreak;\n \t\t\tcase DEV_PATH_BR_VLAN_UNTAG:\n@@ -261,6 +267,7 @@ static void nft_dev_forward_path(const struct nft_pktinfo *pkt,\n \tfor (i = 0; i < info.num_encaps; i++) {\n \t\troute->tuple[!dir].in.encap[i].id = info.encap[i].id;\n \t\troute->tuple[!dir].in.encap[i].proto = info.encap[i].proto;\n+\t\troute->tuple[!dir].in.encap[i].ifindex = info.encap[i].ifindex;\n \t}\n \n \tif (info.num_tuns &&\n@@ -273,6 +280,7 @@ static void nft_dev_forward_path(const struct nft_pktinfo *pkt,\n \n \troute->tuple[!dir].in.num_encaps = info.num_encaps;\n \troute->tuple[!dir].in.ingress_vlans = info.ingress_vlans;\n+\troute->tuple[!dir].in.bridge_ifindex = info.bridge_ifindex;\n \n \tif (info.xmit_type == FLOW_OFFLOAD_XMIT_DIRECT) {\n \t\tmemcpy(route->tuple[dir].out.h_source, info.h_source, ETH_ALEN);\n","prefixes":["RFC","net-next","2/4"]}