1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-28 02:50:16 +03:00

resolved: make sure "resolvectl monitor" can properly deal with stub queries

If we receive a query via the two stubs we store the original packet
instead of just the question object. Hence when we send monitor info to
subscribed clients we need to extract its question and also include it
in the returned data.

Fixes: #29580
This commit is contained in:
Lennart Poettering 2023-10-31 23:00:41 +01:00
parent 43fe529e0f
commit ae55c9c0ae
3 changed files with 15 additions and 3 deletions

View File

@ -586,7 +586,7 @@ void dns_query_complete(DnsQuery *q, DnsTransactionState state) {
q->state = state;
(void) manager_monitor_send(q->manager, q->state, q->answer_rcode, q->answer_errno, q->question_idna, q->question_utf8, q->collected_questions, q->answer);
(void) manager_monitor_send(q->manager, q->state, q->answer_rcode, q->answer_errno, q->question_idna, q->question_utf8, q->question_bypass, q->collected_questions, q->answer);
dns_query_stop(q);
if (q->complete)

View File

@ -1105,6 +1105,7 @@ int manager_monitor_send(
int error,
DnsQuestion *question_idna,
DnsQuestion *question_utf8,
DnsPacket *question_bypass,
DnsQuestion *collected_questions,
DnsAnswer *answer) {
@ -1119,11 +1120,22 @@ int manager_monitor_send(
if (set_isempty(m->varlink_subscription))
return 0;
/* Merge both questions format into one */
/* Merge all questions into one */
r = dns_question_merge(question_idna, question_utf8, &merged);
if (r < 0)
return log_error_errno(r, "Failed to merge UTF8/IDNA questions: %m");
if (question_bypass) {
_cleanup_(dns_question_unrefp) DnsQuestion *merged2 = NULL;
r = dns_question_merge(merged, question_bypass->question, &merged2);
if (r < 0)
return log_error_errno(r, "Failed to merge UTF8/IDNA questions and DNS packet question: %m");
dns_question_unref(merged);
merged = TAKE_PTR(merged2);
}
/* Convert the current primary question to JSON */
r = dns_question_to_json(merged, &jquestion);
if (r < 0)

View File

@ -176,7 +176,7 @@ int manager_start(Manager *m);
uint32_t manager_find_mtu(Manager *m);
int manager_monitor_send(Manager *m, int state, int rcode, int error, DnsQuestion *question_idna, DnsQuestion *question_utf8, DnsQuestion *collected_questions, DnsAnswer *answer);
int manager_monitor_send(Manager *m, int state, int rcode, int error, DnsQuestion *question_idna, DnsQuestion *question_utf8, DnsPacket *question_bypass, DnsQuestion *collected_questions, DnsAnswer *answer);
int manager_write(Manager *m, int fd, DnsPacket *p);
int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *destination, uint16_t port, const union in_addr_union *source, DnsPacket *p);