netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: wenxu@ucloud.cn
Cc: fw@strlen.de, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next 4/5] netfilter: nft_tunnel: support NFT_TUNNEL_IPV6_SRC/DST match
Date: Fri, 15 Nov 2019 23:56:18 +0100	[thread overview]
Message-ID: <20191115225618.ldjjmd2c27vxoorw@salvia> (raw)
In-Reply-To: <1571913336-13431-5-git-send-email-wenxu@ucloud.cn>

On Thu, Oct 24, 2019 at 06:35:35PM +0800, wenxu@ucloud.cn wrote:
> From: wenxu <wenxu@ucloud.cn>
> 
> Add new two NFT_TUNNEL_IPV6_SRC/DST match in nft_tunnel
> 
> Signed-off-by: wenxu <wenxu@ucloud.cn>
> ---
>  include/uapi/linux/netfilter/nf_tables.h |  2 ++
>  net/netfilter/nft_tunnel.c               | 28 ++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
> index 7f65019..584868d 100644
> --- a/include/uapi/linux/netfilter/nf_tables.h
> +++ b/include/uapi/linux/netfilter/nf_tables.h
> @@ -1777,6 +1777,8 @@ enum nft_tunnel_keys {
>  	NFT_TUNNEL_ID,
>  	NFT_TUNNEL_IPV4_SRC,
>  	NFT_TUNNEL_IPV4_DST,
> +	NFT_TUNNEL_IPV6_SRC,
> +	NFT_TUNNEL_IPV6_DST,
>  	__NFT_TUNNEL_MAX
>  };
>  #define NFT_TUNNEL_MAX	(__NFT_TUNNEL_MAX - 1)
> diff --git a/net/netfilter/nft_tunnel.c b/net/netfilter/nft_tunnel.c
> index 580b51b..0a3005d 100644
> --- a/net/netfilter/nft_tunnel.c
> +++ b/net/netfilter/nft_tunnel.c
> @@ -96,6 +96,30 @@ static void nft_tunnel_get_eval(const struct nft_expr *expr,
>  		else
>  			regs->verdict.code = NFT_BREAK;
>  		break;
> +	case NFT_TUNNEL_IPV6_SRC:
> +		if (!tun_info) {
> +			regs->verdict.code = NFT_BREAK;
> +			return;
> +		}
> +		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode,
> +					     NFT_INET_IPV6_TYPE))

And here, add nft_tunnel_mode_match_ip6().

> +			memcpy(dest, &tun_info->key.u.ipv6.src,
> +			       sizeof(struct in6_addr));
> +		else
> +			regs->verdict.code = NFT_BREAK;
> +		break;
> +	case NFT_TUNNEL_IPV6_DST:
> +		if (!tun_info) {
> +			regs->verdict.code = NFT_BREAK;
> +			return;
> +		}
> +		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode,
> +					     NFT_INET_IPV6_TYPE))
> +			memcpy(dest, &tun_info->key.u.ipv6.dst,
> +			       sizeof(struct in6_addr));
> +		else
> +			regs->verdict.code = NFT_BREAK;
> +		break;
>  	default:
>  		WARN_ON(1);
>  		regs->verdict.code = NFT_BREAK;
> @@ -129,6 +153,10 @@ static int nft_tunnel_get_init(const struct nft_ctx *ctx,
>  	case NFT_TUNNEL_IPV4_DST:
>  		len = sizeof(u32);
>  		break;
> +	case NFT_TUNNEL_IPV6_SRC:
> +	case NFT_TUNNEL_IPV6_DST:
> +		len = sizeof(struct in6_addr);
> +		break;
>  	default:
>  		return -EOPNOTSUPP;
>  	}
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2019-11-15 22:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 10:35 [PATCH nf-next 0/5] netfilter: nft_tunnel: support tunnel match expr offload wenxu
2019-10-24 10:35 ` [PATCH nf-next 1/5] netfilter: nft_tunnel: add nft_tunnel_mode_validate function wenxu
2019-11-15 22:52   ` Pablo Neira Ayuso
2019-10-24 10:35 ` [PATCH nf-next 2/5] netfilter: nft_tunnel: support NFT_TUNNEL_IPV4_SRC/DST match wenxu
2019-10-27 10:32   ` kbuild test robot
2019-10-24 10:35 ` [PATCH nf-next 3/5] netfilter: nft_tunnel: add inet type check in nft_tunnel_mode_validate wenxu
2019-11-15 22:55   ` Pablo Neira Ayuso
2019-10-24 10:35 ` [PATCH nf-next 4/5] netfilter: nft_tunnel: support NFT_TUNNEL_IPV6_SRC/DST match wenxu
2019-11-15 22:56   ` Pablo Neira Ayuso [this message]
2019-10-24 10:35 ` [PATCH nf-next 5/5] netfilter: nft_tunnel: add nft_tunnel_get_offload support 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=20191115225618.ldjjmd2c27vxoorw@salvia \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=wenxu@ucloud.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).