2 * Distributed under the terms of the GNU GPL version 2.
3 * Copyright (c) 2007, 2008 The Board of Trustees of The Leland
4 * Stanford Junior University
7 /* Handle changes to managed devices */
9 #include <linux/netdevice.h>
14 static int dp_device_event(struct notifier_block *unused, unsigned long event,
17 struct net_device *dev = ptr;
18 struct net_bridge_port *p = dev->br_port;
19 unsigned long int flags;
23 /* Check if monitored port */
27 spin_lock_irqsave(&p->lock, flags);
28 orig_status = p->status;
32 if (netif_carrier_ok(p->dev))
33 p->status &= ~OFPPFL_LINK_DOWN;
35 p->status |= OFPPFL_LINK_DOWN;
39 p->status |= OFPPFL_PORT_DOWN;
43 p->status &= ~OFPPFL_PORT_DOWN;
46 case NETDEV_UNREGISTER:
47 /* xxx Make sure this is correct */
48 spin_unlock_irqrestore(&p->lock, flags);
49 dp_del_switch_port(p);
53 spin_unlock_irqrestore(&p->lock, flags);
55 if (orig_status != p->status)
56 dp_send_port_status(p, OFPPR_MOD);
61 struct notifier_block dp_device_notifier = {
62 .notifier_call = dp_device_event