[RTNL]: Introduce the rtnl_kill_links helper.
This one is responsible for calling ->dellink on each net device found in net to help with vlan net_exit hook in the nearest future. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
3a931a80cb
Коммит
669f87baab
|
@ -74,6 +74,7 @@ struct rtnl_link_ops {
|
||||||
|
|
||||||
extern int __rtnl_link_register(struct rtnl_link_ops *ops);
|
extern int __rtnl_link_register(struct rtnl_link_ops *ops);
|
||||||
extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
|
extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
|
||||||
|
extern void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops);
|
||||||
|
|
||||||
extern int rtnl_link_register(struct rtnl_link_ops *ops);
|
extern int rtnl_link_register(struct rtnl_link_ops *ops);
|
||||||
extern void rtnl_link_unregister(struct rtnl_link_ops *ops);
|
extern void rtnl_link_unregister(struct rtnl_link_ops *ops);
|
||||||
|
|
|
@ -269,6 +269,26 @@ int rtnl_link_register(struct rtnl_link_ops *ops)
|
||||||
|
|
||||||
EXPORT_SYMBOL_GPL(rtnl_link_register);
|
EXPORT_SYMBOL_GPL(rtnl_link_register);
|
||||||
|
|
||||||
|
static void __rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops)
|
||||||
|
{
|
||||||
|
struct net_device *dev;
|
||||||
|
restart:
|
||||||
|
for_each_netdev(net, dev) {
|
||||||
|
if (dev->rtnl_link_ops == ops) {
|
||||||
|
ops->dellink(dev);
|
||||||
|
goto restart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops)
|
||||||
|
{
|
||||||
|
rtnl_lock();
|
||||||
|
__rtnl_kill_links(net, ops);
|
||||||
|
rtnl_unlock();
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(rtnl_kill_links);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink.
|
* __rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink.
|
||||||
* @ops: struct rtnl_link_ops * to unregister
|
* @ops: struct rtnl_link_ops * to unregister
|
||||||
|
@ -277,17 +297,10 @@ EXPORT_SYMBOL_GPL(rtnl_link_register);
|
||||||
*/
|
*/
|
||||||
void __rtnl_link_unregister(struct rtnl_link_ops *ops)
|
void __rtnl_link_unregister(struct rtnl_link_ops *ops)
|
||||||
{
|
{
|
||||||
struct net_device *dev;
|
|
||||||
struct net *net;
|
struct net *net;
|
||||||
|
|
||||||
for_each_net(net) {
|
for_each_net(net) {
|
||||||
restart:
|
__rtnl_kill_links(net, ops);
|
||||||
for_each_netdev(net, dev) {
|
|
||||||
if (dev->rtnl_link_ops == ops) {
|
|
||||||
ops->dellink(dev);
|
|
||||||
goto restart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
list_del(&ops->list);
|
list_del(&ops->list);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче