network/route-metric: manage uint32_t RTAX_XYZ attributes in the same way

Except for RTAX_CC_ALGO, all RTAX_XYZ attributes take uint32_t and
the kernel's default value is zero. So, let's unify handling of the
attributes.

This should not change any effective behavior. Just refactoring.
This commit is contained in:
Yu Watanabe
2024-01-07 14:04:00 +09:00
parent d32a520b09
commit ebf4fa1e82
6 changed files with 169 additions and 125 deletions
+9 -6
View File
@@ -208,12 +208,15 @@ static int ndisc_request_route(Route *in, Link *link, sd_ndisc_router *rt) {
ndisc_set_route_priority(link, route);
if (!route->protocol_set)
route->protocol = RTPROT_RA;
if (route->metric.quickack < 0)
route->metric.quickack = link->network->ipv6_accept_ra_quickack;
if (route->metric.mtu == 0)
route->metric.mtu = mtu;
if (route->metric.hop_limit == 0)
route->metric.hop_limit = hop_limit;
r = route_metric_set(&route->metric, RTAX_MTU, mtu);
if (r < 0)
return r;
r = route_metric_set(&route->metric, RTAX_HOPLIMIT, hop_limit);
if (r < 0)
return r;
r = route_metric_set(&route->metric, RTAX_QUICKACK, link->network->ipv6_accept_ra_quickack);
if (r < 0)
return r;
is_new = route_get(NULL, link, route, NULL) < 0;