From: Ido Schimmel <idosch@idosch.org>
To: Wei Wang <weiwan@google.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
John Stultz <john.stultz@linaro.org>,
Martin KaFai Lau <kafai@fb.com>,
lkml <linux-kernel@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>,
Linux USB List <linux-usb@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Felipe Balbi <felipe.balbi@linux.intel.com>
Subject: Re: unregister_netdevice: waiting for eth0 to become free. Usage count = 1
Date: Sat, 12 Aug 2017 21:01:29 +0300 [thread overview]
Message-ID: <20170812180129.GA31700@splinter> (raw)
In-Reply-To: <CAEA6p_COwXWP97wSHvzokmm8ckQ2QEd7=dfNH04ttDPm_z3bcg@mail.gmail.com>
Hi Wei,
On Fri, Aug 11, 2017 at 05:10:02PM -0700, Wei Wang wrote:
> I think we have a potential fix for this issue.
> Martin and I found that when addrconf_dst_alloc() creates a rt6, it is
> possible that rt6->dst.dev points to loopback device while
> rt6->rt6i_idev->dev points to a real device.
> When the real device goes down, the current fib6 clean up code only
> checks for rt6->dst.dev and assumes rt6->rt6i_idev->dev is the same.
> That leaves unreleased refcnt on the real device if rt6->dst.dev
> points to loopback dev.
[...]
> From 2d8861808c2029013f6b6e86120ba6902329145b Mon Sep 17 00:00:00 2001
> From: Wei Wang <weiwan@google.com>
> Date: Fri, 11 Aug 2017 16:36:04 -0700
> Subject: [PATCH 1/2] potential fix for unregister_netdevice()
>
> Change-Id: I5d5f6f7a7ad0f5dd769f33487db17ff2570d52ea
> ---
> net/ipv6/route.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 4d30c96a819d..105922903932 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -417,14 +417,12 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
> struct net_device *loopback_dev =
> dev_net(dev)->loopback_dev;
>
> - if (dev != loopback_dev) {
> - if (idev && idev->dev == dev) {
> - struct inet6_dev *loopback_idev =
> - in6_dev_get(loopback_dev);
> - if (loopback_idev) {
> - rt->rt6i_idev = loopback_idev;
> - in6_dev_put(idev);
> - }
> + if (idev && idev->dev != loopback_dev) {
> + struct inet6_dev *loopback_idev =
> + in6_dev_get(loopback_dev);
> + if (loopback_idev) {
> + rt->rt6i_idev = loopback_idev;
> + in6_dev_put(idev);
> }
> }
> }
> @@ -2789,7 +2787,8 @@ static int fib6_ifdown(struct rt6_info *rt, void *arg)
> const struct arg_dev_net *adn = arg;
> const struct net_device *dev = adn->dev;
>
> - if ((rt->dst.dev == dev || !dev) &&
> + if ((rt->dst.dev == dev || !dev ||
> + rt->rt6i_idev->dev == dev) &&
Can you please explain why this line is needed? While host routes aren't
removed from the FIB by rt6_ifdown() (when dst.dev goes down), they are
removed later on in addrconf_ifdown().
With your patch, if I check the return value of ip6_del_rt() in
__ipv6_ifa_notify() I see that -ENONET is returned. Because the host
route was already removed by rt6_ifdown(). When the line in question is
removed from the patch I don't get the error anymore.
Is it possible that in John's case the host route was correctly removed
from the FIB and that the unreleased reference was due to a wrong check
in ip6_dst_ifdown() (which you patched correctly AFAICT)?
Thanks
> rt != adn->net->ipv6.ip6_null_entry &&
> (rt->rt6i_nsiblings == 0 ||
> (dev && netdev_unregistering(dev)) ||
> --
> 2.14.0.434.g98096fd7a8-goog
>
next prev parent reply other threads:[~2017-08-12 18:11 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 21:05 unregister_netdevice: waiting for eth0 to become free. Usage count = 1 John Stultz
2017-08-07 21:15 ` John Stultz
2017-08-09 23:34 ` Cong Wang
2017-08-09 23:44 ` John Stultz
2017-08-10 0:36 ` Wei Wang
2017-08-10 0:44 ` John Stultz
2017-08-10 1:26 ` John Stultz
2017-08-10 1:36 ` Wei Wang
2017-08-10 1:36 ` Wei Wang
2017-08-10 5:41 ` Wei Wang
2017-08-10 18:12 ` John Stultz
2017-08-10 20:06 ` Wei Wang
2017-08-11 16:48 ` Cong Wang
2017-08-11 17:25 ` Wei Wang
2017-08-12 0:10 ` Wei Wang
2017-08-12 0:10 ` Wei Wang
2017-08-12 0:19 ` David Ahern
2017-08-12 0:25 ` Wei Wang
2017-08-12 3:37 ` David Ahern
2017-08-12 3:37 ` David Ahern
2017-08-12 19:29 ` Wei Wang
2017-08-12 0:31 ` John Stultz
2017-08-12 0:46 ` Wei Wang
2017-08-12 3:07 ` John Stultz
2017-08-12 19:28 ` Wei Wang
2017-08-12 19:29 ` Wei Wang
2017-08-12 18:01 ` Ido Schimmel [this message]
2017-08-12 19:42 ` Wei Wang
2017-08-13 16:24 ` David Ahern
2017-08-13 20:56 ` Wei Wang
2017-08-13 23:08 ` David Ahern
2017-08-13 23:08 ` David Ahern
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=20170812180129.GA31700@splinter \
--to=idosch@idosch.org \
--cc=davem@davemloft.net \
--cc=felipe.balbi@linux.intel.com \
--cc=john.stultz@linaro.org \
--cc=kafai@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=weiwan@google.com \
--cc=xiyou.wangcong@gmail.com \
/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.