diff options
author | Sebastian Benoit <benno@cvs.openbsd.org> | 2017-08-10 16:05:24 +0000 |
---|---|---|
committer | Sebastian Benoit <benno@cvs.openbsd.org> | 2017-08-10 16:05:24 +0000 |
commit | a679b65bf1ad9b1acca3a7fcbf71c7030d170186 (patch) | |
tree | 454517de79e3b21ee31bb235cd492800ead8002f | |
parent | 6c059cfe438aa3aadca1b91720d9b94b558a5c7a (diff) |
autodetect AF when setting inet6 default route
From Denis Fondras, thanks!
ok phessler@ bluhm@
-rw-r--r-- | sbin/route/route.8 | 7 | ||||
-rw-r--r-- | sbin/route/route.c | 10 |
2 files changed, 12 insertions, 5 deletions
diff --git a/sbin/route/route.8 b/sbin/route/route.8 index 98335b3cc2b..84e7ee56bfa 100644 --- a/sbin/route/route.8 +++ b/sbin/route/route.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: route.8,v 1.79 2017/01/01 01:08:11 tb Exp $ +.\" $OpenBSD: route.8,v 1.80 2017/08/10 16:05:23 benno Exp $ .\" $NetBSD: route.8,v 1.6 1995/03/18 15:00:13 cgd Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)route.8 8.3 (Berkeley) 3/19/94 .\" -.Dd $Mdocdate: January 1 2017 $ +.Dd $Mdocdate: August 10 2017 $ .Dt ROUTE 8 .Os .Sh NAME @@ -317,7 +317,8 @@ data, in hexadecimal format In the absence of modifiers, an address is assumed to be IPv4, unless containing a .Sq :\& -character, when it is treated as IPv6. +character, when it is treated as IPv6. When using the "default" keyword, +the address family used is that of the gateway. .Pp The optional modifier .Fl link diff --git a/sbin/route/route.c b/sbin/route/route.c index 44318f33e88..a6ee399c427 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.201 2017/08/10 13:44:48 benno Exp $ */ +/* $OpenBSD: route.c,v 1.202 2017/08/10 16:05:23 benno Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -72,7 +72,7 @@ union sockunion so_dst, so_gate, so_mask, so_ifa, so_ifp, so_label, so_src; typedef union sockunion *sup; pid_t pid; -int rtm_addrs, s; +int rtm_addrs, s, defroute; int forcehost, forcenet, Fflag, nflag, af, qflag, tflag, Tflag; int iflag, verbose, aflen = sizeof(struct sockaddr_in); int locking, lockrest, debugonly; @@ -876,6 +876,10 @@ getaddr(int which, char *s, struct hostent **hpp) break; case RTA_GATEWAY: su = &so_gate; + if (defroute) { + so_dst.sa.sa_len = aflen; + so_dst.sa.sa_family = af; + } break; case RTA_NETMASK: su = &so_mask; @@ -902,6 +906,8 @@ getaddr(int which, char *s, struct hostent **hpp) break; case RTA_NETMASK: su->sa.sa_len = 0; + af = 0; + defroute = 1; } return (0); } |