~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/openvswitch/dp_notify.c

Version: ~ [ linux-5.2 ] ~ [ linux-5.1.16 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.57 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.132 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.184 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.184 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.69 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (c) 2007-2012 Nicira, Inc.
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of version 2 of the GNU General Public
  6  * License as published by the Free Software Foundation.
  7  *
  8  * This program is distributed in the hope that it will be useful, but
  9  * WITHOUT ANY WARRANTY; without even the implied warranty of
 10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 11  * General Public License for more details.
 12  *
 13  * You should have received a copy of the GNU General Public License
 14  * along with this program; if not, write to the Free Software
 15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 16  * 02110-1301, USA
 17  */
 18 
 19 #include <linux/netdevice.h>
 20 #include <net/genetlink.h>
 21 #include <net/netns/generic.h>
 22 
 23 #include "datapath.h"
 24 #include "vport-internal_dev.h"
 25 #include "vport-netdev.h"
 26 
 27 static void dp_detach_port_notify(struct vport *vport)
 28 {
 29         struct sk_buff *notify;
 30         struct datapath *dp;
 31 
 32         dp = vport->dp;
 33         notify = ovs_vport_cmd_build_info(vport, 0, 0,
 34                                           OVS_VPORT_CMD_DEL);
 35         ovs_dp_detach_port(vport);
 36         if (IS_ERR(notify)) {
 37                 genl_set_err(&dp_vport_genl_family, ovs_dp_get_net(dp), 0,
 38                              0, PTR_ERR(notify));
 39                 return;
 40         }
 41 
 42         genlmsg_multicast_netns(&dp_vport_genl_family,
 43                                 ovs_dp_get_net(dp), notify, 0,
 44                                 0, GFP_KERNEL);
 45 }
 46 
 47 void ovs_dp_notify_wq(struct work_struct *work)
 48 {
 49         struct ovs_net *ovs_net = container_of(work, struct ovs_net, dp_notify_work);
 50         struct datapath *dp;
 51 
 52         ovs_lock();
 53         list_for_each_entry(dp, &ovs_net->dps, list_node) {
 54                 int i;
 55 
 56                 for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {
 57                         struct vport *vport;
 58                         struct hlist_node *n;
 59 
 60                         hlist_for_each_entry_safe(vport, n, &dp->ports[i], dp_hash_node) {
 61                                 struct netdev_vport *netdev_vport;
 62 
 63                                 if (vport->ops->type != OVS_VPORT_TYPE_NETDEV)
 64                                         continue;
 65 
 66                                 netdev_vport = netdev_vport_priv(vport);
 67                                 if (!(netdev_vport->dev->priv_flags & IFF_OVS_DATAPATH))
 68                                         dp_detach_port_notify(vport);
 69                         }
 70                 }
 71         }
 72         ovs_unlock();
 73 }
 74 
 75 static int dp_device_event(struct notifier_block *unused, unsigned long event,
 76                            void *ptr)
 77 {
 78         struct ovs_net *ovs_net;
 79         struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 80         struct vport *vport = NULL;
 81 
 82         if (!ovs_is_internal_dev(dev))
 83                 vport = ovs_netdev_get_vport(dev);
 84 
 85         if (!vport)
 86                 return NOTIFY_DONE;
 87 
 88         if (event == NETDEV_UNREGISTER) {
 89                 /* upper_dev_unlink and decrement promisc immediately */
 90                 ovs_netdev_detach_dev(vport);
 91 
 92                 /* schedule vport destroy, dev_put and genl notification */
 93                 ovs_net = net_generic(dev_net(dev), ovs_net_id);
 94                 queue_work(system_wq, &ovs_net->dp_notify_work);
 95         }
 96 
 97         return NOTIFY_DONE;
 98 }
 99 
100 struct notifier_block ovs_dp_device_notifier = {
101         .notifier_call = dp_device_event
102 };
103 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp