diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-09-01 04:52:12 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-09-01 04:54:32 +0200 |
commit | c8dbf9acc10939f2d6c4bdd8cdee1d2ff9a4204e (patch) | |
tree | 111a3472857e12ad260e7bd5c57ad6b5191d0449 /src/network/networkd-route.c | |
parent | network/route: also update source, status, and so on EEXIST (diff) | |
download | systemd-c8dbf9acc10939f2d6c4bdd8cdee1d2ff9a4204e.tar.xz systemd-c8dbf9acc10939f2d6c4bdd8cdee1d2ff9a4204e.zip |
network/route: fix adjustment of nexthop weight
Fixes #34167.
Diffstat (limited to 'src/network/networkd-route.c')
-rw-r--r-- | src/network/networkd-route.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 788b2cb04f..271d498502 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -1104,9 +1104,15 @@ static int process_route_one( route = route_ref(tmp); is_new = true; - } else + } else { /* Update remembered route with the received notification. */ - route->nexthop.weight = tmp->nexthop.weight; + + /* Here, update weight only when a non-zero weight is received. As the kernel does + * not provide the weight of a single-path route. In such case, tmp->nexthop.weight + * is zero, hence we should not overwrite the known weight of the route. */ + if (tmp->nexthop.weight != 0) + route->nexthop.weight = tmp->nexthop.weight; + } /* Also update information that cannot be obtained through netlink notification. */ if (req && req->waiting_reply) { @@ -1116,6 +1122,14 @@ static int process_route_one( link_enter_failed(link); return 0; } + + /* We configure IPv6 multipath route separatedly. When the first path is configured, + * the kernel does not provide the weight of the path. So, we need to adjust it here. + * Hopefully, the weight is assigned correctly. */ + if (route->nexthop.weight == 0) { + Route *rt = ASSERT_PTR(req->userdata); + route->nexthop.weight = rt->nexthop.weight; + } } route_enter_configured(route); |