From 39b397dddda51d45958ced162cf1c7a589f65866 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Mon, 18 Jan 2021 11:31:05 +0000 Subject: [PATCH] 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. --- src/route.c | 1 + src/script.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) 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) -- 2.47.2