Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: netpoll: extract core of netpoll_cleanup

Extract the core part of netpoll_cleanup(), so, it could be called from
a caller that has the rtnl lock already.

Netconsole uses this in a weird way right now:

__netpoll_cleanup(&nt->np);
spin_lock_irqsave(&target_list_lock, flags);
netdev_put(nt->np.dev, &nt->np.dev_tracker);
nt->np.dev = NULL;
nt->enabled = false;

This will be replaced by do_netpoll_cleanup() as the locking situation
is overhauled.

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Rik van Riel <riel@surriel.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Breno Leitao and committed by
Paolo Abeni
1ef33652 2bbf1aed

+10 -3
+1
include/linux/netpoll.h
··· 64 64 void __netpoll_cleanup(struct netpoll *np); 65 65 void __netpoll_free(struct netpoll *np); 66 66 void netpoll_cleanup(struct netpoll *np); 67 + void do_netpoll_cleanup(struct netpoll *np); 67 68 netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); 68 69 69 70 #ifdef CONFIG_NETPOLL
+9 -3
net/core/netpoll.c
··· 853 853 } 854 854 EXPORT_SYMBOL_GPL(__netpoll_free); 855 855 856 + void do_netpoll_cleanup(struct netpoll *np) 857 + { 858 + __netpoll_cleanup(np); 859 + netdev_put(np->dev, &np->dev_tracker); 860 + np->dev = NULL; 861 + } 862 + EXPORT_SYMBOL(do_netpoll_cleanup); 863 + 856 864 void netpoll_cleanup(struct netpoll *np) 857 865 { 858 866 rtnl_lock(); 859 867 if (!np->dev) 860 868 goto out; 861 - __netpoll_cleanup(np); 862 - netdev_put(np->dev, &np->dev_tracker); 863 - np->dev = NULL; 869 + do_netpoll_cleanup(np); 864 870 out: 865 871 rtnl_unlock(); 866 872 }