]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: json: add src address when its prefix length is non-zero
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Dec 2021 21:56:26 +0000 (06:56 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Dec 2021 22:02:29 +0000 (07:02 +0900)
This should not change anything. Just for consistency with
route_set_netlink_message(), which sets RTA_SRC attribute when prefix
length is non-zero.

src/network/networkd-json.c

index aa0c606543a9bc8954f5d4a4c7d228371c8499fb..f2bd4982fe0ad0a78826c8307bae67e67ed5240e 100644 (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),