1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-03 00:58:21 +03:00

Merge pull request #21691 from yuwata/network-route-prefix-length

network: route: several tiny cleanups
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-12-09 09:24:36 +01:00 committed by GitHub
commit 0c62d52fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -299,9 +299,9 @@ static int route_build_json(Route *route, JsonVariant **ret) {
JSON_BUILD_PAIR_IN_ADDR("Destination", &route->dst, route->family),
JSON_BUILD_PAIR_UNSIGNED("DestinationPrefixLength", route->dst_prefixlen),
JSON_BUILD_PAIR_IN_ADDR_NON_NULL("Gateway", &route->gw, route->gw_family),
JSON_BUILD_PAIR_IN_ADDR_NON_NULL("Source", &route->src, route->family),
JSON_BUILD_PAIR_CONDITION(in_addr_is_set(route->family, &route->src),
"SourcePrefixLength", JSON_BUILD_UNSIGNED(route->src_prefixlen)),
JSON_BUILD_PAIR_CONDITION(route->src_prefixlen > 0,
"Source", JSON_BUILD_IN_ADDR(&route->src, route->family)),
JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("SourcePrefixLength", route->src_prefixlen),
JSON_BUILD_PAIR_IN_ADDR_NON_NULL("PreferredSource", &route->prefsrc, route->family),
JSON_BUILD_PAIR_UNSIGNED("Scope", route->scope),
JSON_BUILD_PAIR_STRING("ScopeString", scope),

View File

@ -560,8 +560,8 @@ static void log_route_debug(const Route *route, const char *str, const Link *lin
(void) network_config_state_to_string_alloc(route->state, &state);
if (in_addr_is_set(route->family, &route->dst) || route->dst_prefixlen > 0)
(void) in_addr_prefix_to_string(route->family, &route->dst, route->dst_prefixlen, &dst);
if (in_addr_is_set(route->family, &route->src))
(void) in_addr_to_string(route->family, &route->src, &src);
if (in_addr_is_set(route->family, &route->src) || route->src_prefixlen > 0)
(void) in_addr_prefix_to_string(route->family, &route->src, route->src_prefixlen, &src);
if (in_addr_is_set(route->gw_family, &route->gw)) {
(void) in_addr_to_string(route->gw_family, &route->gw, &gw_alloc);
gw = gw_alloc;
@ -2124,6 +2124,8 @@ int config_parse_destination(
return 0;
}
(void) in_addr_mask(n->family, buffer, *prefixlen);
TAKE_PTR(n);
return 0;
}