summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2001-08-20 00:48:15 +0000
committerbrian <brian@cvs.openbsd.org>2001-08-20 00:48:15 +0000
commit102fafd5462043d7631d4c0153d0bfbeea5fe1f4 (patch)
treeb404009d5b7f51f3e9481d3597ec3b8b6f890fc6 /usr.sbin
parente0b2eaa098fac32d28aec256394004edb980e3cb (diff)
When attempting to change the default route under FreeBSD, don't write
the gateway and mask to the routing socket, otherwise the update fails. The code here was broken for FreeBSD when IPv6 support was added, but worked for OpenBSD. OpenBSD expects the gateway and mask to be supplied and fails the update otherwise.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/ppp/route.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/usr.sbin/ppp/ppp/route.c b/usr.sbin/ppp/ppp/route.c
index 91bacd901f1..82041771559 100644
--- a/usr.sbin/ppp/ppp/route.c
+++ b/usr.sbin/ppp/ppp/route.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: route.c,v 1.15 2001/08/19 23:22:18 brian Exp $
+ * $OpenBSD: route.c,v 1.16 2001/08/20 00:48:14 brian Exp $
*/
#include <sys/param.h>
@@ -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;