From: Yu Watanabe Date: Wed, 8 Dec 2021 21:56:26 +0000 (+0900) Subject: network: json: add src address when its prefix length is non-zero X-Git-Tag: v250-rc1~13^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e944711fba9243b3d141879dc78f4a2ee6f12292;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/network/networkd-json.c b/src/network/networkd-json.c index aa0c606543a..f2bd4982fe0 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),