Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[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 Nicira Networks.
4  */
5
6 /* Handle changes to managed devices */
7
8 #include <linux/netdevice.h>
9
10 #include "datapath.h"
11
12
13 static int dp_device_event(struct notifier_block *unused, unsigned long event, 
14                 void *ptr) 
15 {
16         struct net_device *dev = ptr;
17         struct net_bridge_port *p = dev->br_port;
18         if (event == NETDEV_UNREGISTER && p) {
19                 struct datapath *dp = p->dp;
20                 mutex_lock(&dp->mutex);
21                 dp_del_port(p, NULL);
22                 mutex_unlock(&dp->mutex);
23         }
24         return NOTIFY_DONE;
25 }
26
27 struct notifier_block dp_device_notifier = {
28         .notifier_call = dp_device_event
29 };