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

[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>

authored by

Pavel Emelyanov and committed by
David S. Miller
669f87ba 3a931a80

+22 -8
+1
include/net/rtnetlink.h
··· 74 74 75 75 extern int __rtnl_link_register(struct rtnl_link_ops *ops); 76 76 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops); 77 + extern void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops); 77 78 78 79 extern int rtnl_link_register(struct rtnl_link_ops *ops); 79 80 extern void rtnl_link_unregister(struct rtnl_link_ops *ops);
+21 -8
net/core/rtnetlink.c
··· 269 269 270 270 EXPORT_SYMBOL_GPL(rtnl_link_register); 271 271 272 + static void __rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops) 273 + { 274 + struct net_device *dev; 275 + restart: 276 + for_each_netdev(net, dev) { 277 + if (dev->rtnl_link_ops == ops) { 278 + ops->dellink(dev); 279 + goto restart; 280 + } 281 + } 282 + } 283 + 284 + void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops) 285 + { 286 + rtnl_lock(); 287 + __rtnl_kill_links(net, ops); 288 + rtnl_unlock(); 289 + } 290 + EXPORT_SYMBOL_GPL(rtnl_kill_links); 291 + 272 292 /** 273 293 * __rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink. 274 294 * @ops: struct rtnl_link_ops * to unregister ··· 297 277 */ 298 278 void __rtnl_link_unregister(struct rtnl_link_ops *ops) 299 279 { 300 - struct net_device *dev; 301 280 struct net *net; 302 281 303 282 for_each_net(net) { 304 - restart: 305 - for_each_netdev(net, dev) { 306 - if (dev->rtnl_link_ops == ops) { 307 - ops->dellink(dev); 308 - goto restart; 309 - } 310 - } 283 + __rtnl_kill_links(net, ops); 311 284 } 312 285 list_del(&ops->list); 313 286 }