Set MTU in userspace rather than kernel.
[sliver-openvswitch.git] / datapath / dp_notify.c
1 /*
2  * Distributed under the terms of the GNU GPL version 2.
3  * Copyright (c) 2007, 2008, 2009, 2010, 2011 Nicira Networks.
4  *
5  * Significant portions of this file may be copied from parts of the Linux
6  * kernel, by Linus Torvalds and others.
7  */
8
9 /* Handle changes to managed devices */
10
11 #include <linux/netdevice.h>
12 #include <net/genetlink.h>
13
14 #include "datapath.h"
15 #include "vport-internal_dev.h"
16 #include "vport-netdev.h"
17
18 static int dp_device_event(struct notifier_block *unused, unsigned long event,
19                 void *ptr)
20 {
21         struct net_device *dev = ptr;
22         struct vport *vport;
23         struct datapath *dp;
24
25         if (is_internal_dev(dev))
26                 vport = internal_dev_get_vport(dev);
27         else
28                 vport = netdev_get_vport(dev);
29
30         if (!vport)
31                 return NOTIFY_DONE;
32
33         dp = vport->dp;
34
35         switch (event) {
36         case NETDEV_UNREGISTER:
37                 if (!is_internal_dev(dev)) {
38                         struct sk_buff *reply;
39
40                         dp_detach_port(vport);
41                         reply = ovs_vport_cmd_build_info(vport, 0, 0,
42                                                          OVS_VPORT_CMD_DEL);
43                         if (IS_ERR(reply)) {
44                                 netlink_set_err(INIT_NET_GENL_SOCK, 0,
45                                                 dp_vport_multicast_group.id,
46                                                 PTR_ERR(reply));
47                                 break;
48                         }
49
50                         genl_notify(reply, dev_net(dev), 0,
51                                     dp_vport_multicast_group.id, NULL,
52                                     GFP_KERNEL);
53                 }
54                 break;
55
56         case NETDEV_CHANGENAME:
57                 if (vport->port_no != OVSP_LOCAL) {
58                         dp_sysfs_del_if(vport);
59                         dp_sysfs_add_if(vport);
60                 }
61                 break;
62         }
63         return NOTIFY_DONE;
64 }
65
66 struct notifier_block dp_device_notifier = {
67         .notifier_call = dp_device_event
68 };