mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
Merge pull request #19064 from yuwata/resolve-fix-cache-19049
resolve: several trivial cleanups
This commit is contained in:
commit
e872679629
@ -277,7 +277,7 @@ int dns_answer_match_key(DnsAnswer *a, const DnsResourceKey *key, DnsAnswerFlags
|
||||
return found;
|
||||
}
|
||||
|
||||
int dns_answer_contains_nsec_or_nsec3(DnsAnswer *a) {
|
||||
bool dns_answer_contains_nsec_or_nsec3(DnsAnswer *a) {
|
||||
DnsResourceRecord *i;
|
||||
|
||||
DNS_ANSWER_FOREACH(i, a)
|
||||
@ -314,7 +314,7 @@ int dns_answer_contains_zone_nsec3(DnsAnswer *answer, const char *zone) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int dns_answer_contains(DnsAnswer *answer, DnsResourceRecord *rr) {
|
||||
bool dns_answer_contains(DnsAnswer *answer, DnsResourceRecord *rr) {
|
||||
DnsResourceRecord *i;
|
||||
|
||||
DNS_ANSWER_FOREACH(i, answer)
|
||||
|
@ -50,10 +50,10 @@ int dns_answer_add(DnsAnswer *a, DnsResourceRecord *rr, int ifindex, DnsAnswerFl
|
||||
int dns_answer_add_extend(DnsAnswer **a, DnsResourceRecord *rr, int ifindex, DnsAnswerFlags flags, DnsResourceRecord *rrsig);
|
||||
int dns_answer_add_soa(DnsAnswer *a, const char *name, uint32_t ttl, int ifindex);
|
||||
|
||||
int dns_answer_match_key(DnsAnswer *a, const DnsResourceKey *key, DnsAnswerFlags *combined_flags);
|
||||
int dns_answer_contains_nsec_or_nsec3(DnsAnswer *a);
|
||||
int dns_answer_match_key(DnsAnswer *a, const DnsResourceKey *key, DnsAnswerFlags *ret_flags);
|
||||
bool dns_answer_contains_nsec_or_nsec3(DnsAnswer *a);
|
||||
int dns_answer_contains_zone_nsec3(DnsAnswer *answer, const char *zone);
|
||||
int dns_answer_contains(DnsAnswer *answer, DnsResourceRecord *rr);
|
||||
bool dns_answer_contains(DnsAnswer *answer, DnsResourceRecord *rr);
|
||||
|
||||
int dns_answer_find_soa(DnsAnswer *a, const DnsResourceKey *key, DnsResourceRecord **ret, DnsAnswerFlags *ret_flags);
|
||||
int dns_answer_find_cname_or_dname(DnsAnswer *a, const DnsResourceKey *key, DnsResourceRecord **ret, DnsAnswerFlags *ret_flags);
|
||||
@ -93,37 +93,38 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(DnsAnswer*, dns_answer_unref);
|
||||
|
||||
#define _DNS_ANSWER_FOREACH(q, kk, a) \
|
||||
for (size_t UNIQ_T(i, q) = ({ \
|
||||
(kk) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].rr : NULL; \
|
||||
0; \
|
||||
}); \
|
||||
(a) && (UNIQ_T(i, q) < (a)->n_rrs); \
|
||||
UNIQ_T(i, q)++, (kk) = (UNIQ_T(i, q) < (a)->n_rrs ? (a)->items[UNIQ_T(i, q)].rr : NULL))
|
||||
(kk) = dns_answer_isempty(a) ? NULL : (a)->items[0].rr; \
|
||||
0; \
|
||||
}); \
|
||||
UNIQ_T(i, q) < dns_answer_size(a); \
|
||||
UNIQ_T(i, q)++, \
|
||||
(kk) = UNIQ_T(i, q) < dns_answer_size(a) ? (a)->items[UNIQ_T(i, q)].rr : NULL)
|
||||
|
||||
#define DNS_ANSWER_FOREACH(kk, a) _DNS_ANSWER_FOREACH(UNIQ, kk, a)
|
||||
|
||||
#define _DNS_ANSWER_FOREACH_IFINDEX(q, kk, ifi, a) \
|
||||
for (size_t UNIQ_T(i, q) = ({ \
|
||||
(kk) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].rr : NULL; \
|
||||
(ifi) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].ifindex : 0; \
|
||||
(kk) = dns_answer_isempty(a) ? NULL : (a)->items[0].rr; \
|
||||
(ifi) = dns_answer_isempty(a) ? 0 : (a)->items[0].ifindex; \
|
||||
0; \
|
||||
}); \
|
||||
(a) && (UNIQ_T(i, q) < (a)->n_rrs); \
|
||||
UNIQ_T(i, q) < dns_answer_size(a); \
|
||||
UNIQ_T(i, q)++, \
|
||||
(kk) = ((UNIQ_T(i, q) < (a)->n_rrs) ? (a)->items[UNIQ_T(i, q)].rr : NULL), \
|
||||
(ifi) = ((UNIQ_T(i, q) < (a)->n_rrs) ? (a)->items[UNIQ_T(i, q)].ifindex : 0))
|
||||
(kk) = UNIQ_T(i, q) < dns_answer_size(a) ? (a)->items[UNIQ_T(i, q)].rr : NULL, \
|
||||
(ifi) = UNIQ_T(i, q) < dns_answer_size(a) ? (a)->items[UNIQ_T(i, q)].ifindex : 0)
|
||||
|
||||
#define DNS_ANSWER_FOREACH_IFINDEX(kk, ifindex, a) _DNS_ANSWER_FOREACH_IFINDEX(UNIQ, kk, ifindex, a)
|
||||
|
||||
#define _DNS_ANSWER_FOREACH_FLAGS(q, kk, fl, a) \
|
||||
for (size_t UNIQ_T(i, q) = ({ \
|
||||
(kk) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].rr : NULL; \
|
||||
(fl) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].flags : 0; \
|
||||
(kk) = dns_answer_isempty(a) ? NULL : (a)->items[0].rr; \
|
||||
(fl) = dns_answer_isempty(a) ? 0 : (a)->items[0].flags; \
|
||||
0; \
|
||||
}); \
|
||||
(a) && (UNIQ_T(i, q) < (a)->n_rrs); \
|
||||
UNIQ_T(i, q) < dns_answer_size(a); \
|
||||
UNIQ_T(i, q)++, \
|
||||
(kk) = ((UNIQ_T(i, q) < (a)->n_rrs) ? (a)->items[UNIQ_T(i, q)].rr : NULL), \
|
||||
(fl) = ((UNIQ_T(i, q) < (a)->n_rrs) ? (a)->items[UNIQ_T(i, q)].flags : 0))
|
||||
(kk) = UNIQ_T(i, q) < dns_answer_size(a) ? (a)->items[UNIQ_T(i, q)].rr : NULL, \
|
||||
(fl) = UNIQ_T(i, q) < dns_answer_size(a) ? (a)->items[UNIQ_T(i, q)].flags : 0)
|
||||
|
||||
#define DNS_ANSWER_FOREACH_FLAGS(kk, flags, a) _DNS_ANSWER_FOREACH_FLAGS(UNIQ, kk, flags, a)
|
||||
|
||||
@ -134,6 +135,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(DnsAnswer*, dns_answer_unref);
|
||||
}); \
|
||||
UNIQ_T(i, q) < dns_answer_size(a); \
|
||||
UNIQ_T(i, q)++, \
|
||||
(item) = ((UNIQ_T(i, q) < dns_answer_size(a)) ? (a)->items + UNIQ_T(i, q) : NULL))
|
||||
(item) = (UNIQ_T(i, q) < dns_answer_size(a)) ? (a)->items + UNIQ_T(i, q) : NULL)
|
||||
|
||||
#define DNS_ANSWER_FOREACH_ITEM(item, a) _DNS_ANSWER_FOREACH_ITEM(UNIQ, item, a)
|
||||
|
@ -36,14 +36,13 @@ enum DnsCacheItemType {
|
||||
|
||||
struct DnsCacheItem {
|
||||
DnsCacheItemType type;
|
||||
int rcode;
|
||||
DnsResourceKey *key; /* The key for this item, i.e. the lookup key */
|
||||
DnsResourceRecord *rr; /* The RR for this item, i.e. the lookup value for positive queries */
|
||||
DnsAnswer *answer; /* The full validated answer, if this is an RRset acquired via a "primary" lookup */
|
||||
DnsPacket *full_packet; /* The full packet this information was acquired with */
|
||||
int rcode;
|
||||
|
||||
usec_t until;
|
||||
bool shared_owner:1;
|
||||
uint64_t query_flags; /* SD_RESOLVED_AUTHENTICATED and/or SD_RESOLVED_CONFIDENTIAL */
|
||||
DnssecResult dnssec_result;
|
||||
|
||||
@ -53,6 +52,8 @@ struct DnsCacheItem {
|
||||
|
||||
unsigned prioq_idx;
|
||||
LIST_FIELDS(DnsCacheItem, by_key);
|
||||
|
||||
bool shared_owner;
|
||||
};
|
||||
|
||||
/* Returns true if this is a cache item created as result of an explicit lookup, or created as "side-effect"
|
||||
|
@ -496,7 +496,7 @@ int dns_query_new(
|
||||
log_debug("Looking up bypass packet for %s.",
|
||||
dns_resource_key_to_string(key, key_str, sizeof key_str));
|
||||
} else {
|
||||
/* First dump UTF8 question */
|
||||
/* First dump UTF8 question */
|
||||
DNS_QUESTION_FOREACH(key, question_utf8)
|
||||
log_debug("Looking up RR for %s.",
|
||||
dns_resource_key_to_string(key, key_str, sizeof key_str));
|
||||
|
@ -2222,13 +2222,7 @@ static int dns_transaction_has_unsigned_negative_answer(DnsTransaction *t) {
|
||||
* question. If so, let's see if there are any NSEC/NSEC3 RRs
|
||||
* included. If not, the answer is unsigned. */
|
||||
|
||||
r = dns_answer_contains_nsec_or_nsec3(t->answer);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return !dns_answer_contains_nsec_or_nsec3(t->answer);
|
||||
}
|
||||
|
||||
static int dns_transaction_is_primary_response(DnsTransaction *t, DnsResourceRecord *rr) {
|
||||
|
Loading…
Reference in New Issue
Block a user