[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170425171846.ldh3hwg2hrrqlffu@kafai-mba.local>
Date: Tue, 25 Apr 2017 10:18:46 -0700
From: Martin KaFai Lau <kafai@...com>
To: David Ahern <dsa@...ulusnetworks.com>
CC: <netdev@...r.kernel.org>, <dvyukov@...gle.com>,
<andreyknvl@...gle.com>, <mmanning@...cade.com>,
<eric.dumazet@...il.com>
Subject: Re: [PATCH v4 net] net: ipv6: regenerate host route if moved to gc
list
On Tue, Apr 25, 2017 at 09:17:29AM -0700, David Ahern wrote:
[...]
>
> All of those faults are fixed by regenerating the host route if the
> existing one has been moved to the gc list, something that can be
> determined by checking if the rt6i_ref counter is 0.
Acked-by: Martin KaFai Lau <kafai@...com>
>
> Fixes: f1705ec197e7 ("net: ipv6: Make address flushing on ifdown optional")
> Reported-by: Dmitry Vyukov <dvyukov@...gle.com>
> Reported-by: Andrey Konovalov <andreyknvl@...gle.com>
> Signed-off-by: David Ahern <dsa@...ulusnetworks.com>
> ---
> v4
> - move 'prev = ifp->rt;' under spinlock as requested by Eric
>
> v3
> - removed 'if (prev)' and just call ip6_rt_put; added comment about spinlock
>
> v2
> - change ifp->rt under spinlock vs cmpxchg
> - add comment about rt6i_ref == 0
>
> net/ipv6/addrconf.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 80ce478c4851..0ea96c4d334d 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -3271,14 +3271,24 @@ static void addrconf_gre_config(struct net_device *dev)
> static int fixup_permanent_addr(struct inet6_dev *idev,
> struct inet6_ifaddr *ifp)
> {
> - if (!ifp->rt) {
> - struct rt6_info *rt;
> + /* rt6i_ref == 0 means the host route was removed from the
> + * FIB, for example, if 'lo' device is taken down. In that
> + * case regenerate the host route.
> + */
> + if (!ifp->rt || !atomic_read(&ifp->rt->rt6i_ref)) {
> + struct rt6_info *rt, *prev;
>
> rt = addrconf_dst_alloc(idev, &ifp->addr, false);
> if (unlikely(IS_ERR(rt)))
> return PTR_ERR(rt);
>
> + /* ifp->rt can be accessed outside of rtnl */
> + spin_lock(&ifp->lock);
> + prev = ifp->rt;
> ifp->rt = rt;
> + spin_unlock(&ifp->lock);
> +
> + ip6_rt_put(prev);
> }
>
> if (!(ifp->flags & IFA_F_NOPREFIXROUTE)) {
> --
> 2.1.4
>
Powered by blists - more mailing lists