net: add new helper unregister_netdevice_many_notify
authorHangbin Liu <liuhangbin@gmail.com>
Fri, 28 Oct 2022 08:42:22 +0000 (04:42 -0400)
committerJakub Kicinski <kuba@kernel.org>
Tue, 1 Nov 2022 01:10:21 +0000 (18:10 -0700)
Add new helper unregister_netdevice_many_notify(), pass netlink message
header and portid, which could be used to notify userspace when flag
NLM_F_ECHO is set.

Make the unregister_netdevice_many() as a wrapper of new function
unregister_netdevice_many_notify().

Suggested-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/dev.c
net/core/dev.h

index 19e0db536022a163ea9fb7e6ddaf873ad3d9f597..2e4f1c97b59e05669d3db4d0f3f03dfbbdf605c9 100644 (file)
@@ -10781,14 +10781,8 @@ void unregister_netdevice_queue(struct net_device *dev, struct list_head *head)
 }
 EXPORT_SYMBOL(unregister_netdevice_queue);
 
-/**
- *     unregister_netdevice_many - unregister many devices
- *     @head: list of devices
- *
- *  Note: As most callers use a stack allocated list_head,
- *  we force a list_del() to make sure stack wont be corrupted later.
- */
-void unregister_netdevice_many(struct list_head *head)
+void unregister_netdevice_many_notify(struct list_head *head,
+                                     u32 portid, const struct nlmsghdr *nlh)
 {
        struct net_device *dev, *tmp;
        LIST_HEAD(close_head);
@@ -10850,7 +10844,8 @@ void unregister_netdevice_many(struct list_head *head)
                if (!dev->rtnl_link_ops ||
                    dev->rtnl_link_state == RTNL_LINK_INITIALIZED)
                        skb = rtmsg_ifinfo_build_skb(RTM_DELLINK, dev, ~0U, 0,
-                                                    GFP_KERNEL, NULL, 0, 0, 0);
+                                                    GFP_KERNEL, NULL, 0,
+                                                    portid, nlmsg_seq(nlh));
 
                /*
                 *      Flush the unicast and multicast chains
@@ -10865,7 +10860,7 @@ void unregister_netdevice_many(struct list_head *head)
                        dev->netdev_ops->ndo_uninit(dev);
 
                if (skb)
-                       rtmsg_ifinfo_send(skb, dev, GFP_KERNEL, 0, NULL);
+                       rtmsg_ifinfo_send(skb, dev, GFP_KERNEL, portid, nlh);
 
                /* Notifier chain MUST detach us all upper devices. */
                WARN_ON(netdev_has_any_upper_dev(dev));
@@ -10888,6 +10883,18 @@ void unregister_netdevice_many(struct list_head *head)
 
        list_del(head);
 }
+
+/**
+ *     unregister_netdevice_many - unregister many devices
+ *     @head: list of devices
+ *
+ *  Note: As most callers use a stack allocated list_head,
+ *  we force a list_del() to make sure stack wont be corrupted later.
+ */
+void unregister_netdevice_many(struct list_head *head)
+{
+       unregister_netdevice_many_notify(head, 0, NULL);
+}
 EXPORT_SYMBOL(unregister_netdevice_many);
 
 /**
index 6b3c7302f5701741f067e6e840552e794b65f167..814ed5b7b96005e6b590dc8ae5619f5c97993525 100644 (file)
@@ -92,6 +92,9 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
                        unsigned int gchanges, u32 portid,
                        const struct nlmsghdr *nlh);
 
+void unregister_netdevice_many_notify(struct list_head *head,
+                                     u32 portid, const struct nlmsghdr *nlh);
+
 static inline void netif_set_gso_max_size(struct net_device *dev,
                                          unsigned int size)
 {