From patchwork Thu Oct 15 01:16:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 269986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D99ECC43457 for ; Thu, 15 Oct 2020 01:17:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89ABC22254 for ; Thu, 15 Oct 2020 01:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731940AbgJOBRC (ORCPT ); Wed, 14 Oct 2020 21:17:02 -0400 Received: from correo.us.es ([193.147.175.20]:38766 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387588AbgJOBQz (ORCPT ); Wed, 14 Oct 2020 21:16:55 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id E7A56DA7EA for ; Thu, 15 Oct 2020 03:16:45 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id D2D94DA78A for ; Thu, 15 Oct 2020 03:16:45 +0200 (CEST) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id C8A29DA730; Thu, 15 Oct 2020 03:16:45 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id C7FF1DA789; Thu, 15 Oct 2020 03:16:43 +0200 (CEST) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Thu, 15 Oct 2020 03:16:43 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from localhost.localdomain (unknown [90.77.255.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pneira@us.es) by entrada.int (Postfix) with ESMTPSA id 9F66F41FF201; Thu, 15 Oct 2020 03:16:43 +0200 (CEST) X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Subject: [PATCH net-next 8/9] netfilter: flowtable: bridge port support Date: Thu, 15 Oct 2020 03:16:29 +0200 Message-Id: <20201015011630.2399-9-pablo@netfilter.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201015011630.2399-1-pablo@netfilter.org> References: <20201015011630.2399-1-pablo@netfilter.org> MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Update hardware destination address to the master bridge device to emulate the forwarding behaviour. Signed-off-by: Pablo Neira Ayuso --- include/net/netfilter/nf_flow_table.h | 1 + net/netfilter/nf_flow_table_core.c | 4 ++++ net/netfilter/nft_flow_offload.c | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h index 1b57d1d1270d..4ec3f9bb2f32 100644 --- a/include/net/netfilter/nf_flow_table.h +++ b/include/net/netfilter/nf_flow_table.h @@ -172,6 +172,7 @@ struct nf_flow_route { u32 ifindex; u8 h_source[ETH_ALEN]; u8 h_dest[ETH_ALEN]; + enum flow_offload_xmit_type xmit_type; } out; struct dst_entry *dst; } tuple[FLOW_OFFLOAD_DIR_MAX]; diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c index 725366339b85..e80dcabe3668 100644 --- a/net/netfilter/nf_flow_table_core.c +++ b/net/netfilter/nf_flow_table_core.c @@ -100,6 +100,10 @@ static int flow_offload_fill_route(struct flow_offload *flow, if (dst_xfrm(dst)) flow_tuple->xmit_type = FLOW_OFFLOAD_XMIT_XFRM; + else + flow_tuple->xmit_type = route->tuple[dir].out.xmit_type; + + flow_tuple->dst_cache = dst; flow_tuple->dst_cache = dst; diff --git a/net/netfilter/nft_flow_offload.c b/net/netfilter/nft_flow_offload.c index d440e436cb16..9efb5d584290 100644 --- a/net/netfilter/nft_flow_offload.c +++ b/net/netfilter/nft_flow_offload.c @@ -54,6 +54,7 @@ struct nft_forward_info { u32 iifindex; u8 h_source[ETH_ALEN]; u8 h_dest[ETH_ALEN]; + enum flow_offload_xmit_type xmit_type; }; static int nft_dev_forward_path(struct nf_flow_route *route, @@ -83,7 +84,9 @@ static int nft_dev_forward_path(struct nf_flow_route *route, case DEV_PATH_VLAN: return -1; case DEV_PATH_BRIDGE: - return -1; + memcpy(info.h_dest, path->dev->dev_addr, ETH_ALEN); + info.xmit_type = FLOW_OFFLOAD_XMIT_DIRECT; + break; } } @@ -91,6 +94,7 @@ static int nft_dev_forward_path(struct nf_flow_route *route, memcpy(route->tuple[dir].out.h_dest, info.h_source, ETH_ALEN); memcpy(route->tuple[dir].out.h_source, info.h_dest, ETH_ALEN); route->tuple[dir].out.ifindex = info.iifindex; + route->tuple[dir].out.xmit_type = info.xmit_type; return 0; }