summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2007-04-27 09:20:32 +0000
committerclaudio <claudio@openbsd.org>2007-04-27 09:20:32 +0000
commitb505309ec9aefcb0a497e20ea776c2e1b9d6e4fd (patch)
tree6eae5346943d545c02665ade15b8ded8c1299b19
parentUse the right size when we're backing out the allocation in (diff)
downloadwireguard-openbsd-b505309ec9aefcb0a497e20ea776c2e1b9d6e4fd.tar.xz
wireguard-openbsd-b505309ec9aefcb0a497e20ea776c2e1b9d6e4fd.zip
Ripd needs a valid route for 224.0.0.9 to work. Instead of forcing users to
set multicast_router=YES we inject a 224.0.0.9/32 route into the kernel and remove the route on exit if the insert was successful. With this ripd works out of the box. OK michele@ norby@
-rw-r--r--usr.sbin/ripd/kroute.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/usr.sbin/ripd/kroute.c b/usr.sbin/ripd/kroute.c
index 3f90a690029..92ae4929b39 100644
--- a/usr.sbin/ripd/kroute.c
+++ b/usr.sbin/ripd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.8 2007/04/19 13:54:36 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.9 2007/04/27 09:20:32 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -37,6 +37,7 @@
#include <string.h>
#include <unistd.h>
+#include "rip.h"
#include "ripd.h"
#include "log.h"
@@ -94,6 +95,9 @@ RB_HEAD(kif_tree, kif_node) kit;
RB_PROTOTYPE(kif_tree, kif_node, entry, kif_compare)
RB_GENERATE(kif_tree, kif_node, entry, kif_compare)
+struct kroute kr_all_rip_routers;
+int flag_all_rip_routers = 0;
+
int
kif_init(void)
{
@@ -111,8 +115,6 @@ kr_init(int fs)
int opt = 0, rcvbuf, default_rcvbuf;
socklen_t optlen;
- kr_state.fib_sync = fs;
-
if ((kr_state.fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) {
log_warn("kr_init: socket");
return (-1);
@@ -147,6 +149,16 @@ kr_init(int fs)
if (protect_lo() == -1)
return (-1);
+ kr_all_rip_routers.prefix.s_addr = inet_addr(ALL_RIP_ROUTERS);
+ kr_all_rip_routers.netmask.s_addr = htonl(INADDR_BROADCAST);
+ kr_all_rip_routers.nexthop.s_addr = htonl(INADDR_LOOPBACK);
+
+ kr_state.fib_sync = 1; /* force addition of multicast route */
+ if (send_rtmsg(kr_state.fd, RTM_ADD, &kr_all_rip_routers) != -1)
+ flag_all_rip_routers = 1;
+
+ kr_state.fib_sync = fs; /* now set correct sync mode */
+
event_set(&kr_state.ev, kr_state.fd, EV_READ | EV_PERSIST,
kr_dispatch_msg, NULL);
event_add(&kr_state.ev, NULL);
@@ -241,6 +253,12 @@ void
kr_shutdown(void)
{
kr_fib_decouple();
+
+ if (flag_all_rip_routers) {
+ kr_state.fib_sync = 1; /* force removal of mulitcast route */
+ (void)send_rtmsg(kr_state.fd, RTM_DELETE, &kr_all_rip_routers);
+ }
+
kroute_clear();
kif_clear();
}