diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-12-09 09:24:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-09 09:24:36 +0100 |
commit | 0c62d52fe692dee3f2549652b6055cebeecb3610 (patch) | |
tree | b1191925bd907d3f87f861d8c8ffecb861a03e31 | |
parent | ab8a8a4e7721270196f9c7984223fcff41754780 (diff) | |
parent | 72fa19239d8e11d993ea9a73b129b0bd6deaf736 (diff) | |
download | systemd-0c62d52fe692dee3f2549652b6055cebeecb3610.tar.gz |
Merge pull request #21691 from yuwata/network-route-prefix-length
network: route: several tiny cleanups
-rw-r--r-- | src/network/networkd-json.c | 6 | ||||
-rw-r--r-- | src/network/networkd-route.c | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/network/networkd-json.c b/src/network/networkd-json.c index aa0c606543..f2bd4982fe 100644 --- a/src/network/networkd-json.c +++ b/src/network/networkd-json.c @@ -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), diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 82873e9a91..d791c4d044 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -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; } |