From: Roy Marples Date: Mon, 12 Sep 2016 10:58:32 +0000 (+0000) Subject: OpenBSD allows many routes to the same dest with different gateways. X-Git-Tag: v6.11.4~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71b554fcd36ea639bec598f4c3bd1dddfc538c20;p=thirdparty%2Fdhcpcd.git OpenBSD allows many routes to the same dest with different gateways. dhcpcd does not support this yet, so just delete the route until there is an error. Fixes [ad8b5130d4]. --- diff --git a/ipv4.c b/ipv4.c index 80c9eb5b..98fb2b04 100644 --- a/ipv4.c +++ b/ipv4.c @@ -483,12 +483,26 @@ nc_route(struct rt *ort, struct rt *nrt) /* No route metrics, we need to delete the old route before * adding the new one. */ +#ifdef __OpenBSD__ + errno = 0; +#endif if (ort) { if (if_route(RTM_DELETE, ort) == -1 && errno != ESRCH) logger(nrt->iface->ctx, LOG_ERR, "if_route (DEL): %m"); else d_kroute(ort); } +#ifdef __OpenBSD__ + /* OpenBSD allows many routes to the same dest with different gateways. + * dhcpcd does not support this yet, so for the time being just keep on + * deleting the route until there is an error. */ + if (ort && errno == 0) { + for (;;) { + if (if_route(RTM_DELETE, ort) == -1) + break; + } + } +#endif if (if_route(RTM_ADD, nrt) != -1) return 0; #ifdef HAVE_ROUTE_METRIC diff --git a/ipv6.c b/ipv6.c index 4b1d9225..eb1dfcc6 100644 --- a/ipv6.c +++ b/ipv6.c @@ -2285,8 +2285,22 @@ nc_route(struct rt6 *ort, struct rt6 *nrt) /* No route metrics, we need to delete the old route before * adding the new one. */ +#ifdef __OpenBSD__ + errno = 0; +#endif if (ort && if_route6(RTM_DELETE, ort) == -1 && errno != ESRCH) - logger(nrt->iface->ctx, LOG_ERR, "if_route6: %m"); + logger(nrt->iface->ctx, LOG_ERR, "if_route6 (DEL): %m"); +#ifdef __OpenBSD__ + /* OpenBSD allows many routes to the same dest with different gateways. + * dhcpcd does not support this yet, so for the time being just keep on + * deleting the route until there is an error. */ + if (ort && errno == 0) { + for (;;) { + if (if_route6(RTM_DELETE, ort) == -1) + break; + } + } +#endif if (if_route6(RTM_ADD, nrt) != -1) return 0; #ifdef HAVE_ROUTE_METRIC