patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / net / socket.c
index 3f6b90a..57cbf98 100644 (file)
 #endif /* CONFIG_NET_RADIO */
 
 #include <asm/uaccess.h>
+#include <asm/unistd.h>
+
 #include <net/compat.h>
 
 #include <net/sock.h>
 #include <linux/netfilter.h>
+#include <linux/vs_base.h>
+#include <linux/vs_socket.h>
 
 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
@@ -308,9 +312,9 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
 static int init_inodecache(void)
 {
        sock_inode_cachep = kmem_cache_create("sock_inode_cache",
-                                            sizeof(struct socket_alloc),
-                                            0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
-                                            init_once, NULL);
+                               sizeof(struct socket_alloc),
+                               0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+                               init_once, NULL);
        if (sock_inode_cachep == NULL)
                return -ENOMEM;
        return 0;
@@ -749,9 +753,9 @@ static ssize_t sock_writev(struct file *file, const struct iovec *vector,
  */
 
 static DECLARE_MUTEX(br_ioctl_mutex);
-static int (*br_ioctl_hook)(unsigned long arg) = NULL;
+static int (*br_ioctl_hook)(unsigned int cmd, void __user *arg) = NULL;
 
-void brioctl_set(int (*hook)(unsigned long))
+void brioctl_set(int (*hook)(unsigned int, void __user *))
 {
        down(&br_ioctl_mutex);
        br_ioctl_hook = hook;
@@ -760,9 +764,9 @@ void brioctl_set(int (*hook)(unsigned long))
 EXPORT_SYMBOL(brioctl_set);
 
 static DECLARE_MUTEX(vlan_ioctl_mutex);
-static int (*vlan_ioctl_hook)(unsigned long arg);
+static int (*vlan_ioctl_hook)(void __user *arg);
 
-void vlan_ioctl_set(int (*hook)(unsigned long))
+void vlan_ioctl_set(int (*hook)(void __user *))
 {
        down(&vlan_ioctl_mutex);
        vlan_ioctl_hook = hook;
@@ -771,9 +775,9 @@ void vlan_ioctl_set(int (*hook)(unsigned long))
 EXPORT_SYMBOL(vlan_ioctl_set);
 
 static DECLARE_MUTEX(dlci_ioctl_mutex);
-static int (*dlci_ioctl_hook)(unsigned int, void *);
+static int (*dlci_ioctl_hook)(unsigned int, void __user *);
 
-void dlci_ioctl_set(int (*hook)(unsigned int, void *))
+void dlci_ioctl_set(int (*hook)(unsigned int, void __user *))
 {
        down(&dlci_ioctl_mutex);
        dlci_ioctl_hook = hook;
@@ -790,39 +794,42 @@ static int sock_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                      unsigned long arg)
 {
        struct socket *sock;
+       void __user *argp = (void __user *)arg;
        int pid, err;
 
        unlock_kernel();
        sock = SOCKET_I(inode);
        if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
-               err = dev_ioctl(cmd, (void *)arg);
+               err = dev_ioctl(cmd, argp);
        } else
 #ifdef WIRELESS_EXT
        if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) {
-               err = dev_ioctl(cmd, (void *)arg);
+               err = dev_ioctl(cmd, argp);
        } else
 #endif /* WIRELESS_EXT */
        switch (cmd) {
                case FIOSETOWN:
                case SIOCSPGRP:
                        err = -EFAULT;
-                       if (get_user(pid, (int *)arg))
+                       if (get_user(pid, (int __user *)argp))
                                break;
                        err = f_setown(sock->file, pid, 1);
                        break;
                case FIOGETOWN:
                case SIOCGPGRP:
-                       err = put_user(sock->file->f_owner.pid, (int *)arg);
+                       err = put_user(sock->file->f_owner.pid, (int __user *)argp);
                        break;
                case SIOCGIFBR:
                case SIOCSIFBR:
+               case SIOCBRADDBR:
+               case SIOCBRDELBR:
                        err = -ENOPKG;
                        if (!br_ioctl_hook)
                                request_module("bridge");
 
                        down(&br_ioctl_mutex);
                        if (br_ioctl_hook) 
-                               err = br_ioctl_hook(arg);
+                               err = br_ioctl_hook(cmd, argp);
                        up(&br_ioctl_mutex);
                        break;
                case SIOCGIFVLAN:
@@ -833,13 +840,13 @@ static int sock_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
                        down(&vlan_ioctl_mutex);
                        if (vlan_ioctl_hook)
-                               err = vlan_ioctl_hook(arg);
+                               err = vlan_ioctl_hook(argp);
                        up(&vlan_ioctl_mutex);
                        break;
                case SIOCGIFDIVERT:
                case SIOCSIFDIVERT:
                /* Convert this to call through a hook */
-                       err = divert_ioctl(cmd, (struct divert_cf *)arg);
+                       err = divert_ioctl(cmd, argp);
                        break;
                case SIOCADDDLCI:
                case SIOCDELDLCI:
@@ -849,7 +856,7 @@ static int sock_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
                        if (dlci_ioctl_hook) {
                                down(&dlci_ioctl_mutex);
-                               err = dlci_ioctl_hook(cmd, (void *)arg);
+                               err = dlci_ioctl_hook(cmd, argp);
                                up(&dlci_ioctl_mutex);
                        }
                        break;
@@ -1846,6 +1853,8 @@ out:
        return err;
 }
 
+#ifdef __ARCH_WANT_SYS_SOCKETCALL
+
 /* Argument list sizes for sys_socketcall */
 #define AL(x) ((x) * sizeof(unsigned long))
 static unsigned char nargs[18]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
@@ -1939,6 +1948,8 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
        return err;
 }
 
+#endif /* __ARCH_WANT_SYS_SOCKETCALL */
+
 /*
  *     This function is called by a protocol handler that wants to
  *     advertise its address family, and have it linked into the