summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-12-09 06:56:26 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-12-09 07:02:29 +0900
commite944711fba9243b3d141879dc78f4a2ee6f12292 (patch)
tree847418c92e6bb6181bd7635fd6875ac3624ce6a2 /src/network
parent7cf0ed03f27c5facb4d1ca7edba33404290deee8 (diff)
downloadsystemd-e944711fba9243b3d141879dc78f4a2ee6f12292.tar.gz
network: json: add src address when its prefix length is non-zero
This should not change anything. Just for consistency with route_set_netlink_message(), which sets RTA_SRC attribute when prefix length is non-zero.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-json.c6
1 files changed, 3 insertions, 3 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),