Patch "net: replace dst_cache ip6_tunnel implementation with the generic one" has been added to the 4.4-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
net: replace dst_cache ip6_tunnel implementation with the generic one
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
net-replace-dst_cache-ip6_tunnel-implementation-with-the-generic-one.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
607f725f6f7d5ec3759fbc16224afb60e2152a5bMon Sep 17 00:00:00 2001
From: Paolo Abeni <[email protected]>
Date: Fri, 12 Feb 2016 15:43:54 +0100
Subject: net: replace dst_cache ip6_tunnel implementation with the generic one
From: Paolo Abeni <[email protected]>
commit 607f725f6f7d5ec3759fbc16224afb60e2152a5b upstream.
This also fix a potential race into the existing tunnel code, which could lead to the wrong dst to be permanenty cached:
CPU1: CPU2:
<xmit on ip6_tunnel>
<cache lookup fails>
dst = ip6_route_output(...)
<tunnel params are changed via nl> dst_cache_reset() // no effect,
// the cache is empty
dst_cache_set() // the wrong dst
// is permanenty stored // into the cache
With the new dst implementation the above race is not possible since the first cache lookup after dst_cache_reset will fail due to the timestamp check
--- include/net/ip6_tunnel.h | 15 ---- net/ipv6/Kconfig | 1 net/ipv6/ip6_gre.c | 12 +-- net/ipv6/ip6_tunnel.c | 151 +++++++---------------------------------------- net/ipv6/ip6_vti.c | 2 5 files changed, 35 insertions(+), 146 deletions(-)
include/net/ip6_tunnel.h +3 -12
@@ -5,6 +5,8 @@#include <linux/netdevice.h> #include <linux/if_tunnel.h> #include <linux/ip6_tunnel.h> +#include <net/ip_tunnels.h> +#include <net/dst_cache.h> #define IP6TUNNEL_ERR_TIMEO (30*HZ)
@@ -32,12 +34,6 @@ struct __ip6_tnl_parm {__be32 o_key; }; -struct ip6_tnl_dst { -seqlock_t lock; -struct dst_entry __rcu *dst; -u32 cookie; -}; -/* IPv6 tunnel */ struct ip6_tnl {struct ip6_tnl __rcu *next;/* next tunnel in list */
@@ -45,7 +41,7 @@ struct ip6_tnl {struct net *net;/* netns for packet i/o */ struct __ip6_tnl_parm parms;/* tunnel configuration parameters */ struct flowi fl;/* flowi template for xmit */ -struct ip6_tnl_dst __percpu *dst_cache;/* cached dst */ +struct dst_cache dst_cache;/* cached dst */ int err_count;unsigned long err_time;
@@ -65,11 +61,6 @@ struct ipv6_tlv_tnl_enc_lim {__u8 encap_limit;/* tunnel encapsulation limit */ } __packed; -struct dst_entry *ip6_tnl_dst_get (struct ip6_tnl *t); -int ip6_tnl_dst_init (struct ip6_tnl *t); -void ip6_tnl_dst_destroy (struct ip6_tnl *t); -void ip6_tnl_dst_reset (struct ip6_tnl *t); -void ip6_tnl_dst_set (struct ip6_tnl *t,struct dst_entry *dst);int ip6_tnl_rcv_ctl (struct ip6_tnl *t,const struct in6_addr *laddr,const struct in6_addr *raddr); int ip6_tnl_xmit_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
net/ipv6/Kconfig +1 -0
@@ -205,6 +205,7 @@ config IPV6_NDISC_NODETYPE config IPV6_TUNNEL tristate "IPv6: IP-in-IPv6 tunnel (RFC2473)" select INET6_TUNNEL + select DST_CACHE ---help--- Support for IPv6-in-IPv6 and IPv4-in-IPv6 tunnels described in RFC 2473.
net/ipv6/ip6_gre.c +6 -6
@@ -362,7 +362,7 @@ static void ip6gre_tunnel_uninit(structstruct ip6gre_net *ign =net_generic (t->net, ip6gre_net_id);ip6gre_tunnel_unlink (ign, t); -ip6_tnl_dst_reset (t); +dst_cache_reset (&t->dst_cache);dev_put (dev); }
@@ -640,7 +640,7 @@ static netdev_tx_t ip6gre_xmit2(struct s }if (!fl6->flowi6_mark) - dst =ip6_tnl_dst_get (tunnel); + dst =dst_cache_get (&tunnel->dst_cache);if (!dst) { dst =ip6_route_output (net,NULL , fl6);
@@ -709,7 +709,7 @@ static netdev_tx_t ip6gre_xmit2(struct s }if (!fl6->flowi6_mark && ndst) -ip6_tnl_dst_set (tunnel, ndst); +dst_cache_set_ip6 (&tunnel->dst_cache, ndst, &fl6->saddr);skb_dst_set (skb, dst); proto =NEXTHDR_GRE ;
@@ -1017,7 +1017,7 @@ static int ip6gre_tnl_change(struct ip6_ t->parms.o_key = p->o_key; t->parms.i_flags = p->i_flags; t->parms.o_flags = p->o_flags; -ip6_tnl_dst_reset (t); +dst_cache_reset (&t->dst_cache);ip6gre_tnl_link_config (t, set_mtu);return 0 ; }
@@ -1228,7 +1228,7 @@ static void ip6gre_dev_free(struct net_d {struct ip6_tnl *t =netdev_priv (dev); -ip6_tnl_dst_destroy (t); +dst_cache_destroy (&t->dst_cache);free_percpu (dev->tstats);free_netdev (dev); }
@@ -1266,7 +1266,7 @@ static int ip6gre_tunnel_init_common(strif (!dev->tstats)return -ENOMEM ; - ret =ip6_tnl_dst_init (tunnel); + ret =dst_cache_init (&tunnel->dst_cache,GFP_KERNEL );if (ret) {free_percpu (dev->tstats); dev->tstats =NULL ;
net/ipv6/ip6_tunnel.c +24 -127
203 lines not on this page · raw message
net/ipv6/ip6_vti.c +1 -1
@@ -645,7 +645,7 @@ vti6_tnl_change(struct ip6_tnl *t, const t->parms.i_key = p->i_key; t->parms.o_key = p->o_key; t->parms.proto = p->proto; -ip6_tnl_dst_reset (t); +dst_cache_reset (&t->dst_cache);vti6_link_config (t);return 0 ; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/net-add-dst_cache-support.patch queue-4.4/net-replace-dst_cache-ip6_tunnel-implementation-with-the-generic-one.patch queue-4.4/netfilter-on-sockopt-acquire-sock-lock-only-in-the-required-scope.patch