summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-04-10 08:04:11 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-04-11 21:59:42 +0200
commitd9688518ff04890216382547f7d1f69cb4157d55 (patch)
treea2d2905aa5e488939625378a03f22c66fcfe1548
parentnetwork/ndisc: redirect routes do not have lifetime (diff)
downloadsystemd-d9688518ff04890216382547f7d1f69cb4157d55.tar.xz
systemd-d9688518ff04890216382547f7d1f69cb4157d55.zip
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.
-rw-r--r--src/network/networkd-ndisc.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index 859217b14b..b215fb4c1d 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) {