diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-01-21 02:23:15 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-01-21 02:23:15 +0000 |
commit | 2ce0f85e0d51e281a7674fd05d06177a99f453bb (patch) | |
tree | 169524807f92c939b58d9b6e784c7d814c161b60 | |
parent | 85e57203d338437201d1daaab88d5ad0642217e6 (diff) |
Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h
ok krw@ deraadt@ mpi@
-rw-r--r-- | include/protocols/talkd.h | 7 | ||||
-rw-r--r-- | share/man/man4/options.4 | 13 | ||||
-rw-r--r-- | sys/compat/linux/linux_socket.c | 30 | ||||
-rw-r--r-- | sys/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/net/if.c | 65 | ||||
-rw-r--r-- | sys/net/if_tun.c | 3 | ||||
-rw-r--r-- | sys/sys/socket.h | 13 | ||||
-rw-r--r-- | sys/sys/sockio.h | 6 |
8 files changed, 41 insertions, 100 deletions
diff --git a/include/protocols/talkd.h b/include/protocols/talkd.h index 09503582a62..fae2b42b2bf 100644 --- a/include/protocols/talkd.h +++ b/include/protocols/talkd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: talkd.h,v 1.4 2004/01/22 21:48:02 espie Exp $ */ +/* $OpenBSD: talkd.h,v 1.5 2015/01/21 02:23:14 guenther Exp $ */ /* $NetBSD: talkd.h,v 1.5 1995/03/04 07:59:30 cgd Exp $ */ /* @@ -53,6 +53,11 @@ * stream connection through which the conversation takes place. */ +struct osockaddr { + unsigned short sa_family; /* address family */ + char sa_data[14]; /* up to 14 bytes of direct address */ +}; + /* * Client->server request message format. */ diff --git a/share/man/man4/options.4 b/share/man/man4/options.4 index 16620ca8b9f..19dedb96027 100644 --- a/share/man/man4/options.4 +++ b/share/man/man4/options.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: options.4,v 1.238 2014/10/09 04:41:36 tedu Exp $ +.\" $OpenBSD: options.4,v 1.239 2015/01/21 02:23:14 guenther Exp $ .\" $NetBSD: options.4,v 1.21 1997/06/25 03:13:00 thorpej Exp $ .\" .\" Copyright (c) 1998 Theo de Raadt @@ -34,7 +34,7 @@ .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" -.Dd $Mdocdate: October 9 2014 $ +.Dd $Mdocdate: January 21 2015 $ .Dt OPTIONS 4 .Os .Sh NAME @@ -54,15 +54,6 @@ options are passed to the compile process as flags to the C compiler. .Sh COMPATIBILITY OPTIONS .Bl -ohang -.It Cd option COMPAT_43 -This option enables compatibility with -.Bx 4.3 . -It provides backwards compatibility with the -.Dq old -SIOC[GS]IF{ADDR,DSTADDR,BRDADDR,NETMASK} interface ioctls, including -binary compatibility for code written before the introduction of the -.Li sa_len -field in sockaddrs. .It Cd option COMPAT_LINUX On those architectures that support it, this enables binary compatibility with diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 06e2188319d..229ece21171 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_socket.c,v 1.57 2015/01/19 23:30:20 guenther Exp $ */ +/* $OpenBSD: linux_socket.c,v 1.58 2015/01/21 02:23:14 guenther Exp $ */ /* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */ /* @@ -1365,6 +1365,7 @@ linux_ioctl_socket(p, v, retval) struct vnode *vp; int (*ioctlf)(struct file *, u_long, caddr_t, struct proc *); struct ioctl_pt pt; + void *data = SCARG(uap, data); int error = 0, isdev = 0, dosys = 1; fdp = p->p_fd; @@ -1388,7 +1389,7 @@ linux_ioctl_socket(p, v, retval) dosys = 0; ioctlf = fp->f_ops->fo_ioctl; pt.com = SCARG(uap, com); - pt.data = SCARG(uap, data); + pt.data = data; error = ioctlf(fp, PTIOCLINUX, (caddr_t)&pt, p); /* * XXX hack: if the function returns EJUSTRETURN, @@ -1432,16 +1433,16 @@ linux_ioctl_socket(p, v, retval) SCARG(&ia, com) = SIOCGIFFLAGS; break; case LINUX_SIOCGIFADDR: - SCARG(&ia, com) = OSIOCGIFADDR; + SCARG(&ia, com) = SIOCGIFADDR; break; case LINUX_SIOCGIFDSTADDR: - SCARG(&ia, com) = OSIOCGIFDSTADDR; + SCARG(&ia, com) = SIOCGIFDSTADDR; break; case LINUX_SIOCGIFBRDADDR: - SCARG(&ia, com) = OSIOCGIFBRDADDR; + SCARG(&ia, com) = SIOCGIFBRDADDR; break; case LINUX_SIOCGIFNETMASK: - SCARG(&ia, com) = OSIOCGIFNETMASK; + SCARG(&ia, com) = SIOCGIFNETMASK; break; case LINUX_SIOCGIFMETRIC: SCARG(&ia, com) = SIOCGIFMETRIC; @@ -1456,7 +1457,7 @@ linux_ioctl_socket(p, v, retval) SCARG(&ia, com) = SIOCDELMULTI; break; case LINUX_SIOCGIFHWADDR: { - struct linux_ifreq *ifr = (struct linux_ifreq *)SCARG(uap, data); + struct linux_ifreq *ifr = data; struct sockaddr_dl *sdl; struct ifnet *ifp; @@ -1487,8 +1488,21 @@ linux_ioctl_socket(p, v, retval) out: if (error == 0 && dosys) { SCARG(&ia, fd) = SCARG(uap, fd); - SCARG(&ia, data) = SCARG(uap, data); + SCARG(&ia, data) = data; error = sys_ioctl(p, &ia, retval); + + if (error == 0) { + struct linux_ifreq *ifr = data; + + switch (com) { + case LINUX_SIOCGIFADDR: + case LINUX_SIOCGIFDSTADDR: + case LINUX_SIOCGIFBRDADDR: + case LINUX_SIOCGIFNETMASK: + error = linux_sa_put(&ifr->ifr_addr); + break; + } + } } FRELE(fp, p); diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC index a265eeaec69..95f7c45bfd7 100644 --- a/sys/conf/GENERIC +++ b/sys/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.213 2014/10/09 03:36:32 tedu Exp $ +# $OpenBSD: GENERIC,v 1.214 2015/01/21 02:23:14 guenther Exp $ # # Machine-independent option; used by all architectures for their # GENERIC kernel @@ -28,8 +28,6 @@ option SYSVSHM # System V-like memory sharing option UVM_SWAP_ENCRYPT# support encryption of pages going to swap -option COMPAT_43 # Kernel compatibility with 4.3BSD - option FFS # UFS option FFS2 # UFS2 option FFS_SOFTUPDATES # Soft updates diff --git a/sys/net/if.c b/sys/net/if.c index 38710e7d8e5..8cef7bbb507 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.312 2015/01/14 00:37:19 bluhm Exp $ */ +/* $OpenBSD: if.c,v 1.313 2015/01/21 02:23:14 guenther Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1203,7 +1203,9 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) switch (cmd) { case SIOCGIFCONF: +#ifdef COMPAT_LINUX case OSIOCGIFCONF: +#endif return (ifconf(cmd, data)); } ifr = (struct ifreq *)data; @@ -1603,61 +1605,9 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) default: if (so->so_proto == 0) return (EOPNOTSUPP); -#if !defined(COMPAT_43) && !defined(COMPAT_LINUX) error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, (struct mbuf *) cmd, (struct mbuf *) data, (struct mbuf *) ifp, p)); -#else - { - u_long ocmd = cmd; - - switch (cmd) { - - case SIOCSIFADDR: - case SIOCSIFDSTADDR: - case SIOCSIFBRDADDR: - case SIOCSIFNETMASK: -#if BYTE_ORDER != BIG_ENDIAN - if (ifr->ifr_addr.sa_family == 0 && - ifr->ifr_addr.sa_len < 16) { - ifr->ifr_addr.sa_family = ifr->ifr_addr.sa_len; - ifr->ifr_addr.sa_len = 16; - } -#else - if (ifr->ifr_addr.sa_len == 0) - ifr->ifr_addr.sa_len = 16; -#endif - break; - - case OSIOCGIFADDR: - cmd = SIOCGIFADDR; - break; - - case OSIOCGIFDSTADDR: - cmd = SIOCGIFDSTADDR; - break; - - case OSIOCGIFBRDADDR: - cmd = SIOCGIFBRDADDR; - break; - - case OSIOCGIFNETMASK: - cmd = SIOCGIFNETMASK; - } - error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, - (struct mbuf *) cmd, (struct mbuf *) data, - (struct mbuf *) ifp, p)); - switch (ocmd) { - - case OSIOCGIFADDR: - case OSIOCGIFDSTADDR: - case OSIOCGIFBRDADDR: - case OSIOCGIFNETMASK: - *(u_int16_t *)&ifr->ifr_addr = ifr->ifr_addr.sa_family; - } - - } -#endif break; } @@ -1700,7 +1650,7 @@ ifconf(u_long cmd, caddr_t data) TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { sa = ifa->ifa_addr; -#if defined(COMPAT_43) || defined(COMPAT_LINUX) +#ifdef COMPAT_LINUX if (cmd != OSIOCGIFCONF) #endif if (sa->sa_len > sizeof(*sa)) @@ -1731,12 +1681,11 @@ ifconf(u_long cmd, caddr_t data) if (space < sizeof(ifr)) break; -#if defined(COMPAT_43) || defined(COMPAT_LINUX) +#ifdef COMPAT_LINUX if (cmd == OSIOCGIFCONF) { - struct osockaddr *osa = - (struct osockaddr *)&ifr.ifr_addr; ifr.ifr_addr = *sa; - osa->sa_family = sa->sa_family; + *(u_int16_t *)&ifr.ifr_addr = + sa->sa_family; error = copyout((caddr_t)&ifr, (caddr_t)ifrp, sizeof (ifr)); ifrp++; diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index accd04e4777..045e282e7cf 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.130 2014/12/19 17:14:40 tedu Exp $ */ +/* $OpenBSD: if_tun.c,v 1.131 2015/01/21 02:23:14 guenther Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -673,7 +673,6 @@ tunioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) case TIOCGPGRP: *(int *)data = tp->tun_pgid; break; - case OSIOCGIFADDR: case SIOCGIFADDR: if (!(tp->tun_flags & TUN_LAYER2)) { splx(s); diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 514adb8f3bb..51cd1221f42 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.h,v 1.86 2015/01/18 04:52:03 guenther Exp $ */ +/* $OpenBSD: socket.h,v 1.87 2015/01/21 02:23:14 guenther Exp $ */ /* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */ /* @@ -476,17 +476,6 @@ struct cmsghdr { #define SCM_RIGHTS 0x01 /* access rights (array of int) */ #define SCM_TIMESTAMP 0x04 /* timestamp (struct timeval) */ -#if __BSD_VISIBLE -/* - * 4.3 compat sockaddr, move to compat file later - * XXX Needed by protocols/talkd.h - */ -struct osockaddr { - unsigned short sa_family; /* address family */ - char sa_data[14]; /* up to 14 bytes of direct address */ -}; -#endif /* __BSD_VISIBLE */ - #ifndef _KERNEL __BEGIN_DECLS diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h index 20ef02154a2..437082b2623 100644 --- a/sys/sys/sockio.h +++ b/sys/sys/sockio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sockio.h,v 1.56 2015/01/06 21:26:46 stsp Exp $ */ +/* $OpenBSD: sockio.h,v 1.57 2015/01/21 02:23:14 guenther Exp $ */ /* $NetBSD: sockio.h,v 1.5 1995/08/23 00:40:47 thorpej Exp $ */ /*- @@ -47,19 +47,15 @@ #define SIOCGPGRP _IOR('s', 9, int) /* get process group */ #define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */ -#define OSIOCGIFADDR _IOWR('i', 13, struct ifreq) /* get ifnet address */ #define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */ #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ -#define OSIOCGIFDSTADDR _IOWR('i', 15, struct ifreq) /* get p-p address */ #define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */ #define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */ #define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */ -#define OSIOCGIFBRDADDR _IOWR('i', 18, struct ifreq) /* get broadcast addr */ #define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */ #define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */ #define OSIOCGIFCONF _IOWR('i', 20, struct ifconf) /* get ifnet list */ #define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */ -#define OSIOCGIFNETMASK _IOWR('i', 21, struct ifreq) /* get net addr mask */ #define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */ #define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */ #define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */ |