Subject: Re: [BUG net-next] infamous dev refcnt leak... again.

From: David Ahern <[email-masked]>
Date: Fri, 14 Aug 2015 17:19:18 -0600

On 8/14/15 5:14 PM, Eric Dumazet wrote:
> On Fri, 2015-08-14 at 14:14 -0700, Eric Dumazet wrote:
>> While rebooting host running latest net-next
>>
>>   unregister_netdevice: waiting for eth0 to become free. Usage count = 4
>>
>> Oh well...
>>
>
> It looks like David Ahern recent changes uncover a bug ?
>
> Not clear which commit is at fault.
>
> Maybe 3bfd847203c6d89532f836ad3f5b4ff4ced26dd9 ?
>
> Somehow a down device can be found.

Can you elaborate on what you are doing to see the refcnt leak? I have 
not seen that at all. I have to leave for soccer carpool in 45 minutes 
or so, but can take a look this weekend.

David

>
> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
> index b7f1d20..675a3b6 100644
> --- a/net/ipv4/fib_semantics.c
> +++ b/net/ipv4/fib_semantics.c
> @@ -725,10 +725,14 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
>   		nh->nh_dev = dev = FIB_RES_DEV(res);
>   		if (!dev)
>   			goto out;
> -		dev_hold(dev);
>   		if (!netif_carrier_ok(dev))
>   			nh->nh_flags |= RTNH_F_LINKDOWN;
> -		err = (dev->flags & IFF_UP) ? 0 : -ENETDOWN;
> +		if (dev->flags & IFF_UP) {
> +			err = 0;
> +			dev_hold(dev);
> +		} else {
> +			err = -ENETDOWN;
> +		}
>   	} else {
>   		struct in_device *in_dev;
>
>
>