summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-varlink.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-02-05 18:43:55 +0100
committerLennart Poettering <lennart@poettering.net>2021-02-06 00:17:10 +0100
commitf8f5b8d864d3d034dbbfb84fdad4f2cbeb7790f9 (patch)
tree2d1fb04da785e039e7d931cae19f8b731e1eaa96 /src/resolve/resolved-varlink.c
parent9c09454dcee06283fc429ffef9f14ac354074f5f (diff)
downloadsystemd-f8f5b8d864d3d034dbbfb84fdad4f2cbeb7790f9.tar.gz
resolved: suppress ifindex info in varlink JSON responses if zero
If we don't have ifindex info, don't set the field for it. We already do that for parsed IP address replies, let's do it for all cases: it's a bit nicer to suppress the ifindex prop if it doesn't apply than to pass it invalid. This is the other side of #18482, i.e. fixes things so that the parser doesn't get tripped up by this. (This too makes a problem go away we should track down properly, i.e. figure out how the ifindex got lost in https://github.com/systemd/systemd/pull/17823#issuecomment-742439422 )
Diffstat (limited to 'src/resolve/resolved-varlink.c')
-rw-r--r--src/resolve/resolved-varlink.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c
index 2fb9d38dfa..9a8a4f3013 100644
--- a/src/resolve/resolved-varlink.c
+++ b/src/resolve/resolved-varlink.c
@@ -180,7 +180,7 @@ static void vl_method_resolve_hostname_complete(DnsQuery *q) {
r = json_build(&entry,
JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("ifindex", JSON_BUILD_INTEGER(ifindex)),
+ JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", JSON_BUILD_INTEGER(ifindex)),
JSON_BUILD_PAIR("family", JSON_BUILD_INTEGER(family)),
JSON_BUILD_PAIR("address", JSON_BUILD_BYTE_ARRAY(p, FAMILY_ADDRESS_SIZE(family)))));
if (r < 0)
@@ -408,7 +408,7 @@ static void vl_method_resolve_address_complete(DnsQuery *q) {
r = json_build(&entry,
JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("ifindex", JSON_BUILD_INTEGER(ifindex)),
+ JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", JSON_BUILD_INTEGER(ifindex)),
JSON_BUILD_PAIR("name", JSON_BUILD_STRING(normalized))));
if (r < 0)
goto finish;