From 167c7ae511b5c320100405841fd8b93d743fa4ce Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 3 Oct 2022 12:28:41 +0900 Subject: [PATCH] network: ndisc: read prefix earlier No functional changes. --- src/network/networkd-ndisc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 2250235d4e..b1201eb00b 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -408,6 +408,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) { _cleanup_(route_freep) Route *route = NULL; usec_t timestamp_usec; uint32_t lifetime_sec; + struct in6_addr prefix; unsigned prefixlen; int r; @@ -429,6 +430,10 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) { if (r < 0) return log_link_error_errno(link, r, "Failed to get RA timestamp: %m"); + r = sd_ndisc_router_prefix_get_address(rt, &prefix); + if (r < 0) + return log_link_error_errno(link, r, "Failed to get prefix address: %m"); + r = sd_ndisc_router_prefix_get_prefixlen(rt, &prefixlen); if (r < 0) return log_link_error_errno(link, r, "Failed to get prefix length: %m"); @@ -439,13 +444,10 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) { route->family = AF_INET6; route->flags = RTM_F_PREFIX; + route->dst.in6 = prefix; route->dst_prefixlen = prefixlen; route->lifetime_usec = sec_to_usec(lifetime_sec, timestamp_usec); - r = sd_ndisc_router_prefix_get_address(rt, &route->dst.in6); - if (r < 0) - return log_link_error_errno(link, r, "Failed to get prefix address: %m"); - r = ndisc_request_route(TAKE_PTR(route), link, rt); if (r < 0) return log_link_error_errno(link, r, "Could not request prefix route: %m");