From bada339ba24dee9e143bfb42e1dc61f146619846 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 23 Oct 2007 20:19:37 -0700 Subject: [NET]: Validate device addr prior to interface-up Signed-off-by: Jeff Garzik Signed-off-by: David S. Miller --- net/core/dev.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'net/core') diff --git a/net/core/dev.c b/net/core/dev.c index 8726589..f861555 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1007,17 +1007,20 @@ int dev_open(struct net_device *dev) * Call device private open method */ set_bit(__LINK_STATE_START, &dev->state); - if (dev->open) { + + if (dev->validate_addr) + ret = dev->validate_addr(dev); + + if (!ret && dev->open) ret = dev->open(dev); - if (ret) - clear_bit(__LINK_STATE_START, &dev->state); - } /* * If it went open OK then: */ - if (!ret) { + if (ret) + clear_bit(__LINK_STATE_START, &dev->state); + else { /* * Set the flags. */ @@ -1038,6 +1041,7 @@ int dev_open(struct net_device *dev) */ call_netdevice_notifiers(NETDEV_UP, dev); } + return ret; } -- cgit v1.1 From a37ae4086e7e804db534bc8f2d31c2fbf89c5761 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 23 Oct 2007 21:13:53 -0700 Subject: [NET]: Don't declare extern variables in net/core/sysctl_net_core.c Some are already declared in include/linux/netdevice.h, while some others (xfrm ones) need to be declared. The driver/net/rrunner.c just uses same extern as well, so cleanup it also. Signed-off-by: Pavel Emelyanov Signed-off-by: David S. Miller --- net/core/sysctl_net_core.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'net/core') diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 6d5ea97..113cc72 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -9,25 +9,12 @@ #include #include #include +#include #include +#include #ifdef CONFIG_SYSCTL -extern int netdev_max_backlog; -extern int weight_p; - -extern __u32 sysctl_wmem_max; -extern __u32 sysctl_rmem_max; - -extern int sysctl_core_destroy_delay; - -#ifdef CONFIG_XFRM -extern u32 sysctl_xfrm_aevent_etime; -extern u32 sysctl_xfrm_aevent_rseqth; -extern int sysctl_xfrm_larval_drop; -extern u32 sysctl_xfrm_acq_expires; -#endif - ctl_table core_table[] = { #ifdef CONFIG_NET { -- cgit v1.1 From 342709efc7a4ba91eac6d2d2d931ec316a587dfa Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 23 Oct 2007 21:14:45 -0700 Subject: [NET]: Remove in-code externs for some functions from net/core/dev.c Inconsistent prototype and real type for functions may have worse consequences, than those for variables, so move them into a header. Since they are used privately in net/core, make this file reside in the same place. Signed-off-by: Pavel Emelyanov Signed-off-by: David S. Miller --- net/core/dev.c | 6 ++---- net/core/net-sysfs.c | 2 ++ net/core/net-sysfs.h | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 net/core/net-sysfs.h (limited to 'net/core') diff --git a/net/core/dev.c b/net/core/dev.c index f861555..f1647d7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -120,6 +120,8 @@ #include #include +#include "net-sysfs.h" + /* * The list of packet types we will receive (as opposed to discard) * and the routines to invoke. @@ -249,10 +251,6 @@ static RAW_NOTIFIER_HEAD(netdev_chain); DEFINE_PER_CPU(struct softnet_data, softnet_data); -extern int netdev_kobject_init(void); -extern int netdev_register_kobject(struct net_device *); -extern void netdev_unregister_kobject(struct net_device *); - #ifdef CONFIG_DEBUG_LOCK_ALLOC /* * register_netdevice() inits dev->_xmit_lock and sets lockdep class diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 6628e45..61ead1d 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -18,6 +18,8 @@ #include #include +#include "net-sysfs.h" + #ifdef CONFIG_SYSFS static const char fmt_hex[] = "%#x\n"; static const char fmt_long_hex[] = "%#lx\n"; diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h new file mode 100644 index 0000000..f5f108d --- /dev/null +++ b/net/core/net-sysfs.h @@ -0,0 +1,8 @@ +#ifndef __NET_SYSFS_H__ +#define __NET_SYSFS_H__ + +int netdev_kobject_init(void); +int netdev_register_kobject(struct net_device *); +void netdev_unregister_kobject(struct net_device *); + +#endif -- cgit v1.1 From f0fe91ded36bab95541e960ae8a115abc1f5ba03 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 23 Oct 2007 21:15:21 -0700 Subject: [NET]: Use BUILD_BUG_ON in net/core/flowi.c Instead of ugly extern not-existing function. Signed-off-by: Pavel Emelyanov Signed-off-by: David S. Miller --- net/core/flow.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'net/core') diff --git a/net/core/flow.c b/net/core/flow.c index 0ab5234..3ed2b4b 100644 --- a/net/core/flow.c +++ b/net/core/flow.c @@ -142,8 +142,6 @@ typedef u64 flow_compare_t; typedef u32 flow_compare_t; #endif -extern void flowi_is_missized(void); - /* I hear what you're saying, use memcmp. But memcmp cannot make * important assumptions that we can here, such as alignment and * constant size. @@ -153,8 +151,7 @@ static int flow_key_compare(struct flowi *key1, struct flowi *key2) flow_compare_t *k1, *k1_lim, *k2; const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t); - if (sizeof(struct flowi) % sizeof(flow_compare_t)) - flowi_is_missized(); + BUILD_BUG_ON(sizeof(struct flowi) % sizeof(flow_compare_t)); k1 = (flow_compare_t *) key1; k1_lim = k1 + n_elem; -- cgit v1.1