summaryrefslogtreecommitdiff
path: root/sbin/route/route.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2019-08-29 14:28:35 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2019-08-29 14:28:35 +0000
commit545c420984916298dde89001a80658e3d1f54b52 (patch)
tree5c252a56aacf552ffcc0ba160538342f86f99527 /sbin/route/route.c
parent6363a8013523fe801c513ad4bc950226ec669f70 (diff)
route(8) used inet/inet6 autodetection also for the link address
type. Provide the address family AF_LINK and storage size of struct sockaddr_dl to the kernel when creating an IFP routing address. OK mpi@
Diffstat (limited to 'sbin/route/route.c')
-rw-r--r--sbin/route/route.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index d3225240df3..bd57fae5324 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.230 2019/03/31 11:30:35 kn Exp $ */
+/* $OpenBSD: route.c,v 1.231 2019/08/29 14:28:34 bluhm Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
@@ -579,7 +579,7 @@ newroute(int argc, char **argv)
case K_IFP:
if (!--argc)
usage(1+*argv);
- getaddr(RTA_IFP, af, *++argv, NULL);
+ getaddr(RTA_IFP, AF_LINK, *++argv, NULL);
break;
case K_GATEWAY:
if (!--argc)
@@ -798,7 +798,7 @@ getaddr(int which, int af, char *s, struct hostent **hpp)
{
sup su = NULL;
struct hostent *hp;
- int afamily, bits;
+ int aflength, afamily, bits;
if (af == AF_UNSPEC) {
if (strchr(s, ':') != NULL) {
@@ -809,7 +809,9 @@ getaddr(int which, int af, char *s, struct hostent **hpp)
aflen = sizeof(struct sockaddr_in);
}
}
- afamily = af; /* local copy of af so we can change it */
+ /* local copy of len and af so we can change it */
+ aflength = aflen;
+ afamily = af;
rtm_addrs |= which;
switch (which) {
@@ -824,6 +826,7 @@ getaddr(int which, int af, char *s, struct hostent **hpp)
break;
case RTA_IFP:
su = &so_ifp;
+ aflength = sizeof(struct sockaddr_dl);
afamily = AF_LINK;
break;
case RTA_IFA:
@@ -833,7 +836,7 @@ getaddr(int which, int af, char *s, struct hostent **hpp)
errx(1, "internal error");
/* NOTREACHED */
}
- su->sa.sa_len = aflen;
+ su->sa.sa_len = aflength;
su->sa.sa_family = afamily;
if (strcmp(s, "default") == 0) {