diff options
author | brian <brian@FreeBSD.org> | 2001-08-20 00:46:33 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-08-20 00:46:33 +0000 |
commit | 0630cc6224ea7fa2d2e5108902ed6d6d2152a119 (patch) | |
tree | 278fcffb1ab827df3d06df0a8b46bcf3b916979a /usr.sbin/ppp/route.c | |
parent | 05c33a209bd0403f851f4ffd54fe4d16a1a663ef (diff) | |
download | FreeBSD-src-0630cc6224ea7fa2d2e5108902ed6d6d2152a119.zip FreeBSD-src-0630cc6224ea7fa2d2e5108902ed6d6d2152a119.tar.gz |
When attempting to change the default route, don't write the gateway
and mask to the routing socket, otherwise the update fails.
Warning provided by: markm
The code here was broken for FreeBSD when IPv6 support was added, but
was fixed for OpenBSD. OpenBSD expects the gateway and mask to be
supplied and fails the update otherwise.
Diffstat (limited to 'usr.sbin/ppp/route.c')
-rw-r--r-- | usr.sbin/ppp/route.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index 3472eb7..4c7357f 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -838,7 +838,7 @@ rt_Update(struct bundle *bundle, const struct sockaddr *dst, memset(&rtmes, '\0', sizeof rtmes); rtmes.m_rtm.rtm_version = RTM_VERSION; rtmes.m_rtm.rtm_type = RTM_CHANGE; - rtmes.m_rtm.rtm_addrs = RTA_GATEWAY; + rtmes.m_rtm.rtm_addrs = 0; rtmes.m_rtm.rtm_seq = ++bundle->routing_seq; rtmes.m_rtm.rtm_pid = getpid(); rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC; @@ -862,12 +862,31 @@ rt_Update(struct bundle *bundle, const struct sockaddr *dst, memcpy(p, dst, dst->sa_len); p += dst->sa_len; } - memcpy(p, gw, gw->sa_len); - p += gw->sa_len; - if (mask) { - rtmes.m_rtm.rtm_addrs |= RTA_NETMASK; - memcpy(p, mask, mask->sa_len); - p += mask->sa_len; + +#ifdef __FreeBSD__ + /* + * In order to update the default route under FreeBSD, only the destination + * address should be specified. If the (empty) mask or the gateway + * address are used, the update fails... + * Conversely, if the gateway and mask are omitted under OpenBSD, the + * update will fail. + */ + if (dst) + ncprange_setsa(&ncpdst, dst, mask); + else + ncprange_init(&ncpdst); + + if (!ncprange_isdefault(&ncpdst)) +#endif + { + rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; + memcpy(p, gw, gw->sa_len); + p += gw->sa_len; + if (mask) { + rtmes.m_rtm.rtm_addrs |= RTA_NETMASK; + memcpy(p, mask, mask->sa_len); + p += mask->sa_len; + } } rtmes.m_rtm.rtm_msglen = p - (char *)&rtmes; |