netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: wenxu@ucloud.cn
To: pablo@netfilter.org, fw@strlen.de
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH nf-next v5 3/8] netfilter: nft_tunnel: add ipv6 check in nft_tunnel_mode_validate
Date: Wed, 21 Aug 2019 13:09:48 +0800	[thread overview]
Message-ID: <1566364193-31330-4-git-send-email-wenxu@ucloud.cn> (raw)
In-Reply-To: <1566364193-31330-1-git-send-email-wenxu@ucloud.cn>

From: wenxu <wenxu@ucloud.cn>

Add ipv6 tunnel check in nft_tunnel_mode_validate.

Signed-off-by: wenxu <wenxu@ucloud.cn>
---
v5: no change

 net/netfilter/nft_tunnel.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/net/netfilter/nft_tunnel.c b/net/netfilter/nft_tunnel.c
index fe544bf..64bda3d 100644
--- a/net/netfilter/nft_tunnel.c
+++ b/net/netfilter/nft_tunnel.c
@@ -18,8 +18,12 @@ struct nft_tunnel {
 	enum nft_tunnel_mode	mode:8;
 };
 
-bool nft_tunnel_mode_validate(enum nft_tunnel_mode priv_mode, u8 tun_mode)
+bool nft_tunnel_mode_validate(enum nft_tunnel_mode priv_mode,
+			      u8 tun_mode, bool ipv6)
 {
+	if (ipv6 && !(tun_mode & IP_TUNNEL_INFO_IPV6))
+		return false;
+
 	if (priv_mode == NFT_TUNNEL_MODE_NONE ||
 	    (priv_mode == NFT_TUNNEL_MODE_RX &&
 	     !(tun_mode & IP_TUNNEL_INFO_TX)) ||
@@ -46,7 +50,7 @@ static void nft_tunnel_get_eval(const struct nft_expr *expr,
 			nft_reg_store8(dest, false);
 			return;
 		}
-		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode))
+		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode, false))
 			nft_reg_store8(dest, true);
 		else
 			nft_reg_store8(dest, false);
@@ -56,7 +60,7 @@ static void nft_tunnel_get_eval(const struct nft_expr *expr,
 			regs->verdict.code = NFT_BREAK;
 			return;
 		}
-		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode))
+		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode, false))
 			*dest = ntohl(tunnel_id_to_key32(tun_info->key.tun_id));
 		else
 			regs->verdict.code = NFT_BREAK;
@@ -66,7 +70,7 @@ static void nft_tunnel_get_eval(const struct nft_expr *expr,
 			regs->verdict.code = NFT_BREAK;
 			return;
 		}
-		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode))
+		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode, false))
 			*dest = tun_info->key.u.ipv4.src;
 		else
 			regs->verdict.code = NFT_BREAK;
@@ -76,7 +80,7 @@ static void nft_tunnel_get_eval(const struct nft_expr *expr,
 			regs->verdict.code = NFT_BREAK;
 			return;
 		}
-		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode))
+		if (nft_tunnel_mode_validate(priv->mode, tun_info->mode, false))
 			*dest = tun_info->key.u.ipv4.dst;
 		else
 			regs->verdict.code = NFT_BREAK;
-- 
1.8.3.1


  parent reply	other threads:[~2019-08-21  5:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21  5:09 [PATCH nf-next v5 0/8] netfilter: nf_tables_offload: support tunnel offload wenxu
2019-08-21  5:09 ` [PATCH nf-next v5 1/8] netfilter: nft_tunnel: add nft_tunnel_mode_validate function wenxu
2019-08-21  5:09 ` [PATCH nf-next v5 2/8] netfilter: nft_tunnel: support NFT_TUNNEL_IP_SRC/DST match wenxu
2019-08-21  5:09 ` wenxu [this message]
2019-08-21  5:09 ` [PATCH nf-next v5 4/8] netfilter: nft_tunnel: support NFT_TUNNEL_IP6_SRC/DST match wenxu
2019-08-21  5:09 ` [PATCH nf-next v5 5/8] netfilter: nft_tunnel: support tunnel meta match offload wenxu
2019-08-21  5:09 ` [PATCH nf-next v5 6/8] netfilter: nft_tunnel: add NFTA_TUNNEL_KEY_RELEASE action wenxu
2019-08-21  5:09 ` [PATCH nf-next v5 7/8] netfilter: nft_objref: add nft_objref_type offload wenxu
2019-08-21  5:09 ` [PATCH nf-next v5 8/8] netfilter: nft_tunnel: support nft_tunnel_obj offload wenxu
2019-09-05  4:08 ` [PATCH nf-next v5 0/8] netfilter: nf_tables_offload: support tunnel offload 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=1566364193-31330-4-git-send-email-wenxu@ucloud.cn \
    --to=wenxu@ucloud.cn \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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).