]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
OpenBSD allows many routes to the same dest with different gateways.
authorRoy Marples <roy@marples.name>
Mon, 12 Sep 2016 10:58:32 +0000 (10:58 +0000)
committerRoy Marples <roy@marples.name>
Mon, 12 Sep 2016 10:58:32 +0000 (10:58 +0000)
dhcpcd does not support this yet, so just delete the route until there is an error.
Fixes [ad8b5130d4].

ipv4.c
ipv6.c

diff --git a/ipv4.c b/ipv4.c
index 80c9eb5b06811a49a29a4deea22be829cfd4dd8d..98fb2b04ac84861d1f0916a9b9e58906d4c79b5d 100644 (file)
--- 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 4b1d92258316ad387648de8636529b08fb187384..eb1dfcc6d3dc6dd18ed6d68d89eeac46e108cf1b 100644 (file)
--- 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