diff options
author | 2007-04-27 09:20:32 +0000 | |
---|---|---|
committer | 2007-04-27 09:20:32 +0000 | |
commit | b505309ec9aefcb0a497e20ea776c2e1b9d6e4fd (patch) | |
tree | 6eae5346943d545c02665ade15b8ded8c1299b19 | |
parent | Use the right size when we're backing out the allocation in (diff) | |
download | wireguard-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.c | 24 |
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(); } |