From d9688518ff04890216382547f7d1f69cb4157d55 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 10 Apr 2024 15:04:11 +0900 Subject: [PATCH] network/ndisc: drop ndisc_request_redirect_route() It is now called by only ndisc_redirect_handler(), and the check in ndisc_request_redirect_route() is redundant and already done by ndisc_redirect_verify_sender(). No functional change, just refactoring. --- src/network/networkd-ndisc.c | 37 +++++++++--------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 859217b14b1..b215fb4c1d0 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -419,33 +419,6 @@ static int ndisc_redirect_route_new(sd_ndisc_redirect *rd, Route **ret) { return 0; } -static int ndisc_request_redirect_route(Link *link, sd_ndisc_redirect *rd) { - struct in6_addr router, sender; - int r; - - assert(link); - assert(link->ndisc_default_router); - assert(rd); - - r = sd_ndisc_router_get_sender_address(link->ndisc_default_router, &router); - if (r < 0) - return r; - - r = sd_ndisc_redirect_get_sender_address(rd, &sender); - if (r < 0) - return r; - - if (!in6_addr_equal(&sender, &router)) - return 0; - - _cleanup_(route_unrefp) Route *route = NULL; - r = ndisc_redirect_route_new(rd, &route); - if (r < 0) - return r; - - return ndisc_request_route(route, link); -} - static int ndisc_remove_redirect_route(Link *link, sd_ndisc_redirect *rd) { _cleanup_(route_unrefp) Route *route = NULL; int r; @@ -578,17 +551,25 @@ static int ndisc_redirect_handler(Link *link, sd_ndisc_redirect *rd) { /* OK, the Redirect message is sent from the current default router. */ + /* First, drop conflicting redirect route, if exists. */ r = ndisc_redirect_drop_conflict(link, rd); if (r < 0) return r; + /* Then, remember the received message. */ r = set_ensure_put(&link->ndisc_redirects, &ndisc_redirect_hash_ops, rd); if (r < 0) return r; sd_ndisc_redirect_ref(rd); - return ndisc_request_redirect_route(link, rd); + /* Finally, request the corresponding route. */ + _cleanup_(route_unrefp) Route *route = NULL; + r = ndisc_redirect_route_new(rd, &route); + if (r < 0) + return r; + + return ndisc_request_route(route, link); } static int ndisc_drop_redirect(Link *link, const struct in6_addr *router, bool remove) {