]> git.proxmox.com Git - ovs.git/blob - datapath/dp_notify.c
datapath: Reformat copyright messages.
[ovs.git] / datapath / dp_notify.c
1 /*
2 * Copyright (c) 2007-2011 Nicira Networks.
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
22 #include "datapath.h"
23 #include "vport-internal_dev.h"
24 #include "vport-netdev.h"
25
26 static int dp_device_event(struct notifier_block *unused, unsigned long event,
27 void *ptr)
28 {
29 struct net_device *dev = ptr;
30 struct vport *vport;
31 struct datapath *dp;
32
33 if (is_internal_dev(dev))
34 vport = internal_dev_get_vport(dev);
35 else
36 vport = netdev_get_vport(dev);
37
38 if (!vport)
39 return NOTIFY_DONE;
40
41 dp = vport->dp;
42
43 switch (event) {
44 case NETDEV_UNREGISTER:
45 if (!is_internal_dev(dev)) {
46 struct sk_buff *reply;
47
48 reply = ovs_vport_cmd_build_info(vport, 0, 0,
49 OVS_VPORT_CMD_DEL);
50 dp_detach_port(vport);
51 if (IS_ERR(reply)) {
52 netlink_set_err(INIT_NET_GENL_SOCK, 0,
53 dp_vport_multicast_group.id,
54 PTR_ERR(reply));
55 break;
56 }
57
58 genl_notify(reply, dev_net(dev), 0,
59 dp_vport_multicast_group.id, NULL,
60 GFP_KERNEL);
61 }
62 break;
63
64 case NETDEV_CHANGENAME:
65 if (vport->port_no != OVSP_LOCAL) {
66 dp_sysfs_del_if(vport);
67 dp_sysfs_add_if(vport);
68 }
69 break;
70 }
71 return NOTIFY_DONE;
72 }
73
74 struct notifier_block dp_device_notifier = {
75 .notifier_call = dp_device_event
76 };