diff mbox series

[net-next] netfilter: nft_tunnel: Add dst_cache support

Message ID 1550826043-21278-1-git-send-email-wenxu@ucloud.cn
State Accepted
Delegated to: Pablo Neira
Headers show
Series [net-next] netfilter: nft_tunnel: Add dst_cache support | expand

Commit Message

wenxu Feb. 22, 2019, 9 a.m. UTC
From: wenxu <wenxu@ucloud.cn>

The metadata_dst is not init the dst_cache which make the
ip_md_tunnel_xmit can't use the dst_cache. It will lookup
route table every packets.

Signed-off-by: wenxu <wenxu@ucloud.cn>
---
 net/netfilter/nft_tunnel.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Pablo Neira Ayuso March 1, 2019, 1:28 p.m. UTC | #1
On Fri, Feb 22, 2019 at 05:00:43PM +0800, wenxu@ucloud.cn wrote:
> From: wenxu <wenxu@ucloud.cn>
> 
> The metadata_dst is not init the dst_cache which make the
> ip_md_tunnel_xmit can't use the dst_cache. It will lookup
> route table every packets.

Applied, thanks.

One comment below:

> Signed-off-by: wenxu <wenxu@ucloud.cn>
> ---
>  net/netfilter/nft_tunnel.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/net/netfilter/nft_tunnel.c b/net/netfilter/nft_tunnel.c
> index ea28588..b113fca 100644
> --- a/net/netfilter/nft_tunnel.c
> +++ b/net/netfilter/nft_tunnel.c
> @@ -406,6 +406,13 @@ static int nft_tunnel_obj_init(const struct nft_ctx *ctx,
>  		return -ENOMEM;
>  
>  	memcpy(&md->u.tun_info, &info, sizeof(info));
> +#ifdef CONFIG_DST_CACHE

To reduce ifdef pollution, it would be good to turn dst_cache_init()
into noop via static inline trick in case CONFIG_DST_CACHE=n.

BTW, I suspect net/sched/act_tunnel_key.c also needs a similar update.

> +	err = dst_cache_init(&md->u.tun_info.dst_cache, GFP_KERNEL);
> +	if (err < 0) {
> +		metadata_dst_free(md);
> +		return err;
> +	}
> +#endif
>  	ip_tunnel_info_opts_set(&md->u.tun_info, &priv->opts.u, priv->opts.len,
>  				priv->opts.flags);
>  	priv->md = md;
> -- 
> 1.8.3.1
>
diff mbox series

Patch

diff --git a/net/netfilter/nft_tunnel.c b/net/netfilter/nft_tunnel.c
index ea28588..b113fca 100644
--- a/net/netfilter/nft_tunnel.c
+++ b/net/netfilter/nft_tunnel.c
@@ -406,6 +406,13 @@  static int nft_tunnel_obj_init(const struct nft_ctx *ctx,
 		return -ENOMEM;
 
 	memcpy(&md->u.tun_info, &info, sizeof(info));
+#ifdef CONFIG_DST_CACHE
+	err = dst_cache_init(&md->u.tun_info.dst_cache, GFP_KERNEL);
+	if (err < 0) {
+		metadata_dst_free(md);
+		return err;
+	}
+#endif
 	ip_tunnel_info_opts_set(&md->u.tun_info, &priv->opts.u, priv->opts.len,
 				priv->opts.flags);
 	priv->md = md;