All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: introduce pre-up netdev notifier
@ 2009-05-29 23:39 ` Johannes Berg
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2009-05-29 23:39 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, netdev

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>
---
John, please take this patch via your tree, I asked Dave and
he's cool with that.

 include/linux/notifier.h |    1 +
 net/core/dev.c           |    7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

--- wireless-testing.orig/include/linux/notifier.h	2009-05-29 10:28:02.000000000 +0200
+++ wireless-testing/include/linux/notifier.h	2009-05-30 01:38:44.000000000 +0200
@@ -198,6 +198,7 @@ static inline int notifier_to_errno(int 
 #define NETDEV_CHANGENAME	0x000A
 #define NETDEV_FEAT_CHANGE	0x000B
 #define NETDEV_BONDING_FAILOVER 0x000C
+#define NETDEV_PRE_UP		0x000D
 
 #define SYS_DOWN	0x0001	/* Notify of system down */
 #define SYS_RESTART	SYS_DOWN
--- wireless-testing.orig/net/core/dev.c	2009-05-29 10:28:02.000000000 +0200
+++ wireless-testing/net/core/dev.c	2009-05-30 01:38:44.000000000 +0200
@@ -1047,7 +1047,7 @@ void dev_load(struct net *net, const cha
 int dev_open(struct net_device *dev)
 {
 	const struct net_device_ops *ops = dev->netdev_ops;
-	int ret = 0;
+	int ret;
 
 	ASSERT_RTNL();
 
@@ -1064,6 +1064,11 @@ int dev_open(struct net_device *dev)
 	if (!netif_device_present(dev))
 		return -ENODEV;
 
+	ret = call_netdevice_notifiers(NETDEV_PRE_UP, dev);
+	ret = notifier_to_errno(ret);
+	if (ret)
+		return ret;
+
 	/*
 	 *	Call device private open method
 	 */



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] net: introduce pre-up netdev notifier
@ 2009-05-29 23:39 ` Johannes Berg
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2009-05-29 23:39 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, netdev

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-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
---
John, please take this patch via your tree, I asked Dave and
he's cool with that.

 include/linux/notifier.h |    1 +
 net/core/dev.c           |    7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

--- wireless-testing.orig/include/linux/notifier.h	2009-05-29 10:28:02.000000000 +0200
+++ wireless-testing/include/linux/notifier.h	2009-05-30 01:38:44.000000000 +0200
@@ -198,6 +198,7 @@ static inline int notifier_to_errno(int 
 #define NETDEV_CHANGENAME	0x000A
 #define NETDEV_FEAT_CHANGE	0x000B
 #define NETDEV_BONDING_FAILOVER 0x000C
+#define NETDEV_PRE_UP		0x000D
 
 #define SYS_DOWN	0x0001	/* Notify of system down */
 #define SYS_RESTART	SYS_DOWN
--- wireless-testing.orig/net/core/dev.c	2009-05-29 10:28:02.000000000 +0200
+++ wireless-testing/net/core/dev.c	2009-05-30 01:38:44.000000000 +0200
@@ -1047,7 +1047,7 @@ void dev_load(struct net *net, const cha
 int dev_open(struct net_device *dev)
 {
 	const struct net_device_ops *ops = dev->netdev_ops;
-	int ret = 0;
+	int ret;
 
 	ASSERT_RTNL();
 
@@ -1064,6 +1064,11 @@ int dev_open(struct net_device *dev)
 	if (!netif_device_present(dev))
 		return -ENODEV;
 
+	ret = call_netdevice_notifiers(NETDEV_PRE_UP, dev);
+	ret = notifier_to_errno(ret);
+	if (ret)
+		return ret;
+
 	/*
 	 *	Call device private open method
 	 */


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: introduce pre-up netdev notifier
  2009-05-29 23:39 ` Johannes Berg
  (?)
@ 2009-05-30  5:09 ` David Miller
  -1 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2009-05-30  5:09 UTC (permalink / raw)
  To: johannes; +Cc: linville, linux-wireless, netdev

From: Johannes Berg <johannes@sipsolutions.net>
Date: Sat, 30 May 2009 01:39:53 +0200

> 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>
> ---
> John, please take this patch via your tree, I asked Dave and
> he's cool with that.

Yep:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-30  5:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-29 23:39 [PATCH] net: introduce pre-up netdev notifier Johannes Berg
2009-05-29 23:39 ` Johannes Berg
2009-05-30  5:09 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.