From c8740d2687dc793d90e63079030bf9e217d38cbf Mon Sep 17 00:00:00 2001 From: reyk Date: Sun, 28 Aug 2016 07:22:11 +0000 Subject: [PATCH] Remove obsolete gre(4) ioctls GRESADDRS, GRESADDRD, GREGADDRS, GREGADDRD, GRESPROTO, and GREGPROTO. They have been replaced by generic ioctls some time ago (eg. the "ifconfig gre0 tunnel") and there is no need to keep the old ones around. They are neither used in base nor in ports. OK sthen@ --- share/man/man4/gre.4 | 28 ++-------------- sys/net/if_gre.c | 79 ++++++++------------------------------------ sys/sys/sockio.h | 9 +---- 3 files changed, 17 insertions(+), 99 deletions(-) diff --git a/share/man/man4/gre.4 b/share/man/man4/gre.4 index 756037b8829..bee1432e582 100644 --- a/share/man/man4/gre.4 +++ b/share/man/man4/gre.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: gre.4,v 1.43 2015/07/16 15:46:41 sobrado Exp $ +.\" $OpenBSD: gre.4,v 1.44 2016/08/28 07:22:11 reyk Exp $ .\" $NetBSD: gre.4,v 1.10 1999/12/22 14:55:49 kleink Exp $ .\" .\" Copyright 1998 (c) The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 16 2015 $ +.Dd $Mdocdate: August 28 2016 $ .Dt GRE 4 .Os .Sh NAME @@ -98,26 +98,7 @@ etc. The number of interfaces is given by the corresponding .Ic pseudo-device line in the system configuration file. -.Nm gre -interfaces support the following -.Xr ioctl 2 Ns s : -.Bl -tag -width Ds -.It Dv GRESADDRS Fa "struct ifreq *" -Set the IP address of the local tunnel end. -.It Dv GRESADDRD Fa "struct ifreq *" -Set the IP address of the remote tunnel end. -.It Dv GREGADDRS Fa "struct ifreq *" -Query the IP address that is set for the local tunnel end. -.It Dv GREGADDRD Fa "struct ifreq *" -Query the IP address that is set for the remote tunnel end. -.It Dv GRESPROTO Fa "struct ifreq *" -Set the operation mode to the specified IP protocol value. -The protocol is passed to the interface in the -.Va ifr_flags -field of the -.Vt ifreq -structure. -The operation mode can also be set with the following modifiers to +The operation mode can be set with the following modifiers to .Xr ifconfig 8 : .Pp .Bl -tag -width "-link0" -offset indent -compact @@ -126,9 +107,6 @@ The operation mode can also be set with the following modifiers to .It Cm -link0 .Dv IPPROTO_MOBILE .El -.It Dv GREGPROTO Fa "struct ifreq *" -Query operation mode. -.El .Pp Note that the IP addresses of the tunnel endpoints may be the same as the ones defined with diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 6caae4043a5..43b8ebbb20a 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.78 2015/11/10 06:34:35 dlg Exp $ */ +/* $OpenBSD: if_gre.c,v 1.79 2016/08/28 07:22:11 reyk Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -430,7 +430,6 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct gre_softc *sc = ifp->if_softc; int s; struct sockaddr_in si; - struct sockaddr *sa = NULL; int error = 0; struct proc *prc = curproc; /* XXX */ @@ -463,69 +462,6 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCADDMULTI: case SIOCDELMULTI: break; - case GRESPROTO: - /* Check for superuser */ - if ((error = suser(prc, 0)) != 0) - break; - - sc->g_proto = ifr->ifr_flags; - switch (sc->g_proto) { - case IPPROTO_GRE: - ifp->if_flags |= IFF_LINK0; - break; - case IPPROTO_MOBILE: - ifp->if_flags &= ~IFF_LINK0; - break; - default: - error = EPROTONOSUPPORT; - break; - } - break; - case GREGPROTO: - ifr->ifr_flags = sc->g_proto; - break; - case GRESADDRS: - case GRESADDRD: - /* Check for superuser */ - if ((error = suser(prc, 0)) != 0) - break; - - /* - * set tunnel endpoints and mark if as up - */ - sa = &ifr->ifr_addr; - if (cmd == GRESADDRS ) - sc->g_src = (satosin(sa))->sin_addr; - if (cmd == GRESADDRD ) - sc->g_dst = (satosin(sa))->sin_addr; -recompute: - if ((sc->g_src.s_addr != INADDR_ANY) && - (sc->g_dst.s_addr != INADDR_ANY)) { - if (sc->route.ro_rt != NULL) { - rtfree(sc->route.ro_rt); - sc->route.ro_rt = NULL; - } - /* ip_output() will do the lookup */ - bzero(&sc->route, sizeof(sc->route)); - ifp->if_flags |= IFF_UP; - } - break; - case GREGADDRS: - bzero(&si, sizeof(si)); - si.sin_family = AF_INET; - si.sin_len = sizeof(struct sockaddr_in); - si.sin_addr.s_addr = sc->g_src.s_addr; - sa = sintosa(&si); - ifr->ifr_addr = *sa; - break; - case GREGADDRD: - bzero(&si, sizeof(si)); - si.sin_family = AF_INET; - si.sin_len = sizeof(struct sockaddr_in); - si.sin_addr.s_addr = sc->g_dst.s_addr; - sa = sintosa(&si); - ifr->ifr_addr = *sa; - break; case SIOCSETKALIVE: if ((error = suser(prc, 0)) != 0) break; @@ -569,7 +505,18 @@ recompute: } sc->g_src = ((struct sockaddr_in *)&lifr->addr)->sin_addr; sc->g_dst = ((struct sockaddr_in *)&lifr->dstaddr)->sin_addr; - goto recompute; + recompute: + if ((sc->g_src.s_addr != INADDR_ANY) && + (sc->g_dst.s_addr != INADDR_ANY)) { + if (sc->route.ro_rt != NULL) { + rtfree(sc->route.ro_rt); + sc->route.ro_rt = NULL; + } + /* ip_output() will do the lookup */ + bzero(&sc->route, sizeof(sc->route)); + ifp->if_flags |= IFF_UP; + } + break; case SIOCDIFPHYADDR: if ((error = suser(prc, 0)) != 0) break; diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h index 7b96563bd9e..6ccf4e62b71 100644 --- a/sys/sys/sockio.h +++ b/sys/sys/sockio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sockio.h,v 1.66 2016/06/15 19:39:34 gerhard Exp $ */ +/* $OpenBSD: sockio.h,v 1.67 2016/08/28 07:22:11 reyk Exp $ */ /* $NetBSD: sockio.h,v 1.5 1995/08/23 00:40:47 thorpej Exp $ */ /*- @@ -122,13 +122,6 @@ #define SIOCBRDGSPROTO _IOW('i', 90, struct ifbrparam)/* set protocol */ #define SIOCBRDGS -#define GRESADDRS _IOW('i', 101, struct ifreq) -#define GRESADDRD _IOW('i', 102, struct ifreq) -#define GREGADDRS _IOWR('i', 103, struct ifreq) -#define GREGADDRD _IOWR('i', 104, struct ifreq) -#define GRESPROTO _IOW('i', 105, struct ifreq) -#define GREGPROTO _IOWR('i', 106, struct ifreq) - #define SIOCSIFMTU _IOW('i', 127, struct ifreq) /* set ifnet mtu */ #define SIOCGIFMTU _IOWR('i', 126, struct ifreq) /* get ifnet mtu */ #define SIOCSIFASYNCMAP _IOW('i', 125, struct ifreq) /* set ppp asyncmap */ -- 2.20.1