-.\" $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.
.\" 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
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
.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
-/* $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 $ */
/*
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 */
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;
}
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;
-/* $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 $ */
/*-
#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 */