aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-05-29 19:39:53 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-03 14:05:12 -0400
commit3b8bcfd5d31ea0fec58681d035544ace707d2536 (patch)
treecdb845275acea5a367bd9f17ce07c1a5ab4f19fa
parentbdf6d32f933bf28dfdca325281ee5266c753dc67 (diff)
net: introduce pre-up netdev notifier
NETDEV_UP is called after the device is set UP, but sometimes it is useful to be able to veto the device UP. Introduce a new NETDEV_PRE_UP notifier that can be used for exactly this. The first use case will be cfg80211 denying interfaces to be set UP if the device is known to be rfkill'ed. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--include/linux/notifier.h1
-rw-r--r--net/core/dev.c7
2 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index b86fa2ffca0c..81bc252dc8ac 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -198,6 +198,7 @@ static inline int notifier_to_errno(int ret)
198#define NETDEV_CHANGENAME 0x000A 198#define NETDEV_CHANGENAME 0x000A
199#define NETDEV_FEAT_CHANGE 0x000B 199#define NETDEV_FEAT_CHANGE 0x000B
200#define NETDEV_BONDING_FAILOVER 0x000C 200#define NETDEV_BONDING_FAILOVER 0x000C
201#define NETDEV_PRE_UP 0x000D
201 202
202#define SYS_DOWN 0x0001 /* Notify of system down */ 203#define SYS_DOWN 0x0001 /* Notify of system down */
203#define SYS_RESTART SYS_DOWN 204#define SYS_RESTART SYS_DOWN
diff --git a/net/core/dev.c b/net/core/dev.c
index 34b49a6a22fd..1f38401fc028 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1048,7 +1048,7 @@ void dev_load(struct net *net, const char *name)
1048int dev_open(struct net_device *dev) 1048int dev_open(struct net_device *dev)
1049{ 1049{
1050 const struct net_device_ops *ops = dev->netdev_ops; 1050 const struct net_device_ops *ops = dev->netdev_ops;
1051 int ret = 0; 1051 int ret;
1052 1052
1053 ASSERT_RTNL(); 1053 ASSERT_RTNL();
1054 1054
@@ -1065,6 +1065,11 @@ int dev_open(struct net_device *dev)
1065 if (!netif_device_present(dev)) 1065 if (!netif_device_present(dev))
1066 return -ENODEV; 1066 return -ENODEV;
1067 1067
1068 ret = call_netdevice_notifiers(NETDEV_PRE_UP, dev);
1069 ret = notifier_to_errno(ret);
1070 if (ret)
1071 return ret;
1072
1068 /* 1073 /*
1069 * Call device private open method 1074 * Call device private open method
1070 */ 1075 */