aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2000-09-29 10:50:11 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2000-09-29 10:50:11 +0000
commit4eed20b85fdf721aac8cb26a609fe047583da38f (patch)
tree297e3d9bd81e73d03cb786b9670ae1c4b3449050
parentecfe112d3e38ceab4baf97811e84ee2b23fa380f (diff)
downloadsrc-4eed20b85fdf721aac8cb26a609fe047583da38f.tar.gz
src-4eed20b85fdf721aac8cb26a609fe047583da38f.zip
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.
Notes
Notes: svn path=/head/; revision=66449
-rw-r--r--sbin/route/route.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index edbc434bf0fd..e6ee0889ccf6 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);