From: Roy Marples Date: Mon, 18 Jan 2021 11:31:05 +0000 (+0000) Subject: script: Use rt_proto_add to ensure no duplicate interfaces on OpenBSD X-Git-Tag: v9.4.1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39b397dddda51d45958ced162cf1c7a589f65866;p=thirdparty%2Fdhcpcd.git script: Use rt_proto_add to ensure no duplicate interfaces on OpenBSD OpenBSD allows matching priorities, so we need to take the interfaces in the order given to ensure uniqueness. --- diff --git a/src/route.c b/src/route.c index 71523c14..89d0c132 100644 --- a/src/route.c +++ b/src/route.c @@ -409,6 +409,7 @@ rt_proto_add_ctx(rb_tree_t *tree, struct rt *rt, struct dhcpcd_ctx *ctx) return rt; rt_free(rt); + errno = EEXIST; return NULL; } diff --git a/src/script.c b/src/script.c index 5f404eac..622bab87 100644 --- a/src/script.c +++ b/src/script.c @@ -390,6 +390,7 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp, if (ifp->ctx->options & DHCPCD_DUMPLEASE) goto dumplease; + ifp->ctx->rt_order = 0; rb_tree_init(&ifaces, &rt_compare_proto_ops); TAILQ_FOREACH(ifp2, ifp->ctx->ifaces, next) { if (!ifp2->active) @@ -397,7 +398,7 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp, rt = rt_new(UNCONST(ifp2)); if (rt == NULL) goto eexit; - if (rb_tree_insert_node(&ifaces, rt) != rt) + if (rt_proto_add(&ifaces, rt) != rt) goto eexit; } if (fprintf(fp, "interface_order=") == -1)