Subject: Re: Correct usage of dev_base_lock in 2020

From: Stephen Hemminger <[email-masked]>
Date: Mon, 30 Nov 2020 12:21:29 -0800

On Mon, 30 Nov 2020 21:46:17 +0200
Vladimir Oltean <[email-masked]> wrote:

> On Mon, Nov 30, 2020 at 08:22:01PM +0100, Eric Dumazet wrote:
> > And ?
> >
> > A bonding device can absolutely maintain a private list, ready for
> > bonding ndo_get_stats() use, regardless
> > of register/unregister logic.
> >
> > bond_for_each_slave() is simply a macro, you can replace it by something else.  
> 
> Also, coming to take the comment at face value.
> Can it really? How? Freeing a net_device at unregister time happens
> after an RCU grace period. So whatever the bonding driver does to keep a
> private list of slave devices, those pointers need to be under RCU
> protection. And that doesn't help with the sleepable context that we're
> looking for.

if device is in a private list (in bond device), the way to handle
this is to use dev_hold() to keep a ref count.