2009-07-08 13:19:16 -07:00
|
|
|
/*
|
|
|
|
* Distributed under the terms of the GNU GPL version 2.
|
2011-01-26 12:49:06 -08:00
|
|
|
* Copyright (c) 2007, 2008, 2009, 2010, 2011 Nicira Networks.
|
2009-06-15 15:11:30 -07:00
|
|
|
*
|
|
|
|
* Significant portions of this file may be copied from parts of the Linux
|
|
|
|
* kernel, by Linus Torvalds and others.
|
2009-07-08 13:19:16 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Handle changes to managed devices */
|
|
|
|
|
|
|
|
#include <linux/netdevice.h>
|
2011-08-23 17:20:00 -07:00
|
|
|
#include <net/genetlink.h>
|
2009-07-08 13:19:16 -07:00
|
|
|
|
|
|
|
#include "datapath.h"
|
2010-04-12 15:53:39 -04:00
|
|
|
#include "vport-internal_dev.h"
|
|
|
|
#include "vport-netdev.h"
|
2009-07-08 13:19:16 -07:00
|
|
|
|
2010-08-30 00:24:53 -07:00
|
|
|
static int dp_device_event(struct notifier_block *unused, unsigned long event,
|
|
|
|
void *ptr)
|
2009-07-08 13:19:16 -07:00
|
|
|
{
|
|
|
|
struct net_device *dev = ptr;
|
2010-04-12 15:53:39 -04:00
|
|
|
struct vport *vport;
|
2009-08-05 14:36:21 -07:00
|
|
|
struct datapath *dp;
|
|
|
|
|
2010-04-12 15:53:39 -04:00
|
|
|
if (is_internal_dev(dev))
|
|
|
|
vport = internal_dev_get_vport(dev);
|
2010-07-29 15:59:36 -07:00
|
|
|
else
|
2010-04-12 15:53:39 -04:00
|
|
|
vport = netdev_get_vport(dev);
|
|
|
|
|
2010-07-29 15:59:36 -07:00
|
|
|
if (!vport)
|
|
|
|
return NOTIFY_DONE;
|
2010-04-12 15:53:39 -04:00
|
|
|
|
2010-12-03 13:09:26 -08:00
|
|
|
dp = vport->dp;
|
2009-08-05 14:36:21 -07:00
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case NETDEV_UNREGISTER:
|
2011-08-23 17:20:00 -07:00
|
|
|
if (!is_internal_dev(dev)) {
|
|
|
|
struct sk_buff *reply;
|
|
|
|
|
|
|
|
reply = ovs_vport_cmd_build_info(vport, 0, 0,
|
|
|
|
OVS_VPORT_CMD_DEL);
|
2011-09-29 09:49:37 -07:00
|
|
|
dp_detach_port(vport);
|
2011-08-23 17:20:00 -07:00
|
|
|
if (IS_ERR(reply)) {
|
|
|
|
netlink_set_err(INIT_NET_GENL_SOCK, 0,
|
|
|
|
dp_vport_multicast_group.id,
|
|
|
|
PTR_ERR(reply));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
genl_notify(reply, dev_net(dev), 0,
|
|
|
|
dp_vport_multicast_group.id, NULL,
|
|
|
|
GFP_KERNEL);
|
|
|
|
}
|
2009-08-05 14:36:21 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NETDEV_CHANGENAME:
|
2011-08-18 10:35:40 -07:00
|
|
|
if (vport->port_no != OVSP_LOCAL) {
|
2010-12-03 13:09:26 -08:00
|
|
|
dp_sysfs_del_if(vport);
|
|
|
|
dp_sysfs_add_if(vport);
|
2009-08-05 14:36:21 -07:00
|
|
|
}
|
|
|
|
break;
|
2009-07-08 13:19:16 -07:00
|
|
|
}
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct notifier_block dp_device_notifier = {
|
|
|
|
.notifier_call = dp_device_event
|
|
|
|
};
|