[NET]: Add a dev_ioctl() fallback to sock_ioctl()
authorChristoph Hellwig <hch@lst.de>
Tue, 3 Jan 2006 22:18:33 +0000 (14:18 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Jan 2006 22:18:33 +0000 (14:18 -0800)
Currently all network protocols need to call dev_ioctl as the default
fallback in their ioctl implementations.  This patch adds a fallback
to dev_ioctl to sock_ioctl if the protocol returned -ENOIOCTLCMD.
This way all the procotol ioctl handlers can be simplified and we don't
need to export dev_ioctl.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 files changed:
net/appletalk/ddp.c
net/ax25/af_ax25.c
net/core/dev.c
net/decnet/af_decnet.c
net/econet/af_econet.c
net/ipv4/af_inet.c
net/ipv6/af_inet6.c
net/ipx/af_ipx.c
net/irda/af_irda.c
net/llc/af_llc.c
net/netrom/af_netrom.c
net/packet/af_packet.c
net/rose/af_rose.c
net/socket.c
net/unix/af_unix.c
net/wanrouter/af_wanpipe.c
net/x25/af_x25.c

index 296f186802ffd007209ce4572e8bed2a4c30296f..a5144e43aae136896ae646e4048fbdc13b75b25e 100644 (file)
@@ -1763,7 +1763,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
  */
 static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
-       int rc = -EINVAL;
+       int rc = -ENOIOCTLCMD;
        struct sock *sk = sock->sk;
        void __user *argp = (void __user *)arg;
 
@@ -1813,23 +1813,6 @@ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        rc = atif_ioctl(cmd, argp);
                        rtnl_unlock();
                        break;
-               /* Physical layer ioctl calls */
-               case SIOCSIFLINK:
-               case SIOCGIFHWADDR:
-               case SIOCSIFHWADDR:
-               case SIOCGIFFLAGS:
-               case SIOCSIFFLAGS:
-               case SIOCGIFTXQLEN:
-               case SIOCSIFTXQLEN:
-               case SIOCGIFMTU:
-               case SIOCGIFCONF:
-               case SIOCADDMULTI:
-               case SIOCDELMULTI:
-               case SIOCGIFCOUNT:
-               case SIOCGIFINDEX:
-               case SIOCGIFNAME:
-                       rc = dev_ioctl(cmd, argp);
-                       break;
        }
 
        return rc;
index 8b5d10aaba059b698485a51feafa840c36061905..e8753c7fcad17d1464e06006af3abb96dad6ba30 100644 (file)
@@ -1827,7 +1827,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                break;
 
        default:
-               res = dev_ioctl(cmd, argp);
+               res = -ENOIOCTLCMD;
                break;
        }
        release_sock(sk);
index a5efc9ae010bb144260258c51ae7556447c5c421..29ba109d3e54ffaa0a93dfc7cf9b9c0539614139 100644 (file)
@@ -3276,7 +3276,6 @@ EXPORT_SYMBOL(dev_close);
 EXPORT_SYMBOL(dev_get_by_flags);
 EXPORT_SYMBOL(dev_get_by_index);
 EXPORT_SYMBOL(dev_get_by_name);
-EXPORT_SYMBOL(dev_ioctl);
 EXPORT_SYMBOL(dev_open);
 EXPORT_SYMBOL(dev_queue_xmit);
 EXPORT_SYMBOL(dev_remove_pack);
index 65e3baed02517ac7b5d90a693a8985cc0fa52bc3..78ec5344be86e6f65f2c02121a84145bf4bc1cfc 100644 (file)
@@ -1252,7 +1252,7 @@ static int dn_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                break;
 
        default:
-               err = dev_ioctl(cmd, (void __user *)arg);
+               err = -ENOIOCTLCMD;
                break;
        }
 
index 70fb2b88da652f9b8b48894deafb46771c183ab4..4fc245243ccaf19807bfaf5e9f45feb7f1e6d264 100644 (file)
@@ -687,7 +687,7 @@ static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg
                        break;
 
                default:
-                       return dev_ioctl(cmd, argp);
+                       return -ENOIOCTLCMD;
        }
        /*NOTREACHED*/
        return 0;
index 36a6306ca5a3a690bfafe5f8e27f284bb7c6b967..966a071a408c86203985917886d0dcf2360abcf2 100644 (file)
@@ -777,10 +777,10 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        err = devinet_ioctl(cmd, (void __user *)arg);
                        break;
                default:
-                       if (!sk->sk_prot->ioctl ||
-                           (err = sk->sk_prot->ioctl(sk, cmd, arg)) ==
-                                                               -ENOIOCTLCMD)
-                               err = dev_ioctl(cmd, (void __user *)arg);
+                       if (sk->sk_prot->ioctl)
+                               err = sk->sk_prot->ioctl(sk, cmd, arg);
+                       else
+                               err = -ENOIOCTLCMD;
                        break;
        }
        return err;
index 7c9f19269f21a1a1684a4d1f17455564dd7f75d8..68afc53be6628a0b26c7fc6cf6556ff8c9b4bdc8 100644 (file)
@@ -434,7 +434,6 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
 int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
        struct sock *sk = sock->sk;
-       int err = -EINVAL;
 
        switch(cmd) 
        {
@@ -453,10 +452,9 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
        case SIOCSIFDSTADDR:
                return addrconf_set_dstaddr((void __user *) arg);
        default:
-               if (!sk->sk_prot->ioctl ||
-                   (err = sk->sk_prot->ioctl(sk, cmd, arg)) == -ENOIOCTLCMD)
-                       return(dev_ioctl(cmd,(void __user *) arg));             
-               return err;
+               if (!sk->sk_prot->ioctl)
+                       return -ENOIOCTLCMD;
+               return sk->sk_prot->ioctl(sk, cmd, arg);
        }
        /*NOTREACHED*/
        return(0);
index 6c464c11bb09a72364415678cf129a045331861d..0dc519b404042c25b1e25a912762ae5ed2d162c0 100644 (file)
@@ -1884,7 +1884,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                rc = -EINVAL;
                break;
        default:
-               rc = dev_ioctl(cmd, argp);
+               rc = -ENOIOCTLCMD;
                break;
        }
 
index e57683d424f760462293a904c826dbd4649177f5..fbfa96754417cbf18f3b8bace4577394806b6e9f 100644 (file)
@@ -1822,7 +1822,7 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                return -EINVAL;
        default:
                IRDA_DEBUG(1, "%s(), doing device ioctl!\n", __FUNCTION__);
-               return dev_ioctl(cmd, (void __user *) arg);
+               return -ENOIOCTLCMD;
        }
 
        /*NOTREACHED*/
index 9cf65f9d8902621e13b0fc876d3301c86bbb6cfb..8171c53bc0ed064d1bd199fda3484023a233cf9e 100644 (file)
@@ -959,7 +959,7 @@ out:
 static int llc_ui_ioctl(struct socket *sock, unsigned int cmd,
                        unsigned long arg)
 {
-       return dev_ioctl(cmd, (void __user *)arg);
+       return -ENOIOCTLCMD;
 }
 
 /**
index 9ee672e19ec160e368829eee7121ff403f9e7a10..63b0e4afeb3342da4cdda6d63e95c4053872564a 100644 (file)
@@ -1215,7 +1215,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                return nr_rt_ioctl(cmd, argp);
 
        default:
-               return dev_ioctl(cmd, argp);
+               return -ENOIOCTLCMD;
        }
 
        return 0;
index deda6fdb1e534890d2af062951b37299900e401e..f69e5ed9bd060b55f29212938d6f97efb27061bf 100644 (file)
@@ -1521,7 +1521,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
 #endif
 
                default:
-                       return dev_ioctl(cmd, (void __user *)arg);
+                       return -ENOIOCTLCMD;
        }
        return 0;
 }
index 829fdbc4400be21af83e3846fd913cd746fdca3b..63090be2315a9c7a0c7ab30bc5d354f7c35a6385 100644 (file)
@@ -1320,7 +1320,7 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                return 0;
 
        default:
-               return dev_ioctl(cmd, argp);
+               return -ENOIOCTLCMD;
        }
 
        return 0;
index 0dde6dade2b17b60afac9ffc937f724f3ba9f6b3..06fa217f58a99cb93b72b28ca99e85b7dc3739cd 100644 (file)
@@ -900,6 +900,13 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
                        break;
                default:
                        err = sock->ops->ioctl(sock, cmd, arg);
+
+                       /*
+                        * If this ioctl is unknown try to hand it down
+                        * to the NIC driver.
+                        */
+                       if (err == -ENOIOCTLCMD)
+                               err = dev_ioctl(cmd, argp);
                        break;
        }
        return err;
index 1ddd36d50091b32c7e40890cfff405b16e1fe5db..5f6ae79b8b1627db8a71be971712b2a6ace18de4 100644 (file)
@@ -1859,7 +1859,7 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                }
 
                default:
-                       err = dev_ioctl(cmd, (void __user *)arg);
+                       err = -ENOIOCTLCMD;
                        break;
        }
        return err;
index 67948bf22dc46f44bb19cec6ffb81653178354f5..7a43ae4721edd95fd6748974f68b8cf40c2f5e7b 100644 (file)
@@ -1839,7 +1839,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
 #endif
 
                default:
-                       return dev_ioctl(cmd,(void __user *) arg);
+                       return -ENOIOCTLCMD;
        }
        /*NOTREACHED*/
 }
index ca8b3b0b920d58a145fa174936673858dfffe9df..16459c7f54b2c71123cbcd05fd49f8ad0d786de5 100644 (file)
@@ -1378,7 +1378,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                }
 
                default:
-                       rc = dev_ioctl(cmd, argp);
+                       rc = -ENOIOCTLCMD;
                        break;
        }