]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
script: Use rt_proto_add to ensure no duplicate interfaces on OpenBSD
authorRoy Marples <roy@marples.name>
Mon, 18 Jan 2021 11:31:05 +0000 (11:31 +0000)
committerRoy Marples <roy@marples.name>
Mon, 18 Jan 2021 11:31:05 +0000 (11:31 +0000)
OpenBSD allows matching priorities, so we need to take the interfaces
in the order given to ensure uniqueness.

src/route.c
src/script.c

index 71523c146a86c0d3fbd0801009e6ab21d1a1882d..89d0c13279269015b62df77f25b746e1b6458482 100644 (file)
@@ -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;
 }
 
index 5f404eac456a9136222bdb80a4b8737e8b71ef91..622bab8737aa203bbccb610a1e1c7f35c401515f 100644 (file)
@@ -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)