summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGao Feng <fgao@ikuai8.com>2016-10-26 21:05:22 -0400
committerDavid S. Miller <davem@davemloft.net>2016-10-31 10:56:47 -0400
commit20861f26e33d76a4f3587bcc866fa1dab3e01094 (patch)
treef27493e8976cf194e01148dd10f3183686d057c5
parentc62cce2caee558e18aa05c01c2fd3b40f07174f2 (diff)
driver: tun: Use new macro SOCK_IOC_TYPE instead of literal number 0x89
The current codes use _IOC_TYPE(cmd) == 0x89 to check if the cmd is one socket ioctl command like SIOCGIFHWADDR. But the literal number 0x89 may confuse readers. So create one macro SOCK_IOC_TYPE to enhance the readability. Signed-off-by: Gao Feng <fgao@ikuai8.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/tun.c2
-rw-r--r--include/uapi/linux/sockios.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 9142db847ee1..1588469844e7 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1985,7 +1985,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
1985 int le; 1985 int le;
1986 int ret; 1986 int ret;
1987 1987
1988 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) { 1988 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == SOCK_IOC_TYPE) {
1989 if (copy_from_user(&ifr, argp, ifreq_len)) 1989 if (copy_from_user(&ifr, argp, ifreq_len))
1990 return -EFAULT; 1990 return -EFAULT;
1991 } else { 1991 } else {
diff --git a/include/uapi/linux/sockios.h b/include/uapi/linux/sockios.h
index 83cc54ce6081..79d029d25310 100644
--- a/include/uapi/linux/sockios.h
+++ b/include/uapi/linux/sockios.h
@@ -24,6 +24,8 @@
24#define SIOCINQ FIONREAD 24#define SIOCINQ FIONREAD
25#define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */ 25#define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */
26 26
27#define SOCK_IOC_TYPE 0x89
28
27/* Routing table calls. */ 29/* Routing table calls. */
28#define SIOCADDRT 0x890B /* add routing table entry */ 30#define SIOCADDRT 0x890B /* add routing table entry */
29#define SIOCDELRT 0x890C /* delete routing table entry */ 31#define SIOCDELRT 0x890C /* delete routing table entry */