All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: David Miller <davem@davemloft.net>,
	cwang@twopensource.com, netdev@vger.kernel.org
Subject: Re: [PATCH v2 net] ipv6: clean up anycast when an interface is destroyed
Date: Fri, 12 Sep 2014 21:45:13 +0200	[thread overview]
Message-ID: <1410551113.2970.12.camel@localhost> (raw)
In-Reply-To: <20140910212302.GA26184@kria>

On Mi, 2014-09-10 at 23:23 +0200, Sabrina Dubroca wrote:
> If we try to rmmod the driver for an interface while sockets with
> setsockopt(JOIN_ANYCAST) are alive, some refcounts aren't cleaned up
> and we get stuck on:
> 
>   unregister_netdevice: waiting for ens3 to become free. Usage count = 1
> 
> If we LEAVE_ANYCAST/close everything before rmmod'ing, there is no
> problem.
> 
> We need to perform a cleanup similar to the one for multicast in
> addrconf_ifdown(how == 1).
> 
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>

This is the correct fix for the bug:

Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

more comments inline:

> ---
> v2: remove comment
> 
>  include/net/addrconf.h |  1 +
>  net/ipv6/addrconf.c    |  8 +++++---
>  net/ipv6/anycast.c     | 21 +++++++++++++++++++++
>  3 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/include/net/addrconf.h b/include/net/addrconf.h
> index f679877bb601..ec51e673b4b6 100644
> --- a/include/net/addrconf.h
> +++ b/include/net/addrconf.h
> @@ -204,6 +204,7 @@ void ipv6_sock_ac_close(struct sock *sk);
>  
>  int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
>  int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
> +void ipv6_ac_destroy_dev(struct inet6_dev *idev);
>  bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
>  			 const struct in6_addr *addr);
>  bool ipv6_chk_acast_addr_src(struct net *net, struct net_device *dev,
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index fc1fac2a0528..3342ee64f2e3 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -3094,11 +3094,13 @@ static int addrconf_ifdown(struct net_device *dev, int how)
>  
>  	write_unlock_bh(&idev->lock);
>  
> -	/* Step 5: Discard multicast list */
> -	if (how)
> +	/* Step 5: Discard anycast and multicast list */
> +	if (how) {
> +		ipv6_ac_destroy_dev(idev);
>  		ipv6_mc_destroy_dev(idev);
> -	else
> +	} else {
>  		ipv6_mc_down(idev);
> +	}

Do we also need to provide a ipv6_ac_down function to unload all anycast
sources when we ifdown an interface (we need to keep the entries in
aca_list around and activate them when we initialize the interface
again)?
 
Thanks,
Hannes

  reply	other threads:[~2014-09-12 19:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 10:27 [PATCH net] ipv6: clean up anycast when an interface is destroyed Sabrina Dubroca
2014-09-10 17:15 ` Cong Wang
2014-09-10 20:58   ` David Miller
2014-09-10 21:23     ` [PATCH v2 " Sabrina Dubroca
2014-09-12 19:45       ` Hannes Frederic Sowa [this message]
2014-09-12 21:33       ` David Miller

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=1410551113.2970.12.camel@localhost \
    --to=hannes@stressinduktion.org \
    --cc=cwang@twopensource.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=sd@queasysnail.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.