mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-18 06:03:42 +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;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dns_answer_contains_nsec_or_nsec3(DnsAnswer *a) {
|
bool dns_answer_contains_nsec_or_nsec3(DnsAnswer *a) {
|
||||||
DnsResourceRecord *i;
|
DnsResourceRecord *i;
|
||||||
|
|
||||||
DNS_ANSWER_FOREACH(i, a)
|
DNS_ANSWER_FOREACH(i, a)
|
||||||
@ -314,7 +314,7 @@ int dns_answer_contains_zone_nsec3(DnsAnswer *answer, const char *zone) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dns_answer_contains(DnsAnswer *answer, DnsResourceRecord *rr) {
|
bool dns_answer_contains(DnsAnswer *answer, DnsResourceRecord *rr) {
|
||||||
DnsResourceRecord *i;
|
DnsResourceRecord *i;
|
||||||
|
|
||||||
DNS_ANSWER_FOREACH(i, answer)
|
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_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_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_match_key(DnsAnswer *a, const DnsResourceKey *key, DnsAnswerFlags *ret_flags);
|
||||||
int dns_answer_contains_nsec_or_nsec3(DnsAnswer *a);
|
bool dns_answer_contains_nsec_or_nsec3(DnsAnswer *a);
|
||||||
int dns_answer_contains_zone_nsec3(DnsAnswer *answer, const char *zone);
|
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_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);
|
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) \
|
#define _DNS_ANSWER_FOREACH(q, kk, a) \
|
||||||
for (size_t UNIQ_T(i, q) = ({ \
|
for (size_t UNIQ_T(i, q) = ({ \
|
||||||
(kk) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].rr : NULL; \
|
(kk) = dns_answer_isempty(a) ? NULL : (a)->items[0].rr; \
|
||||||
0; \
|
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))
|
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(kk, a) _DNS_ANSWER_FOREACH(UNIQ, kk, a)
|
||||||
|
|
||||||
#define _DNS_ANSWER_FOREACH_IFINDEX(q, kk, ifi, a) \
|
#define _DNS_ANSWER_FOREACH_IFINDEX(q, kk, ifi, a) \
|
||||||
for (size_t UNIQ_T(i, q) = ({ \
|
for (size_t UNIQ_T(i, q) = ({ \
|
||||||
(kk) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].rr : NULL; \
|
(kk) = dns_answer_isempty(a) ? NULL : (a)->items[0].rr; \
|
||||||
(ifi) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].ifindex : 0; \
|
(ifi) = dns_answer_isempty(a) ? 0 : (a)->items[0].ifindex; \
|
||||||
0; \
|
0; \
|
||||||
}); \
|
}); \
|
||||||
(a) && (UNIQ_T(i, q) < (a)->n_rrs); \
|
UNIQ_T(i, q) < dns_answer_size(a); \
|
||||||
UNIQ_T(i, q)++, \
|
UNIQ_T(i, q)++, \
|
||||||
(kk) = ((UNIQ_T(i, q) < (a)->n_rrs) ? (a)->items[UNIQ_T(i, q)].rr : NULL), \
|
(kk) = UNIQ_T(i, q) < dns_answer_size(a) ? (a)->items[UNIQ_T(i, q)].rr : NULL, \
|
||||||
(ifi) = ((UNIQ_T(i, q) < (a)->n_rrs) ? (a)->items[UNIQ_T(i, q)].ifindex : 0))
|
(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_IFINDEX(kk, ifindex, a) _DNS_ANSWER_FOREACH_IFINDEX(UNIQ, kk, ifindex, a)
|
||||||
|
|
||||||
#define _DNS_ANSWER_FOREACH_FLAGS(q, kk, fl, a) \
|
#define _DNS_ANSWER_FOREACH_FLAGS(q, kk, fl, a) \
|
||||||
for (size_t UNIQ_T(i, q) = ({ \
|
for (size_t UNIQ_T(i, q) = ({ \
|
||||||
(kk) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].rr : NULL; \
|
(kk) = dns_answer_isempty(a) ? NULL : (a)->items[0].rr; \
|
||||||
(fl) = ((a) && (a)->n_rrs > 0) ? (a)->items[0].flags : 0; \
|
(fl) = dns_answer_isempty(a) ? 0 : (a)->items[0].flags; \
|
||||||
0; \
|
0; \
|
||||||
}); \
|
}); \
|
||||||
(a) && (UNIQ_T(i, q) < (a)->n_rrs); \
|
UNIQ_T(i, q) < dns_answer_size(a); \
|
||||||
UNIQ_T(i, q)++, \
|
UNIQ_T(i, q)++, \
|
||||||
(kk) = ((UNIQ_T(i, q) < (a)->n_rrs) ? (a)->items[UNIQ_T(i, q)].rr : NULL), \
|
(kk) = UNIQ_T(i, q) < dns_answer_size(a) ? (a)->items[UNIQ_T(i, q)].rr : NULL, \
|
||||||
(fl) = ((UNIQ_T(i, q) < (a)->n_rrs) ? (a)->items[UNIQ_T(i, q)].flags : 0))
|
(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)
|
#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) < dns_answer_size(a); \
|
||||||
UNIQ_T(i, q)++, \
|
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)
|
#define DNS_ANSWER_FOREACH_ITEM(item, a) _DNS_ANSWER_FOREACH_ITEM(UNIQ, item, a)
|
||||||
|
@ -36,14 +36,13 @@ enum DnsCacheItemType {
|
|||||||
|
|
||||||
struct DnsCacheItem {
|
struct DnsCacheItem {
|
||||||
DnsCacheItemType type;
|
DnsCacheItemType type;
|
||||||
|
int rcode;
|
||||||
DnsResourceKey *key; /* The key for this item, i.e. the lookup key */
|
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 */
|
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 */
|
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 */
|
DnsPacket *full_packet; /* The full packet this information was acquired with */
|
||||||
int rcode;
|
|
||||||
|
|
||||||
usec_t until;
|
usec_t until;
|
||||||
bool shared_owner:1;
|
|
||||||
uint64_t query_flags; /* SD_RESOLVED_AUTHENTICATED and/or SD_RESOLVED_CONFIDENTIAL */
|
uint64_t query_flags; /* SD_RESOLVED_AUTHENTICATED and/or SD_RESOLVED_CONFIDENTIAL */
|
||||||
DnssecResult dnssec_result;
|
DnssecResult dnssec_result;
|
||||||
|
|
||||||
@ -53,6 +52,8 @@ struct DnsCacheItem {
|
|||||||
|
|
||||||
unsigned prioq_idx;
|
unsigned prioq_idx;
|
||||||
LIST_FIELDS(DnsCacheItem, by_key);
|
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"
|
/* Returns true if this is a cache item created as result of an explicit lookup, or created as "side-effect"
|
||||||
|
@ -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
|
* question. If so, let's see if there are any NSEC/NSEC3 RRs
|
||||||
* included. If not, the answer is unsigned. */
|
* included. If not, the answer is unsigned. */
|
||||||
|
|
||||||
r = dns_answer_contains_nsec_or_nsec3(t->answer);
|
return !dns_answer_contains_nsec_or_nsec3(t->answer);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
if (r > 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dns_transaction_is_primary_response(DnsTransaction *t, DnsResourceRecord *rr) {
|
static int dns_transaction_is_primary_response(DnsTransaction *t, DnsResourceRecord *rr) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user