summaryrefslogtreecommitdiffstats
path: root/src/ipv6.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-06-07 16:37:00 +0100
committerRoy Marples <roy@marples.name>2019-06-07 16:37:00 +0100
commit108d94cc30787a009ad05383bf517745dacd70ff (patch)
tree5f8123754f029289386a67d3417293816e31a81e /src/ipv6.c
parente1d2d6272df55c23391d3423c6debda437997dc8 (diff)
downloaddhcpcd-108d94cc30787a009ad05383bf517745dacd70ff.tar.xz
route: Use order from message / config
We can't just make the order up as that is prone to error. So apply ordering as from the source.
Diffstat (limited to 'src/ipv6.c')
-rw-r--r--src/ipv6.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/ipv6.c b/src/ipv6.c
index e39a6584..f9ff1422 100644
--- a/src/ipv6.c
+++ b/src/ipv6.c
@@ -2226,8 +2226,8 @@ inet6_staticroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
(IPV6_AF_ADDED | IPV6_AF_STATIC))
{
rt = inet6_makeprefix(ifp, NULL, ia);
- if (rt && rb_tree_insert_node(routes, rt) != rt)
- rt_free(rt);
+ if (rt)
+ rt_proto_add(routes, rt);
}
}
}
@@ -2251,17 +2251,14 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx, int expired,
rt = inet6_makeprefix(rap->iface, rap, addr);
if (rt) {
rt->rt_dflags |= RTDF_RA;
- if (rb_tree_insert_node(routes, rt) != rt)
- rt_free(rt);
+ rt_proto_add(routes, rt);
}
}
if (rap->lifetime) {
rt = inet6_makerouter(rap);
if (rt) {
rt->rt_dflags |= RTDF_RA;
- if (rb_tree_insert_node(routes, rt) != rt)
- rt_free(rt);
- else if (have_default)
+ if (rt_proto_add(routes, rt) && have_default)
*have_default = true;
}
}
@@ -2287,8 +2284,7 @@ inet6_dhcproutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx,
if (rt == NULL)
continue;
rt->rt_dflags |= RTDF_DHCP;
- if (rb_tree_insert_node(routes, rt) != rt)
- rt_free(rt);
+ rt_proto_add(routes, rt);
}
}
}
@@ -2313,7 +2309,7 @@ inet6_getroutes(struct dhcpcd_ctx *ctx, rb_tree_t *routes)
#ifdef DHCP6
/* We have no way of knowing if prefixes added by DHCP are reachable
* or not, so we have to assume they are.
- * Add bound before delegated so we can prefer interfaces better */
+ * Add bound before delegated so we can prefer interfaces better. */
if (inet6_dhcproutes(routes, ctx, DH6S_BOUND) == -1)
return false;
if (inet6_dhcproutes(routes, ctx, DH6S_DELEGATED) == -1)