diff options
author | ru <ru@FreeBSD.org> | 2000-09-29 10:50:11 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2000-09-29 10:50:11 +0000 |
commit | 8ab228cbb3a9d70cc8dda947fbb997ac9bbe493d (patch) | |
tree | 2cf3b022806e302b9a25cf71a445e2b26d74fb34 /sbin/route | |
parent | d9dc1e970197c4e708688d2f33ce5d12f25cb3e6 (diff) | |
download | FreeBSD-src-8ab228cbb3a9d70cc8dda947fbb997ac9bbe493d.zip FreeBSD-src-8ab228cbb3a9d70cc8dda947fbb997ac9bbe493d.tar.gz |
Interpret the address argument as network-type address for `destination'
argument only. Before that, the `route add default gateway' first tried
the `gateway' as network address and passed its name to getnetbyname(3),
which in the BIND resolution case does the T_PTR lookup on that name.
Diffstat (limited to 'sbin/route')
-rw-r--r-- | sbin/route/route.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index edbc434..e6ee088 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -810,7 +810,7 @@ getaddr(which, s, hpp) struct hostent *hp; struct netent *np; u_long val; - char *q,qs; + char *q; int afamily; /* local copy of af so we can change it */ if (af == 0) { @@ -976,31 +976,30 @@ getaddr(which, s, hpp) q = strchr(s,'/'); if (q && which == RTA_DST) { - qs = *q; *q = '\0'; - if (((val = inet_addr(s)) != INADDR_NONE)) { + if ((val = inet_addr(s)) != INADDR_NONE) { inet_makenetandmask( - htonl(val), &su->sin, strtoul(q+1, 0, 0)); + ntohl(val), &su->sin, strtoul(q+1, 0, 0)); return (0); } - *q =qs; + *q = '/'; } - if (((val = inet_addr(s)) != INADDR_NONE) && - (which != RTA_DST || forcenet == 0)) { + if ((which != RTA_DST || forcenet == 0) && + (val = inet_addr(s)) != INADDR_NONE) { su->sin.sin_addr.s_addr = val; - if (inet_lnaof(su->sin.sin_addr) != INADDR_ANY) + if (which != RTA_DST || + inet_lnaof(su->sin.sin_addr) != INADDR_ANY) return (1); else { val = ntohl(val); goto netdone; } } - if ((val = inet_network(s)) != INADDR_NONE || - (forcehost == 0 && (np = getnetbyname(s)) != NULL && - (val = np->n_net) != 0)) { + if (which == RTA_DST && forcehost == 0 && + ((val = inet_network(s)) != INADDR_NONE || + ((np = getnetbyname(s)) != NULL && (val = np->n_net) != 0))) { netdone: - if (which == RTA_DST) - inet_makenetandmask(val, &su->sin, 0); + inet_makenetandmask(val, &su->sin, 0); return (0); } hp = gethostbyname(s); |