diff options
author | brian <brian@FreeBSD.org> | 2001-11-23 17:19:27 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-11-23 17:19:27 +0000 |
commit | e37212b65332aa0be86109565050259dd397d661 (patch) | |
tree | 1da3ec9181b6762de785370771bfb70b849e2ee1 /usr.sbin/ppp | |
parent | ee9d3747a114fa9cdb6fcd9397a2e7c174489944 (diff) | |
download | FreeBSD-src-e37212b65332aa0be86109565050259dd397d661.zip FreeBSD-src-e37212b65332aa0be86109565050259dd397d661.tar.gz |
Be paranoid about non-zero netmasks being associated with INET addresses
of 0.0.0.0.
The OpenBSD PF_ROUTE/NET_RT_DUMP sysctl is sending back routes with
RTAX_NETMASK set, but the corresponding sockaddr being 4 zero bytes
(with an address family of zero). ppp was getting confused by this
and ending up interpreting it as a 0.0.0.0/32 routing table
destination and subsequently failing to do anything with the route.
Specifically, after this fix, ppp under OpenBSD can successfully
change and delete the default route again !
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/ncpaddr.c | 23 | ||||
-rw-r--r-- | usr.sbin/ppp/route.c | 2 |
2 files changed, 20 insertions, 5 deletions
diff --git a/usr.sbin/ppp/ncpaddr.c b/usr.sbin/ppp/ncpaddr.c index aa99bda..943db3d 100644 --- a/usr.sbin/ppp/ncpaddr.c +++ b/usr.sbin/ppp/ncpaddr.c @@ -591,8 +591,13 @@ ncprange_sethost(struct ncprange *range, const struct ncpaddr *from) case AF_INET: range->ncprange_family = AF_INET; range->ncprange_ip4addr = from->ncpaddr_ip4addr; - range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; - range->ncprange_ip4width = 32; + if (from->ncpaddr_ip4addr.s_addr == INADDR_ANY) { + range->ncprange_ip4mask.s_addr = INADDR_ANY; + range->ncprange_ip4width = 0; + } else { + range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; + range->ncprange_ip4width = 32; + } break; #ifndef NOINET6 @@ -654,8 +659,13 @@ ncprange_setip4host(struct ncprange *range, struct in_addr from) { range->ncprange_family = AF_INET; range->ncprange_ip4addr = from; - range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; - range->ncprange_ip4width = 32; + if (from.s_addr == INADDR_ANY) { + range->ncprange_ip4mask.s_addr = INADDR_ANY; + range->ncprange_ip4width = 0; + } else { + range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; + range->ncprange_ip4width = 32; + } } void @@ -693,7 +703,10 @@ ncprange_setsa(struct ncprange *range, const struct sockaddr *host, case AF_INET: range->ncprange_family = AF_INET; range->ncprange_ip4addr = host4->sin_addr; - if (mask4) { + if (host4->sin_addr.s_addr == INADDR_ANY) { + range->ncprange_ip4mask.s_addr = INADDR_ANY; + range->ncprange_ip4width = 0; + } else if (mask4 && mask4->sin_family == AF_INET) { range->ncprange_ip4mask.s_addr = mask4->sin_addr.s_addr; range->ncprange_ip4width = mask42bits(mask4->sin_addr); } else { diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index 2ff5ee3..76ae24e 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -317,6 +317,8 @@ route_ParseHdr(struct rt_msghdr *rtm, struct sockaddr *sa[RTAX_MAX]) if (rtm->rtm_addrs & (1 << rtax)) { sa[rtax] = (struct sockaddr *)wp; wp += ROUNDUP(sa[rtax]->sa_len); + if (sa[rtax]->sa_family == 0) + sa[rtax] = NULL; /* ??? */ } else sa[rtax] = NULL; } |