diff options
| author | Stephen Hemminger <shemminger@osdl.org> | 2003-04-09 11:01:10 -0700 |
|---|---|---|
| committer | David S. Miller <davem@nuts.ninka.net> | 2003-04-09 11:01:10 -0700 |
| commit | d1ebfcd6e608b71bb13cb245544dafa6d0c05674 (patch) | |
| tree | a0863fa204e53feb95c71583ae2ee0a468b282d3 /net/socket.c | |
| parent | 60c6580a3e197510248bd574e42a78c4e585cf9b (diff) | |
[BRIDGE]: Fix several locking bugs, plus cleanups.
Diffstat (limited to 'net/socket.c')
| -rw-r--r-- | net/socket.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/net/socket.c b/net/socket.c index 0df13a726ce5..0d549c4602b5 100644 --- a/net/socket.c +++ b/net/socket.c @@ -71,6 +71,7 @@ #include <linux/wanrouter.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> +#include <linux/if_bridge.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/cache.h> @@ -712,7 +713,18 @@ static ssize_t sock_writev(struct file *file, const struct iovec *vector, file, vector, count, tot_len); } -int (*br_ioctl_hook)(unsigned long arg); + +static DECLARE_MUTEX(br_ioctl_mutex); +static int (*br_ioctl_hook)(unsigned long arg) = NULL; + +void brioctl_set(int (*hook)(unsigned long)) +{ + down(&br_ioctl_mutex); + br_ioctl_hook = hook; + up(&br_ioctl_mutex); +} + + int (*vlan_ioctl_hook)(unsigned long arg); #ifdef CONFIG_DLCI @@ -759,12 +771,16 @@ static int sock_ioctl(struct inode *inode, struct file *file, unsigned int cmd, case SIOCGIFBR: case SIOCSIFBR: err = -ENOPKG; + #ifdef CONFIG_KMOD if (!br_ioctl_hook) request_module("bridge"); #endif - if (br_ioctl_hook) + + down(&br_ioctl_mutex); + if (br_ioctl_hook) err = br_ioctl_hook(arg); + up(&br_ioctl_mutex); break; case SIOCGIFVLAN: case SIOCSIFVLAN: |
