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 872658927e47..f861555cc525 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.2.3 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 --- drivers/net/rrunner.c | 8 +++----- include/net/xfrm.h | 2 ++ net/core/sysctl_net_core.c | 17 ++--------------- 3 files changed, 7 insertions(+), 20 deletions(-) (limited to 'net/core') diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c index 19152f54ef2b..b822859c8de3 100644 --- a/drivers/net/rrunner.c +++ b/drivers/net/rrunner.c @@ -79,12 +79,10 @@ static char version[] __devinitdata = "rrunner.c: v0.50 11/11/2002 Jes Sorensen */ /* - * These are checked at init time to see if they are at least 256KB - * and increased to 256KB if they are not. This is done to avoid ending - * up with socket buffers smaller than the MTU size, + * sysctl_[wr]mem_max are checked at init time to see if they are at + * least 256KB and increased to 256KB if they are not. This is done to + * avoid ending up with socket buffers smaller than the MTU size, */ -extern __u32 sysctl_wmem_max; -extern __u32 sysctl_rmem_max; static int __devinit rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 688f6f5d3285..58dfa82889aa 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -37,6 +37,8 @@ extern struct sock *xfrm_nl; extern u32 sysctl_xfrm_aevent_etime; extern u32 sysctl_xfrm_aevent_rseqth; +extern int sysctl_xfrm_larval_drop; +extern u32 sysctl_xfrm_acq_expires; extern struct mutex xfrm_cfg_mutex; diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 6d5ea9762040..113cc728dc31 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.2.3 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 f861555cc525..f1647d7dd14b 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 6628e457ddc0..61ead1d11132 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 000000000000..f5f108db3924 --- /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.2.3 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 0ab5234b17d8..3ed2b4b1d6d4 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.2.3