On Wed, Dec 20, 2017 at 01:43:13PM +0100, Martin Pieuchot wrote:
> > rtm_ifchg() calls route_input() which needs the net lock.
> 
> Does it?  What needs the lock in route_input()?  I thought routing
> sockets are still protected by the KERNEL_LOCK().

My fault.  I have misread the code.  Your change is fine.

> > May we access the ifp->if_flags without net lock?  As we want to
> > compare them to their value before we changed them, would it be
> > even better to put the "oif_flags = ifp->if_flags;" under the lock?
> 
> Flags are modified by the driver, not by the stack.  Some of them are
> event immutable and might be better moved to a different field.

You have marked if_flags and if_xflags with an [N].  Reading happens
everywhere in the stack.  Carp changes them often.  I think we have
the kernel lock there.  Note that if_flags is short so access is
not atomic.

Perhaps we should split the flags like I did with the sb_flagsintr
a long time ago.  Changing them to int would be an easy first step.

> The goal is to stop grabbing the lock for per-driver ioctl(2).  This
> would fix the problem that sleeping in if_ioctl() might block network
> traffic for a long time.  That means the limit between driver and stack
> fields have to be clear.  You just pointed out that `if_flags' has some
> issues.

Thanks for the explanation.  The goal sounds reasonable.  But that
means we have to check all the drivers and especially the pseudo-drivers'
ioctl functions before unlocking (*ifp->if_ioctl)().

bluhm

Reply via email to