aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-07-30 20:03:38 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-07-31 05:28:15 -0400
commitfcc5a03ac42564e9e255c1134dda47442289e466 (patch)
tree8be87d6dc1a58b8ccd27de930c17bc1c9c26bac9 /include
parentaeed9e82cd258b9699eaa6568efefba9cc6d5f01 (diff)
[NET]: Allow netdev REGISTER/CHANGENAME events to fail
This patch adds code to allow errors to be passed up from event handlers of NETDEV_REGISTER and NETDEV_CHANGENAME. It also adds the notifier_from_errno/notifier_to_errnor helpers to pass the errno value up to the notifier caller. If an error is detected when a device is registered, it causes that operation to fail. A NETDEV_UNREGISTER will be sent to all event handlers. Similarly if NETDEV_CHANGENAME fails the original name is restored and a new NETDEV_CHANGENAME event is sent. As such all event handlers must be idempotent with respect to these events. When an event handler is registered NETDEV_REGISTER events are sent for all devices currently registered. Should any of them fail, we will send NETDEV_GOING_DOWN/NETDEV_DOWN/NETDEV_UNREGISTER events to that handler for the devices which have already been registered with it. The handler registration itself will fail. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/notifier.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index be3f2bb6fcf3..fad7ff17e468 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -157,6 +157,19 @@ extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
157 */ 157 */
158#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK) 158#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK)
159 159
160/* Encapsulate (negative) errno value (in particular, NOTIFY_BAD <=> EPERM). */
161static inline int notifier_from_errno(int err)
162{
163 return NOTIFY_STOP_MASK | (NOTIFY_OK - err);
164}
165
166/* Restore (negative) errno value from notify return value. */
167static inline int notifier_to_errno(int ret)
168{
169 ret &= ~NOTIFY_STOP_MASK;
170 return ret > NOTIFY_OK ? NOTIFY_OK - ret : 0;
171}
172
160/* 173/*
161 * Declared notifiers so far. I can imagine quite a few more chains 174 * Declared notifiers so far. I can imagine quite a few more chains
162 * over time (eg laptop power reset chains, reboot chain (to clean 175 * over time (eg laptop power reset chains, reboot chain (to clean