1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

Merge pull request #29309 from poettering/resolved-varlink-tweaks

resolved: minor varlink API tweaks
This commit is contained in:
Lennart Poettering 2023-09-25 23:27:33 +02:00 committed by GitHub
commit 902dc432e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -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",

View File

@ -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)))),

View File

@ -528,7 +528,7 @@ static int vl_method_resolve_address(Varlink *link, JsonVariant *parameters, Var
return 1;
}
static int vl_method_subscribe_dns_resolves(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_subscribe_query_results(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
Manager *m;
int r;
@ -701,7 +701,7 @@ static int varlink_monitor_server_init(Manager *m) {
r = varlink_server_bind_method_many(
server,
"io.systemd.Resolve.Monitor.SubscribeQueryResults", vl_method_subscribe_dns_resolves,
"io.systemd.Resolve.Monitor.SubscribeQueryResults", vl_method_subscribe_query_results,
"io.systemd.Resolve.Monitor.DumpCache", vl_method_dump_cache,
"io.systemd.Resolve.Monitor.DumpServerState", vl_method_dump_server_state,
"io.systemd.Resolve.Monitor.DumpStatistics", vl_method_dump_statistics,