All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: wenxu@chinatelecom.cn
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next] nf_flow_table_offload: offload the vlan encap in the flowtable
Date: Wed, 27 Apr 2022 16:10:27 +0200	[thread overview]
Message-ID: <YmlO009uqhJNnBq7@salvia> (raw)
In-Reply-To: <1649169515-4337-1-git-send-email-wenx05124561@163.com>

On Tue, Apr 05, 2022 at 10:38:35AM -0400, wenx05124561@163.com wrote:
> From: wenxu <wenxu@chinatelecom.cn>
> 
> This patch put the vlan dev process in the FLOW_OFFLOAD_XMIT_DIRECT
> mode. Xmit the packet with vlan can offload to the real dev directly.
> 
> It can support all kinds of VLAN dev path:
> br0.100-->br0(vlan filter enable)-->eth
> br0(vlan filter enable)-->eth
> br0(vlan filter disable)-->eth.100-->eth

I assume this eth is a bridge port.

> The packet xmit and recv offload to the 'eth' in both original and
> reply direction.

This is an enhancement or fix?

Is this going to work for VLAN + PPP?

Would you update tools/testing/selftests/netfilter/nft_flowtable.sh to
cover bridge filtering usecase? It could be done in a follow up patch.

> Signed-off-by: wenxu <wenxu@chinatelecom.cn>
> ---
>  net/netfilter/nf_flow_table_ip.c | 19 +++++++++++++++++++
>  net/netfilter/nft_flow_offload.c |  7 +++++--
>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
> index 32c0eb1..99ae2550 100644
> --- a/net/netfilter/nf_flow_table_ip.c
> +++ b/net/netfilter/nf_flow_table_ip.c
> @@ -282,6 +282,23 @@ static bool nf_flow_skb_encap_protocol(const struct sk_buff *skb, __be16 proto,
>  	return false;
>  }
>  
> +static void nf_flow_encap_push(struct sk_buff *skb,
> +			       struct flow_offload_tuple_rhash *tuplehash)
> +{
> +	int i;
> +
> +	for (i = 0; i < tuplehash->tuple.encap_num; i++) {
> +		switch (tuplehash->tuple.encap[i].proto) {
> +		case htons(ETH_P_8021Q):
> +		case htons(ETH_P_8021AD):
> +			skb_vlan_push(skb,
> +				      tuplehash->tuple.encap[i].proto,
> +				      tuplehash->tuple.encap[i].id);
> +			break;
> +		}
> +	}
> +}
> +
>  static void nf_flow_encap_pop(struct sk_buff *skb,
>  			      struct flow_offload_tuple_rhash *tuplehash)
>  {
> @@ -403,6 +420,7 @@ static unsigned int nf_flow_queue_xmit(struct net *net, struct sk_buff *skb,
>  		ret = NF_STOLEN;
>  		break;
>  	case FLOW_OFFLOAD_XMIT_DIRECT:
> +		nf_flow_encap_push(skb, &flow->tuplehash[!dir]);
>  		ret = nf_flow_queue_xmit(state->net, skb, tuplehash, ETH_P_IP);
>  		if (ret == NF_DROP)
>  			flow_offload_teardown(flow);
> @@ -659,6 +677,7 @@ static int nf_flow_tuple_ipv6(struct sk_buff *skb, const struct net_device *dev,
>  		ret = NF_STOLEN;
>  		break;
>  	case FLOW_OFFLOAD_XMIT_DIRECT:
> +		nf_flow_encap_push(skb, &flow->tuplehash[!dir]);
>  		ret = nf_flow_queue_xmit(state->net, skb, tuplehash, ETH_P_IPV6);
>  		if (ret == NF_DROP)
>  			flow_offload_teardown(flow);
> diff --git a/net/netfilter/nft_flow_offload.c b/net/netfilter/nft_flow_offload.c
> index 900d48c..f9837c9 100644
> --- a/net/netfilter/nft_flow_offload.c
> +++ b/net/netfilter/nft_flow_offload.c
> @@ -119,12 +119,15 @@ static void nft_dev_path_info(const struct net_device_path_stack *stack,
>  				info->indev = NULL;
>  				break;
>  			}
> -			info->outdev = path->dev;
>  			info->encap[info->num_encaps].id = path->encap.id;
>  			info->encap[info->num_encaps].proto = path->encap.proto;
>  			info->num_encaps++;
> -			if (path->type == DEV_PATH_PPPOE)
> +			if (path->type == DEV_PATH_PPPOE) {
> +				info->outdev = path->dev;
>  				memcpy(info->h_dest, path->encap.h_dest, ETH_ALEN);
> +			}
> +			if (path->type == DEV_PATH_VLAN)
> +				info->xmit_type = FLOW_OFFLOAD_XMIT_DIRECT;
>  			break;
>  		case DEV_PATH_BRIDGE:
>  			if (is_zero_ether_addr(info->h_source))
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2022-04-27 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 14:38 [PATCH nf-next] nf_flow_table_offload: offload the vlan encap in the flowtable wenx05124561
2022-04-27 14:10 ` Pablo Neira Ayuso [this message]
2022-04-27 15:28   ` wenxu
2022-04-27 15:55     ` Pablo Neira Ayuso
2022-04-27 16:30       ` wenxu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YmlO009uqhJNnBq7@salvia \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=wenxu@chinatelecom.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.