summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2021-01-18 11:31:05 +0000
committerRoy Marples <roy@marples.name>2021-01-18 11:31:05 +0000
commit569af70a83c255d3c70d23b9d21b3b9c1a68b90f (patch)
treee78d3cd25d0033e923728a3daf3ccc0f81fdef7c
parent37215e81df0651b2861ea23675f51b2deb332452 (diff)
downloaddhcpcd-569af70a83c255d3c70d23b9d21b3b9c1a68b90f.tar.xz
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.
-rw-r--r--src/route.c1
-rw-r--r--src/script.c3
2 files changed, 3 insertions, 1 deletions
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)