• Kirill Tkhai's avatar
    net: Do not take net_rwsem in __rtnl_link_unregister() · 554873e5
    Kirill Tkhai authored
    This function calls call_netdevice_notifier(), which also
    may take net_rwsem. So, we can't use net_rwsem here.
    
    This patch makes callers of this functions take pernet_ops_rwsem,
    like register_netdevice_notifier() does. This will protect
    the modifications of net_namespace_list, and allows notifiers
    to take it (they won't have to care about context).
    
    Since __rtnl_link_unregister() is used on module load
    and unload (which are not frequent operations), this looks
    for me better, than make all call_netdevice_notifier()
    always executing in "protected net_namespace_list" context.
    
    Also, this fixes the problem we had a deal in 328fbe74
    "Close race between {un, }register_netdevice_notifier and ...",
    and guarantees __rtnl_link_unregister() does not skip
    exitting net.
    Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    554873e5
ifb.c 8.6 KB