X Tutup
Skip to content

Commit f8f5b8d

Browse files
committed
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 systemd#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 systemd#17823 (comment) )
1 parent 9c09454 commit f8f5b8d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/resolve/resolved-varlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void vl_method_resolve_hostname_complete(DnsQuery *q) {
180180

181181
r = json_build(&entry,
182182
JSON_BUILD_OBJECT(
183-
JSON_BUILD_PAIR("ifindex", JSON_BUILD_INTEGER(ifindex)),
183+
JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", JSON_BUILD_INTEGER(ifindex)),
184184
JSON_BUILD_PAIR("family", JSON_BUILD_INTEGER(family)),
185185
JSON_BUILD_PAIR("address", JSON_BUILD_BYTE_ARRAY(p, FAMILY_ADDRESS_SIZE(family)))));
186186
if (r < 0)
@@ -408,7 +408,7 @@ static void vl_method_resolve_address_complete(DnsQuery *q) {
408408

409409
r = json_build(&entry,
410410
JSON_BUILD_OBJECT(
411-
JSON_BUILD_PAIR("ifindex", JSON_BUILD_INTEGER(ifindex)),
411+
JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", JSON_BUILD_INTEGER(ifindex)),
412412
JSON_BUILD_PAIR("name", JSON_BUILD_STRING(normalized))));
413413
if (r < 0)
414414
goto finish;

0 commit comments

Comments
 (0)
X Tutup