diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-09-22 22:37:37 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-09-25 18:45:52 +0200 |
commit | 0319a28e42d91fd837f161a4c19113bbca70b4bd (patch) | |
tree | eee6955daf8bc7a44fa78b54d9dc4862cc820afb | |
parent | Merge pull request #29301 from poettering/pcr-extend-rename (diff) | |
download | systemd-0319a28e42d91fd837f161a4c19113bbca70b4bd.tar.xz systemd-0319a28e42d91fd837f161a4c19113bbca70b4bd.zip |
resolved: also expose interface index in server JSON data
-rw-r--r-- | src/resolve/resolvectl.c | 17 | ||||
-rw-r--r-- | src/resolve/resolved-dns-server.c | 1 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index 5d540058ef..071b2d85bb 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -2997,6 +2997,7 @@ static int dump_server_state(JsonVariant *server) { const char *server_name; const char *type; const char *ifname; + int ifindex; const char *verified_feature_level; const char *possible_feature_level; const char *dnssec_mode; @@ -3009,7 +3010,9 @@ static int dump_server_state(JsonVariant *server) { bool packet_rrsig_missing; bool packet_invalid; bool packet_do_off; - } server_state = {}; + } server_state = { + .ifindex = -1, + }; int r; @@ -3017,6 +3020,7 @@ static int dump_server_state(JsonVariant *server) { { "Server", JSON_VARIANT_STRING, json_dispatch_const_string, offsetof(struct server_state, server_name), JSON_MANDATORY }, { "Type", JSON_VARIANT_STRING, json_dispatch_const_string, offsetof(struct server_state, type), JSON_MANDATORY }, { "Interface", JSON_VARIANT_STRING, json_dispatch_const_string, offsetof(struct server_state, ifname), 0 }, + { "InterfaceIndex", JSON_VARIANT_INTEGER, json_dispatch_int, offsetof(struct server_state, ifindex), 0 }, { "VerifiedFeatureLevel", JSON_VARIANT_STRING, json_dispatch_const_string, offsetof(struct server_state, verified_feature_level), 0 }, { "PossibleFeatureLevel", JSON_VARIANT_STRING, json_dispatch_const_string, offsetof(struct server_state, possible_feature_level), 0 }, { "DNSSECMode", JSON_VARIANT_STRING, json_dispatch_const_string, offsetof(struct server_state, dnssec_mode), JSON_MANDATORY }, @@ -3032,7 +3036,7 @@ static int dump_server_state(JsonVariant *server) { {}, }; - r = json_dispatch(server, dispatch_table, NULL, JSON_LOG, &server_state); + r = json_dispatch(server, dispatch_table, NULL, JSON_LOG|JSON_PERMISSIVE, &server_state); if (r < 0) return r; @@ -3059,12 +3063,19 @@ static int dump_server_state(JsonVariant *server) { if (server_state.ifname) { r = table_add_many(table, TABLE_FIELD, "Interface", - TABLE_SET_ALIGN_PERCENT, 100, TABLE_STRING, server_state.ifname); if (r < 0) return table_log_add_error(r); } + if (server_state.ifindex >= 0) { + r = table_add_many(table, + TABLE_FIELD, "Interface Index", + TABLE_INT, server_state.ifindex); + if (r < 0) + return table_log_add_error(r); + } + if (server_state.verified_feature_level) { r = table_add_many(table, TABLE_FIELD, "Verified feature level", diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c index f23e3f5db9..b7db83965b 100644 --- a/src/resolve/resolved-dns-server.c +++ b/src/resolve/resolved-dns-server.c @@ -1106,6 +1106,7 @@ int dns_server_dump_state_to_json(DnsServer *server, JsonVariant **ret) { JSON_BUILD_PAIR_STRING("Server", strna(dns_server_string_full(server))), JSON_BUILD_PAIR_STRING("Type", strna(dns_server_type_to_string(server->type))), JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "Interface", JSON_BUILD_STRING(server->link ? server->link->ifname : NULL)), + JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "InterfaceIndex", JSON_BUILD_UNSIGNED(server->link ? server->link->ifindex : 0)), JSON_BUILD_PAIR_STRING("VerifiedFeatureLevel", strna(dns_server_feature_level_to_string(server->verified_feature_level))), JSON_BUILD_PAIR_STRING("PossibleFeatureLevel", strna(dns_server_feature_level_to_string(server->possible_feature_level))), JSON_BUILD_PAIR_STRING("DNSSECMode", strna(dnssec_mode_to_string(dns_server_get_dnssec_mode(server)))), |