Skip to content

Commit

Permalink
Merge pull request #585 from ssahani/dhcp
Browse files Browse the repository at this point in the history
JSON: Add dev name in output when dev name missing
  • Loading branch information
ssahani authored Dec 17, 2023
2 parents 12e3674 + 55fb7a4 commit 941e8bf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/json/network-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ int json_fill_dns_servers(const json_object *jn, const char *link, json_object *
if (!json_object_object_get_ex(interface, "Name", &ifname))
continue;

if (link && str_eq(link, json_object_get_string(ifname)))
if (link && !str_eq(link, json_object_get_string(ifname)))
continue;

if (!json_object_object_get_ex(interface, "DNS", &dns))
Expand All @@ -986,6 +986,16 @@ int json_fill_dns_servers(const json_object *jn, const char *link, json_object *
if (!dns_address)
return log_oom();

if (!link) {
_cleanup_(json_object_putp) json_object *s = NULL;

s = json_object_new_string(json_object_get_string(ifname));
if (!s)
return log_oom();
json_object_object_add(jaddr, "Name", s);
steal_ptr(s);
}

json_object_object_add(jaddr, "Address", dns_address);
steal_ptr(dns_address);

Expand Down

0 comments on commit 941e8bf

Please sign in to comment.