mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-08 20:58:20 +03:00
parent
c9472f9102
commit
0d609349ba
@ -180,14 +180,8 @@ static int reply_query_state(DnsQuery *q) {
|
||||
sd_bus_error_setf(&error, _BUS_ERROR_DNS "NXDOMAIN", "'%s' not found", dns_query_string(q));
|
||||
else {
|
||||
const char *rc, *n;
|
||||
char p[DECIMAL_STR_MAX(q->answer_rcode)];
|
||||
|
||||
rc = dns_rcode_to_string(q->answer_rcode);
|
||||
if (!rc) {
|
||||
xsprintf(p, "%i", q->answer_rcode);
|
||||
rc = p;
|
||||
}
|
||||
|
||||
rc = FORMAT_DNS_RCODE(q->answer_rcode);
|
||||
n = strjoina(_BUS_ERROR_DNS, rc);
|
||||
sd_bus_error_setf(&error, n, "Could not resolve '%s', server or network returned error %s", dns_query_string(q), rc);
|
||||
}
|
||||
|
@ -1099,7 +1099,7 @@ int dns_cache_lookup(
|
||||
|
||||
if (found_rcode >= 0) {
|
||||
log_debug("RCODE %s cache hit for %s",
|
||||
dns_rcode_to_string(found_rcode),
|
||||
FORMAT_DNS_RCODE(found_rcode),
|
||||
dns_resource_key_to_string(key, key_str, sizeof(key_str)));
|
||||
|
||||
if (ret_rcode)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "memory-util.h"
|
||||
#include "resolved-dns-packet.h"
|
||||
#include "set.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
#include "unaligned.h"
|
||||
@ -2649,6 +2650,14 @@ static const char* const dns_rcode_table[_DNS_RCODE_MAX_DEFINED] = {
|
||||
};
|
||||
DEFINE_STRING_TABLE_LOOKUP(dns_rcode, int);
|
||||
|
||||
const char *format_dns_rcode(int i, char buf[static DECIMAL_STR_MAX(int)]) {
|
||||
const char *p = dns_rcode_to_string(i);
|
||||
if (p)
|
||||
return p;
|
||||
|
||||
return snprintf_ok(buf, DECIMAL_STR_MAX(int), "%i", i);
|
||||
}
|
||||
|
||||
static const char* const dns_protocol_table[_DNS_PROTOCOL_MAX] = {
|
||||
[DNS_PROTOCOL_DNS] = "dns",
|
||||
[DNS_PROTOCOL_MDNS] = "mdns",
|
||||
|
@ -283,6 +283,8 @@ enum {
|
||||
|
||||
const char* dns_rcode_to_string(int i) _const_;
|
||||
int dns_rcode_from_string(const char *s) _pure_;
|
||||
const char *format_dns_rcode(int i, char buf[static DECIMAL_STR_MAX(int)]);
|
||||
#define FORMAT_DNS_RCODE(i) format_dns_rcode(i, (char [DECIMAL_STR_MAX(int)]) {})
|
||||
|
||||
const char* dns_protocol_to_string(DnsProtocol p) _const_;
|
||||
DnsProtocol dns_protocol_from_string(const char *s) _pure_;
|
||||
|
@ -864,7 +864,7 @@ static int dns_transaction_dnssec_ready(DnsTransaction *t) {
|
||||
|
||||
case DNS_TRANSACTION_RCODE_FAILURE:
|
||||
if (!IN_SET(dt->answer_rcode, DNS_RCODE_NXDOMAIN, DNS_RCODE_SERVFAIL)) {
|
||||
log_debug("Auxiliary DNSSEC RR query failed with rcode=%s.", dns_rcode_to_string(dt->answer_rcode));
|
||||
log_debug("Auxiliary DNSSEC RR query failed with rcode=%s.", FORMAT_DNS_RCODE(dt->answer_rcode));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -1049,7 +1049,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
||||
|
||||
log_debug("Processing incoming packet of size %zu on transaction %" PRIu16" (rcode=%s).",
|
||||
p->size,
|
||||
t->id, dns_rcode_to_string(DNS_PACKET_RCODE(p)));
|
||||
t->id, FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)));
|
||||
|
||||
switch (t->scope->protocol) {
|
||||
|
||||
@ -1137,7 +1137,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
||||
return;
|
||||
|
||||
/* Give up, accept the rcode */
|
||||
log_debug("Server returned error: %s", dns_rcode_to_string(DNS_PACKET_RCODE(p)));
|
||||
log_debug("Server returned error: %s", FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1151,7 +1151,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
||||
t->clamp_feature_level_servfail < 0) {
|
||||
t->clamp_feature_level_servfail = t->current_feature_level;
|
||||
log_debug("Server returned error %s, retrying transaction.",
|
||||
dns_rcode_to_string(DNS_PACKET_RCODE(p)));
|
||||
FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)));
|
||||
} else {
|
||||
/* Reduce this feature level by one and try again. */
|
||||
switch (t->current_feature_level) {
|
||||
@ -1167,7 +1167,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
||||
}
|
||||
|
||||
log_debug("Server returned error %s, retrying transaction with reduced feature level %s.",
|
||||
dns_rcode_to_string(DNS_PACKET_RCODE(p)),
|
||||
FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)),
|
||||
dns_server_feature_level_to_string(t->clamp_feature_level_servfail));
|
||||
}
|
||||
|
||||
@ -1308,7 +1308,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
||||
t->clamp_feature_level_nxdomain = DNS_SERVER_FEATURE_LEVEL_UDP;
|
||||
|
||||
log_debug("Server returned error %s in EDNS0 mode, retrying transaction with reduced feature level %s (DVE-2018-0001 mitigation)",
|
||||
dns_rcode_to_string(DNS_PACKET_RCODE(p)),
|
||||
FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)),
|
||||
dns_server_feature_level_to_string(t->clamp_feature_level_nxdomain));
|
||||
|
||||
dns_transaction_retry(t, false /* use the same server */);
|
||||
|
Loading…
x
Reference in New Issue
Block a user