Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

route(8) use -inet6 automatically for addresses containing :

1 view
Skip to first unread message

Stuart Henderson

unread,
May 22, 2013, 3:47:36 PM5/22/13
to tech
does anyone see a downside to this? if the address family is not
explicitly specified, assume v6 if it looks like it may be an ipv6
address.

allows e.g. "route get 2001:200:dff:fff1:216:3eff:feb1:44d7"
without needing to specify -inet6.

Index: route.c
===================================================================
RCS file: /cvs/src/sbin/route/route.c,v
retrieving revision 1.161
diff -u -p -r1.161 route.c
--- route.c 21 Mar 2013 04:43:17 -0000 1.161
+++ route.c 22 May 2013 19:43:34 -0000
@@ -803,7 +803,10 @@ getaddr(int which, char *s, struct hoste
int afamily, bits;

if (af == 0) {
- af = AF_INET;
+ if (strchr(s, ':') != NULL)
+ af = AF_INET6;
+ else
+ af = AF_INET;
aflen = sizeof(struct sockaddr_in);
}
afamily = af; /* local copy of af so we can change it */

Stuart Henderson

unread,
May 22, 2013, 4:18:48 PM5/22/13
to tech
On 2013/05/22 20:47, Stuart Henderson wrote:
> does anyone see a downside to this? if the address family is not
> explicitly specified, assume v6 if it looks like it may be an ipv6
> address.
>
> allows e.g. "route get 2001:200:dff:fff1:216:3eff:feb1:44d7"
> without needing to specify -inet6.

oops, as pointed out by jca@, I missed aflen (or rather, saw it and
for some unknown reason thought it didn't matter, I blame my tooth ;)

Index: route.c
===================================================================
RCS file: /cvs/src/sbin/route/route.c,v
retrieving revision 1.161
diff -u -p -r1.161 route.c
--- route.c 21 Mar 2013 04:43:17 -0000 1.161
+++ route.c 22 May 2013 20:15:53 -0000
@@ -803,8 +803,13 @@ getaddr(int which, char *s, struct hoste
int afamily, bits;

if (af == 0) {
- af = AF_INET;
- aflen = sizeof(struct sockaddr_in);
+ if (strchr(s, ':') != NULL) {
+ af = AF_INET6;
+ aflen = sizeof(struct sockaddr_in6);
+ } else {
+ af = AF_INET;
+ aflen = sizeof(struct sockaddr_in);
+ }

Sebastian Benoit

unread,
May 23, 2013, 9:04:45 AM5/23/13
to st...@openbsd.org, tech
Stuart Henderson(st...@openbsd.org) on 2013.05.22 21:18:05 +0100:
> On 2013/05/22 20:47, Stuart Henderson wrote:
> > does anyone see a downside to this?

i see none other than making the maze of options of route(8) a bit more
bizarre.
ok

maybe a note in the manpage?

Stuart Henderson

unread,
May 23, 2013, 9:51:34 AM5/23/13
to tech
Possible manpage wording..

Index: route.8
===================================================================
RCS file: /cvs/src/sbin/route/route.8,v
retrieving revision 1.70
diff -u -p -r1.70 route.8
--- route.8 13 Jul 2012 10:15:53 -0000 1.70
+++ route.8 23 May 2013 13:49:50 -0000
@@ -310,6 +310,9 @@ Actual
data, in hexadecimal format
.El
.Pp
+In the absence of modifiers, an address is assumed to be IPv4,
+unless containing a : character when it is treated as IPv6.
+.Pp
The optional modifier
.Fl link
specifies that all subsequent addresses are specified as link-level addresses,

0 new messages