Commit b5e5fa5e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

[NET]: Add a dev_ioctl() fallback to sock_ioctl()

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5ff7630e
...@@ -1763,7 +1763,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr ...@@ -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) static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{ {
int rc = -EINVAL; int rc = -ENOIOCTLCMD;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
...@@ -1813,23 +1813,6 @@ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1813,23 +1813,6 @@ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
rc = atif_ioctl(cmd, argp); rc = atif_ioctl(cmd, argp);
rtnl_unlock(); rtnl_unlock();
break; 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; return rc;
......
...@@ -1827,7 +1827,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1827,7 +1827,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
break; break;
default: default:
res = dev_ioctl(cmd, argp); res = -ENOIOCTLCMD;
break; break;
} }
release_sock(sk); release_sock(sk);
......
...@@ -3276,7 +3276,6 @@ EXPORT_SYMBOL(dev_close); ...@@ -3276,7 +3276,6 @@ EXPORT_SYMBOL(dev_close);
EXPORT_SYMBOL(dev_get_by_flags); EXPORT_SYMBOL(dev_get_by_flags);
EXPORT_SYMBOL(dev_get_by_index); EXPORT_SYMBOL(dev_get_by_index);
EXPORT_SYMBOL(dev_get_by_name); EXPORT_SYMBOL(dev_get_by_name);
EXPORT_SYMBOL(dev_ioctl);
EXPORT_SYMBOL(dev_open); EXPORT_SYMBOL(dev_open);
EXPORT_SYMBOL(dev_queue_xmit); EXPORT_SYMBOL(dev_queue_xmit);
EXPORT_SYMBOL(dev_remove_pack); EXPORT_SYMBOL(dev_remove_pack);
......
...@@ -1252,7 +1252,7 @@ static int dn_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1252,7 +1252,7 @@ static int dn_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
break; break;
default: default:
err = dev_ioctl(cmd, (void __user *)arg); err = -ENOIOCTLCMD;
break; break;
} }
......
...@@ -687,7 +687,7 @@ static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg ...@@ -687,7 +687,7 @@ static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg
break; break;
default: default:
return dev_ioctl(cmd, argp); return -ENOIOCTLCMD;
} }
/*NOTREACHED*/ /*NOTREACHED*/
return 0; return 0;
......
...@@ -777,10 +777,10 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -777,10 +777,10 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
err = devinet_ioctl(cmd, (void __user *)arg); err = devinet_ioctl(cmd, (void __user *)arg);
break; break;
default: default:
if (!sk->sk_prot->ioctl || if (sk->sk_prot->ioctl)
(err = sk->sk_prot->ioctl(sk, cmd, arg)) == err = sk->sk_prot->ioctl(sk, cmd, arg);
-ENOIOCTLCMD) else
err = dev_ioctl(cmd, (void __user *)arg); err = -ENOIOCTLCMD;
break; break;
} }
return err; return err;
......
...@@ -434,7 +434,6 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -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) int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
int err = -EINVAL;
switch(cmd) switch(cmd)
{ {
...@@ -453,10 +452,9 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -453,10 +452,9 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCSIFDSTADDR: case SIOCSIFDSTADDR:
return addrconf_set_dstaddr((void __user *) arg); return addrconf_set_dstaddr((void __user *) arg);
default: default:
if (!sk->sk_prot->ioctl || if (!sk->sk_prot->ioctl)
(err = sk->sk_prot->ioctl(sk, cmd, arg)) == -ENOIOCTLCMD) return -ENOIOCTLCMD;
return(dev_ioctl(cmd,(void __user *) arg)); return sk->sk_prot->ioctl(sk, cmd, arg);
return err;
} }
/*NOTREACHED*/ /*NOTREACHED*/
return(0); return(0);
......
...@@ -1884,7 +1884,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1884,7 +1884,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
rc = -EINVAL; rc = -EINVAL;
break; break;
default: default:
rc = dev_ioctl(cmd, argp); rc = -ENOIOCTLCMD;
break; break;
} }
......
...@@ -1822,7 +1822,7 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1822,7 +1822,7 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
return -EINVAL; return -EINVAL;
default: default:
IRDA_DEBUG(1, "%s(), doing device ioctl!\n", __FUNCTION__); IRDA_DEBUG(1, "%s(), doing device ioctl!\n", __FUNCTION__);
return dev_ioctl(cmd, (void __user *) arg); return -ENOIOCTLCMD;
} }
/*NOTREACHED*/ /*NOTREACHED*/
......
...@@ -959,7 +959,7 @@ static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -959,7 +959,7 @@ static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
static int llc_ui_ioctl(struct socket *sock, unsigned int cmd, static int llc_ui_ioctl(struct socket *sock, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
return dev_ioctl(cmd, (void __user *)arg); return -ENOIOCTLCMD;
} }
/** /**
......
...@@ -1215,7 +1215,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1215,7 +1215,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
return nr_rt_ioctl(cmd, argp); return nr_rt_ioctl(cmd, argp);
default: default:
return dev_ioctl(cmd, argp); return -ENOIOCTLCMD;
} }
return 0; return 0;
......
...@@ -1521,7 +1521,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd, ...@@ -1521,7 +1521,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
#endif #endif
default: default:
return dev_ioctl(cmd, (void __user *)arg); return -ENOIOCTLCMD;
} }
return 0; return 0;
} }
......
...@@ -1320,7 +1320,7 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1320,7 +1320,7 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
return 0; return 0;
default: default:
return dev_ioctl(cmd, argp); return -ENOIOCTLCMD;
} }
return 0; return 0;
......
...@@ -900,6 +900,13 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) ...@@ -900,6 +900,13 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
break; break;
default: default:
err = sock->ops->ioctl(sock, cmd, arg); 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; break;
} }
return err; return err;
......
...@@ -1859,7 +1859,7 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1859,7 +1859,7 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
} }
default: default:
err = dev_ioctl(cmd, (void __user *)arg); err = -ENOIOCTLCMD;
break; break;
} }
return err; return err;
......
...@@ -1839,7 +1839,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar ...@@ -1839,7 +1839,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
#endif #endif
default: default:
return dev_ioctl(cmd,(void __user *) arg); return -ENOIOCTLCMD;
} }
/*NOTREACHED*/ /*NOTREACHED*/
} }
......
...@@ -1378,7 +1378,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1378,7 +1378,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
} }
default: default:
rc = dev_ioctl(cmd, argp); rc = -ENOIOCTLCMD;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment