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;
20 uint32_t orig_state, orig_config;
23 /* Check if monitored port */
27 spin_lock_irqsave(&p->lock, flags);
28 orig_state = p->state;
29 orig_config = p->config;
33 if (netif_carrier_ok(p->dev))
34 p->state &= ~OFPPS_LINK_DOWN;
36 p->state |= OFPPS_LINK_DOWN;
40 p->config |= OFPPC_PORT_DOWN;
44 p->config &= ~OFPPC_PORT_DOWN;
47 case NETDEV_UNREGISTER:
48 spin_unlock_irqrestore(&p->lock, flags);
49 dp_del_switch_port(p);
53 spin_unlock_irqrestore(&p->lock, flags);
55 if ((orig_state != p->state) || (orig_config != p->config))
56 dp_send_port_status(p, OFPPR_MODIFY);
61 struct notifier_block dp_device_notifier = {
62 .notifier_call = dp_device_event