1 // SPDX-License-Identifier: GPL-2.0-only 1 2 /* 3 * Copyright (c) 2007-2012 Nicira, Inc. 4 */ 5 6 #include <linux/netdevice.h> 7 #include <net/genetlink.h> 8 #include <net/netns/generic.h> 9 10 #include "datapath.h" 11 #include "vport-internal_dev.h" 12 #include "vport-netdev.h" 13 14 static void dp_detach_port_notify(struct vport 15 { 16 struct sk_buff *notify; 17 struct datapath *dp; 18 19 dp = vport->dp; 20 notify = ovs_vport_cmd_build_info(vpor 21 0, 0 22 ovs_dp_detach_port(vport); 23 if (IS_ERR(notify)) { 24 genl_set_err(&dp_vport_genl_fa 25 0, PTR_ERR(notify 26 return; 27 } 28 29 genlmsg_multicast_netns(&dp_vport_genl 30 ovs_dp_get_net 31 0, GFP_KERNEL) 32 } 33 34 void ovs_dp_notify_wq(struct work_struct *work 35 { 36 struct ovs_net *ovs_net = container_of 37 struct datapath *dp; 38 39 ovs_lock(); 40 list_for_each_entry(dp, &ovs_net->dps, 41 int i; 42 43 for (i = 0; i < DP_VPORT_HASH_ 44 struct vport *vport; 45 struct hlist_node *n; 46 47 hlist_for_each_entry_s 48 if (vport->ops 49 contin 50 51 if (!(netif_is 52 dp_det 53 } 54 } 55 } 56 ovs_unlock(); 57 } 58 59 static int dp_device_event(struct notifier_blo 60 void *ptr) 61 { 62 struct ovs_net *ovs_net; 63 struct net_device *dev = netdev_notifi 64 struct vport *vport = NULL; 65 66 if (!ovs_is_internal_dev(dev)) 67 vport = ovs_netdev_get_vport(d 68 69 if (!vport) 70 return NOTIFY_DONE; 71 72 if (event == NETDEV_UNREGISTER) { 73 /* upper_dev_unlink and decrem 74 ovs_netdev_detach_dev(vport); 75 76 /* schedule vport destroy, dev 77 ovs_net = net_generic(dev_net( 78 queue_work(system_wq, &ovs_net 79 } 80 81 return NOTIFY_DONE; 82 } 83 84 struct notifier_block ovs_dp_device_notifier = 85 .notifier_call = dp_device_event 86 }; 87
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.