From: Roy Marples Date: Tue, 18 Jun 2019 16:35:23 +0000 (+0100) Subject: route: Build list of static routes and routers correctly. X-Git-Tag: v8.0.0~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33191264bdfcd7dadae5cedf2c34589a1d43bc7a;p=thirdparty%2Fdhcpcd.git route: Build list of static routes and routers correctly. They they need to be inserted by rt_proto_add(). --- diff --git a/src/dhcp.c b/src/dhcp.c index 25a9e72c..e73a900f 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -656,9 +656,7 @@ get_option_routes(rb_tree_t *routes, struct interface *ifp, sa_in_init(&rt->rt_dest, &dest); sa_in_init(&rt->rt_netmask, &netmask); sa_in_init(&rt->rt_gateway, &gateway); - if (rb_tree_insert_node(routes, rt) != rt) - rt_free(rt); - else + if (rt_proto_add(routes, rt)) n++; } } @@ -668,7 +666,7 @@ get_option_routes(rb_tree_t *routes, struct interface *ifp, p = get_option(ifp->ctx, bootp, bootp_len, DHO_ROUTER, &len); else p = NULL; - if (p) { + if (p && len % 4 == 0) { e = p + len; dest.s_addr = INADDR_ANY; netmask.s_addr = INADDR_ANY; @@ -680,9 +678,7 @@ get_option_routes(rb_tree_t *routes, struct interface *ifp, sa_in_init(&rt->rt_dest, &dest); sa_in_init(&rt->rt_netmask, &netmask); sa_in_init(&rt->rt_gateway, &gateway); - if (rb_tree_insert_node(routes, rt) != rt) - rt_free(rt); - else + if (rt_proto_add(routes, rt)) n++; } }