aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/route.c
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>2001-08-20 00:46:33 +0000
committerBrian Somers <brian@FreeBSD.org>2001-08-20 00:46:33 +0000
commitd42d9220c705dee27342357b74d10a46c50890fc (patch)
tree278fcffb1ab827df3d06df0a8b46bcf3b916979a /usr.sbin/ppp/route.c
parent2f9e4e8025d489474ae350ac90f08d1879050dc0 (diff)
downloadsrc-d42d9220c705dee27342357b74d10a46c50890fc.tar.gz
src-d42d9220c705dee27342357b74d10a46c50890fc.zip
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.
Notes
Notes: svn path=/head/; revision=81934
Diffstat (limited to 'usr.sbin/ppp/route.c')
-rw-r--r--usr.sbin/ppp/route.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c
index 3472eb71f8f6..4c7357f105ab 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;