resolved: Remove circular header dependencies

This commit is contained in:
Daan De Meyer
2025-04-23 10:33:37 +02:00
parent 834dc38310
commit 68527d3051
64 changed files with 391 additions and 151 deletions
+3
View File
@@ -1,10 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-json.h"
#include "fd-util.h"
#include "fuzz.h"
#include "memory-util.h"
#include "memstream-util.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL, *copy = NULL;
+1
View File
@@ -38,6 +38,7 @@
#include "resolvectl.h"
#include "resolved-def.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
#include "resolved-util.h"
#include "socket-netlink.h"
#include "sort-util.h"
+16
View File
@@ -7,17 +7,33 @@
#include "bus-log-control-api.h"
#include "bus-message-util.h"
#include "bus-polkit.h"
#include "bus-util.h"
#include "dns-domain.h"
#include "format-util.h"
#include "memory-util.h"
#include "path-util.h"
#include "resolve-util.h"
#include "resolved-bus.h"
#include "resolved-def.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-stream.h"
#include "resolved-dns-stub.h"
#include "resolved-dns-synthesize.h"
#include "resolved-dns-transaction.h"
#include "resolved-dns-trust-anchor.h"
#include "resolved-dnssd-bus.h"
#include "resolved-dnssd.h"
#include "resolved-link.h"
#include "resolved-link-bus.h"
#include "resolved-manager.h"
#include "resolved-resolv-conf.h"
#include "socket-netlink.h"
#include "stdio-util.h"
+4 -1
View File
@@ -2,7 +2,10 @@
#pragma once
#include "bus-object.h"
#include "resolved-manager.h"
#include "macro.h"
typedef struct DnsServer DnsServer;
typedef struct Manager Manager;
extern const BusObjectImplementation manager_object;
+2
View File
@@ -5,12 +5,14 @@
#include "constants.h"
#include "creds-util.h"
#include "dns-domain.h"
#include "dns-type.h"
#include "extract-word.h"
#include "hexdecoct.h"
#include "parse-util.h"
#include "proc-cmdline.h"
#include "resolved-conf.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-stub.h"
#include "resolved-dnssd.h"
#include "resolved-manager.h"
+2 -2
View File
@@ -3,6 +3,8 @@
#include "conf-parser.h"
typedef struct Manager Manager;
typedef enum ResolveConfigSource {
RESOLVE_CONFIG_SOURCE_FILE,
RESOLVE_CONFIG_SOURCE_NETWORKD,
@@ -11,8 +13,6 @@ typedef enum ResolveConfigSource {
_RESOLVE_CONFIG_SOURCE_INVALID = -EINVAL,
} ResolveConfigSource;
#include "resolved-dns-server.h"
int manager_parse_config_file(Manager *m);
const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
+1
View File
@@ -8,6 +8,7 @@
#include "random-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-rr.h"
#include "string-util.h"
static DnsAnswerItem *dns_answer_item_free(DnsAnswerItem *item) {
+7 -8
View File
@@ -1,12 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsAnswerItem DnsAnswerItem;
#include "macro.h"
#include "ordered-set.h"
#include "resolved-dns-rr.h"
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsResourceRecord DnsResourceRecord;
/* A simple array of resource records. We keep track of the originating ifindex for each RR where that makes
* sense, so that we can qualify A and AAAA RRs referring to a local link with the right ifindex.
@@ -29,18 +28,18 @@ typedef enum DnsAnswerFlags {
DNS_ANSWER_SECTION_ADDITIONAL,
} DnsAnswerFlags;
struct DnsAnswerItem {
typedef struct DnsAnswerItem {
unsigned n_ref;
DnsResourceRecord *rr;
DnsResourceRecord *rrsig; /* Optionally, also store RRSIG RR that successfully validates this item */
int ifindex;
DnsAnswerFlags flags;
};
} DnsAnswerItem;
struct DnsAnswer {
typedef struct DnsAnswer {
unsigned n_ref;
OrderedSet *items;
};
} DnsAnswer;
DnsAnswer *dns_answer_new(size_t n);
DnsAnswer *dns_answer_ref(DnsAnswer *a);
+2
View File
@@ -8,7 +8,9 @@
#include "format-ifname.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-cache.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
#include "string-util.h"
/* Never cache more than 4K entries. RFC 1536, Section 5 suggests to
+11 -6
View File
@@ -1,13 +1,23 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-json.h"
#include "hashmap.h"
#include "in-addr-util.h"
#include "list.h"
#include "prioq.h"
#include "resolve-util.h"
#include "resolved-dns-dnssec.h"
#include "time-util.h"
typedef enum DnsProtocol DnsProtocol;
typedef enum DnssecResult DnssecResult;
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsPacket DnsPacket;
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsResourceRecord DnsResourceRecord;
typedef struct DnsCache {
Hashmap *by_key;
Prioq *by_expiry;
@@ -15,11 +25,6 @@ typedef struct DnsCache {
unsigned n_miss;
} DnsCache;
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
void dns_cache_flush(DnsCache *c);
void dns_cache_prune(DnsCache *c);
+3
View File
@@ -2,6 +2,7 @@
#include "alloc-util.h"
#include "dns-domain.h"
#include "dns-type.h"
#include "fd-util.h"
#include "fileio.h"
#include "hexdecoct.h"
@@ -9,8 +10,10 @@
#include "memory-util.h"
#include "memstream-util.h"
#include "openssl-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
#include "sort-util.h"
#include "string-table.h"
+12 -9
View File
@@ -1,14 +1,17 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef enum DnssecResult DnssecResult;
typedef enum DnssecVerdict DnssecVerdict;
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include "dns-domain.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-rr.h"
#include "time-util.h"
enum DnssecResult {
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsResourceRecord DnsResourceRecord;
typedef enum DnssecResult {
/* These six are returned by dnssec_verify_rrset() */
DNSSEC_VALIDATED,
DNSSEC_VALIDATED_WILDCARD, /* Validated via a wildcard RRSIG, further NSEC/NSEC3 checks necessary */
@@ -30,9 +33,9 @@ enum DnssecResult {
_DNSSEC_RESULT_MAX,
_DNSSEC_RESULT_INVALID = -EINVAL,
};
} DnssecResult;
enum DnssecVerdict {
typedef enum DnssecVerdict {
DNSSEC_SECURE,
DNSSEC_INSECURE,
DNSSEC_BOGUS,
@@ -40,7 +43,7 @@ enum DnssecVerdict {
_DNSSEC_VERDICT_MAX,
_DNSSEC_VERDICT_INVALID = -EINVAL,
};
} DnssecVerdict;
#define DNSSEC_CANONICAL_HOSTNAME_MAX (DNS_HOSTNAME_MAX + 2)
+3
View File
@@ -5,7 +5,10 @@
#include "escape.h"
#include "log.h"
#include "memory-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "set.h"
#include "stdio-util.h"
#include "string-table.h"
+9 -9
View File
@@ -8,15 +8,15 @@
#include "hashmap.h"
#include "in-addr-util.h"
#include "macro.h"
#include "sparse-endian.h"
typedef struct DnsPacketHeader DnsPacketHeader;
typedef struct DnsPacket DnsPacket;
#include "resolved-def.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "sparse-endian.h"
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsPacket DnsPacket;
typedef struct DnsQuestion DnsQuestion;
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsResourceRecord DnsResourceRecord;
typedef enum DnsProtocol {
DNS_PROTOCOL_DNS,
@@ -26,14 +26,14 @@ typedef enum DnsProtocol {
_DNS_PROTOCOL_INVALID = -EINVAL,
} DnsProtocol;
struct DnsPacketHeader {
typedef struct DnsPacketHeader {
uint16_t id;
be16_t flags;
be16_t qdcount;
be16_t ancount;
be16_t nscount;
be16_t arcount;
} _packed_;
} _packed_ DnsPacketHeader;
#define DNS_PACKET_HEADER_SIZE sizeof(DnsPacketHeader)
#define UDP4_PACKET_HEADER_SIZE (sizeof(struct iphdr) + sizeof(struct udphdr))
+19
View File
@@ -7,9 +7,18 @@
#include "glyph-util.h"
#include "hostname-util.h"
#include "local-addresses.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-stub.h"
#include "resolved-dns-synthesize.h"
#include "resolved-dns-transaction.h"
#include "resolved-etc-hosts.h"
#include "resolved-manager.h"
#include "resolved-timeouts.h"
#include "string-util.h"
@@ -1493,3 +1502,13 @@ int validate_and_mangle_query_flags(
return 0;
}
uint64_t dns_query_reply_flags_make(DnsQuery *q) {
assert(q);
return SD_RESOLVED_FLAGS_MAKE(q->answer_protocol,
q->answer_family,
dns_query_fully_authenticated(q),
dns_query_fully_confidential(q)) |
(q->answer_query_flags & (SD_RESOLVED_FROM_MASK|SD_RESOLVED_SYNTHETIC));
}
+14 -14
View File
@@ -4,16 +4,24 @@
#include "sd-bus.h"
#include "sd-varlink.h"
#include "in-addr-util.h"
#include "list.h"
#include "resolved-def.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-transaction.h"
#include "set.h"
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsPacket DnsPacket;
typedef struct DnsQueryCandidate DnsQueryCandidate;
typedef struct DnsQuery DnsQuery;
typedef struct DnsQuestion DnsQuestion;
typedef struct DnsScope DnsScope;
typedef struct DnsSearchDomain DnsSearchDomain;
typedef struct DnsStream DnsStream;
typedef struct DnsStubListenerExtra DnsStubListenerExtra;
#include "resolved-dns-answer.h"
#include "resolved-dns-question.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-transaction.h"
typedef struct Manager Manager;
struct DnsQueryCandidate {
unsigned n_ref;
@@ -160,12 +168,4 @@ bool dns_query_fully_authoritative(DnsQuery *q);
int validate_and_mangle_query_flags(Manager *manager, uint64_t *flags, const char *name, uint64_t ok);
static inline uint64_t dns_query_reply_flags_make(DnsQuery *q) {
assert(q);
return SD_RESOLVED_FLAGS_MAKE(q->answer_protocol,
q->answer_family,
dns_query_fully_authenticated(q),
dns_query_fully_confidential(q)) |
(q->answer_query_flags & (SD_RESOLVED_FROM_MASK|SD_RESOLVED_SYNTHETIC));
}
uint64_t dns_query_reply_flags_make(DnsQuery *q);
+1
View File
@@ -5,6 +5,7 @@
#include "dns-type.h"
#include "log.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "socket-util.h"
DnsQuestion *dns_question_new(size_t n) {
+10 -8
View File
@@ -1,11 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct DnsQuestion DnsQuestion;
typedef struct DnsQuestionItem DnsQuestionItem;
#include <stdio.h>
#include "macro.h"
#include "resolved-dns-rr.h"
#include "in-addr-util.h"
#include "memory-util.h"
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsResourceRecord DnsResourceRecord;
/* A simple array of resource keys */
@@ -13,16 +15,16 @@ typedef enum DnsQuestionFlags {
DNS_QUESTION_WANTS_UNICAST_REPLY = 1 << 0, /* For mDNS: sender is willing to accept unicast replies */
} DnsQuestionFlags;
struct DnsQuestionItem {
typedef struct DnsQuestionItem {
DnsResourceKey *key;
DnsQuestionFlags flags;
};
} DnsQuestionItem;
struct DnsQuestion {
typedef struct DnsQuestion {
unsigned n_ref;
size_t n_keys, n_allocated;
DnsQuestionItem items[];
};
} DnsQuestion;
DnsQuestion *dns_question_new(size_t n);
DnsQuestion *dns_question_ref(DnsQuestion *q);
+11
View File
@@ -5,16 +5,27 @@
#include "af-list.h"
#include "alloc-util.h"
#include "dns-domain.h"
#include "dns-type.h"
#include "errno-util.h"
#include "fd-util.h"
#include "hostname-util.h"
#include "missing_network.h"
#include "random-util.h"
#include "resolved-dnssd.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-synthesize.h"
#include "resolved-dns-transaction.h"
#include "resolved-dns-zone.h"
#include "resolved-link.h"
#include "resolved-llmnr.h"
#include "resolved-manager.h"
#include "resolved-mdns.h"
#include "resolved-timeouts.h"
#include "socket-util.h"
+14 -9
View File
@@ -1,20 +1,25 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-event.h"
#include "dns-def.h"
#include "list.h"
#include "ratelimit.h"
typedef struct DnsQueryCandidate DnsQueryCandidate;
typedef struct DnsScope DnsScope;
#include "resolve-util.h"
#include "resolved-dns-cache.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-stream.h"
#include "resolved-dns-zone.h"
#include "socket-util.h"
typedef struct DnsQuery DnsQuery;
typedef struct DnsQueryCandidate DnsQueryCandidate;
typedef struct DnsQuestion DnsQuestion;
typedef struct DnsSearchDomain DnsSearchDomain;
typedef struct DnsServer DnsServer;
typedef struct DnsStream DnsStream;
typedef struct Link Link;
typedef struct Manager Manager;
typedef enum DnsScopeMatch {
DNS_SCOPE_NO,
+6
View File
@@ -5,12 +5,18 @@
#include "sd-messages.h"
#include "alloc-util.h"
#include "dns-domain.h"
#include "errno-util.h"
#include "fd-util.h"
#include "json-util.h"
#include "resolved-bus.h"
#include "resolved-dns-cache.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-stub.h"
#include "resolved-link.h"
#include "resolved-manager.h"
#include "resolved-resolv-conf.h"
#include "siphash24.h"
+2 -4
View File
@@ -6,6 +6,8 @@
#include "in-addr-util.h"
#include "list.h"
#include "resolve-util.h"
#include "resolved-conf.h"
#include "resolved-dnstls.h"
#include "time-util.h"
typedef struct DnsScope DnsScope;
@@ -15,8 +17,6 @@ typedef struct DnsPacket DnsPacket;
typedef struct Link Link;
typedef struct Manager Manager;
#include "resolved-dnstls.h"
typedef enum DnsServerType {
DNS_SERVER_SYSTEM,
DNS_SERVER_FALLBACK,
@@ -25,8 +25,6 @@ typedef enum DnsServerType {
_DNS_SERVER_TYPE_INVALID = -EINVAL,
} DnsServerType;
#include "resolved-conf.h"
const char* dns_server_type_to_string(DnsServerType i) _const_;
DnsServerType dns_server_type_from_string(const char *s) _pure_;
+2
View File
@@ -9,6 +9,8 @@
#include "iovec-util.h"
#include "macro.h"
#include "missing_network.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-server.h"
#include "resolved-dns-stream.h"
#include "resolved-manager.h"
+4 -3
View File
@@ -3,18 +3,19 @@
#include "sd-event.h"
#include "list.h"
#include "ordered-set.h"
#include "resolved-dnstls.h"
#include "resolved-dns-packet.h"
#include "socket-util.h"
typedef struct DnsPacket DnsPacket;
typedef struct DnsServer DnsServer;
typedef struct DnsStream DnsStream;
typedef struct DnsTransaction DnsTransaction;
typedef struct Manager Manager;
typedef struct DnsStubListenerExtra DnsStubListenerExtra;
#include "resolved-dns-packet.h"
#include "resolved-dnstls.h"
/* Various timeouts for establishing TCP connections. First the default timeout for that. */
#define DNS_STREAM_DEFAULT_TIMEOUT_USEC (10 * USEC_PER_SEC)
+11
View File
@@ -4,11 +4,22 @@
#include <netinet/tcp.h>
#include "capability-util.h"
#include "dns-type.h"
#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "missing_network.h"
#include "missing_socket.h"
#include "resolve-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-stream.h"
#include "resolved-dns-stub.h"
#include "resolved-dns-transaction.h"
#include "resolved-manager.h"
#include "socket-netlink.h"
#include "socket-util.h"
#include "stdio-util.h"
+5 -3
View File
@@ -1,9 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "hash-funcs.h"
#include "sd-event.h"
#include "hashmap.h"
#include "in-addr-util.h"
typedef struct DnsStubListenerExtra DnsStubListenerExtra;
typedef struct Manager Manager;
typedef enum DnsStubListenerMode {
DNS_STUB_LISTENER_NO,
@@ -14,8 +18,6 @@ typedef enum DnsStubListenerMode {
_DNS_STUB_LISTENER_MODE_INVALID = -EINVAL,
} DnsStubListenerMode;
#include "resolved-manager.h"
struct DnsStubListenerExtra {
Manager *manager;
+9
View File
@@ -1,11 +1,20 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "dns-domain.h"
#include "dns-type.h"
#include "env-util.h"
#include "hostname-util.h"
#include "local-addresses.h"
#include "missing_network.h"
#include "resolved-def.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-synthesize.h"
#include "resolved-manager.h"
#include "socket-util.h"
int dns_synthesize_family(uint64_t flags) {
+8 -3
View File
@@ -1,9 +1,14 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "resolved-dns-answer.h"
#include "resolved-dns-question.h"
#include "resolved-manager.h"
#include <stdbool.h>
#include <stdint.h>
typedef enum DnsProtocol DnsProtocol;
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsQuestion DnsQuestion;
typedef struct Manager Manager;
int dns_synthesize_family(uint64_t flags);
DnsProtocol dns_synthesize_protocol(uint64_t flags);
+23
View File
@@ -10,10 +10,19 @@
#include "fd-util.h"
#include "glyph-util.h"
#include "random-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-cache.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-server.h"
#include "resolved-dns-transaction.h"
#include "resolved-dnstls.h"
#include "resolved-link.h"
#include "resolved-llmnr.h"
#include "resolved-socket-graveyard.h"
#include "resolved-timeouts.h"
#include "string-table.h"
@@ -2788,6 +2797,20 @@ int dns_transaction_request_dnssec_keys(DnsTransaction *t) {
return dns_transaction_dnssec_is_live(t);
}
DnsResourceKey* dns_transaction_key(DnsTransaction *t) {
assert(t);
/* Return the lookup key of this transaction. Either takes the lookup key from the bypass packet if
* we are a bypass transaction. Or take the configured key for regular transactions. */
if (t->key)
return t->key;
assert(t->bypass);
return dns_question_first_key(t->bypass->question);
}
void dns_transaction_notify(DnsTransaction *t, DnsTransaction *source) {
assert(t);
assert(source);
+17 -26
View File
@@ -2,20 +2,23 @@
#pragma once
#include "sd-event.h"
#include "in-addr-util.h"
typedef struct DnsTransaction DnsTransaction;
typedef struct DnsTransactionFinder DnsTransactionFinder;
typedef enum DnsTransactionState DnsTransactionState;
typedef enum DnsTransactionSource DnsTransactionSource;
#include "resolved-dns-answer.h"
#include "list.h"
#include "resolved-def.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-dns-server.h"
#include "set.h"
enum DnsTransactionState {
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsPacket DnsPacket;
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsScope DnsScope;
typedef struct DnsServer DnsServer;
typedef struct DnsStream DnsStream;
typedef struct DnsTransaction DnsTransaction;
typedef enum DnsTransactionState {
DNS_TRANSACTION_NULL,
DNS_TRANSACTION_PENDING,
DNS_TRANSACTION_VALIDATING,
@@ -36,18 +39,18 @@ enum DnsTransactionState {
DNS_TRANSACTION_STUB_LOOP,
_DNS_TRANSACTION_STATE_MAX,
_DNS_TRANSACTION_STATE_INVALID = -EINVAL,
};
} DnsTransactionState;
#define DNS_TRANSACTION_IS_LIVE(state) IN_SET((state), DNS_TRANSACTION_NULL, DNS_TRANSACTION_PENDING, DNS_TRANSACTION_VALIDATING)
enum DnsTransactionSource {
typedef enum DnsTransactionSource {
DNS_TRANSACTION_NETWORK,
DNS_TRANSACTION_CACHE,
DNS_TRANSACTION_ZONE,
DNS_TRANSACTION_TRUST_ANCHOR,
_DNS_TRANSACTION_SOURCE_MAX,
_DNS_TRANSACTION_SOURCE_INVALID = -EINVAL,
};
} DnsTransactionSource;
struct DnsTransaction {
DnsScope *scope;
@@ -163,19 +166,7 @@ void dns_transaction_notify(DnsTransaction *t, DnsTransaction *source);
int dns_transaction_validate_dnssec(DnsTransaction *t);
int dns_transaction_request_dnssec_keys(DnsTransaction *t);
static inline DnsResourceKey *dns_transaction_key(DnsTransaction *t) {
assert(t);
/* Return the lookup key of this transaction. Either takes the lookup key from the bypass packet if
* we are a bypass transaction. Or take the configured key for regular transactions. */
if (t->key)
return t->key;
assert(t->bypass);
return dns_question_first_key(t->bypass->question);
}
DnsResourceKey* dns_transaction_key(DnsTransaction *t);
static inline uint64_t dns_transaction_source_to_query_flags(DnsTransactionSource s) {
+2
View File
@@ -12,7 +12,9 @@
#include "log.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-trust-anchor.h"
#include "set.h"
#include "string-util.h"
+6 -6
View File
@@ -1,19 +1,19 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct DnsTrustAnchor DnsTrustAnchor;
#include "hashmap.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-rr.h"
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsResourceRecord DnsResourceRecord;
/* This contains a fixed database mapping domain names to DS or DNSKEY records. */
struct DnsTrustAnchor {
typedef struct DnsTrustAnchor {
Hashmap *positive_by_key;
Set *negative_by_name;
Set *revoked_by_rr;
};
} DnsTrustAnchor;
int dns_trust_anchor_load(DnsTrustAnchor *d);
void dns_trust_anchor_flush(DnsTrustAnchor *d);
+4
View File
@@ -3,7 +3,11 @@
#include "alloc-util.h"
#include "dns-domain.h"
#include "list.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-transaction.h"
#include "resolved-dns-zone.h"
#include "resolved-dnssd.h"
#include "resolved-manager.h"
+10 -10
View File
@@ -2,32 +2,32 @@
#pragma once
#include "hashmap.h"
#include "list.h"
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsResourceRecord DnsResourceRecord;
typedef struct DnsScope DnsScope;
typedef struct DnsTransaction DnsTransaction;
typedef struct DnsZoneItem DnsZoneItem;
typedef struct DnsZone {
Hashmap *by_key;
Hashmap *by_name;
} DnsZone;
typedef struct DnsZoneItem DnsZoneItem;
typedef enum DnsZoneItemState DnsZoneItemState;
#include "resolved-dns-answer.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-transaction.h"
/* RFC 4795 Section 2.8. suggests a TTL of 30s by default */
#define LLMNR_DEFAULT_TTL (30)
/* RFC 6762 Section 10. suggests a TTL of 120s by default */
#define MDNS_DEFAULT_TTL (120)
enum DnsZoneItemState {
typedef enum DnsZoneItemState {
DNS_ZONE_ITEM_PROBING,
DNS_ZONE_ITEM_ESTABLISHED,
DNS_ZONE_ITEM_VERIFYING,
DNS_ZONE_ITEM_WITHDRAWN,
};
} DnsZoneItemState;
struct DnsZoneItem {
DnsScope *scope;
+1
View File
@@ -2,6 +2,7 @@
#include "alloc-util.h"
#include "bus-polkit.h"
#include "resolved-dns-scope.h"
#include "resolved-dnssd-bus.h"
#include "resolved-dnssd.h"
#include "resolved-link.h"
+2
View File
@@ -3,10 +3,12 @@
#include "conf-files.h"
#include "conf-parser.h"
#include "constants.h"
#include "dns-domain.h"
#include "hexdecoct.h"
#include "path-util.h"
#include "resolved-conf.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-zone.h"
#include "resolved-dnssd.h"
#include "resolved-manager.h"
#include "specifier.h"
+1
View File
@@ -10,6 +10,7 @@
#include "io-util.h"
#include "openssl-util.h"
#include "resolved-dns-server.h"
#include "resolved-dns-stream.h"
#include "resolved-dnstls.h"
#include "resolved-manager.h"
+5
View File
@@ -4,11 +4,16 @@
#include <sys/types.h>
#include <unistd.h>
#include "dns-domain.h"
#include "fd-util.h"
#include "fileio.h"
#include "hostname-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-synthesize.h"
#include "resolved-etc-hosts.h"
#include "resolved-manager.h"
#include "socket-netlink.h"
#include "stat-util.h"
#include "string-util.h"
+13 -3
View File
@@ -1,9 +1,19 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "resolved-manager.h"
#include "resolved-dns-question.h"
#include "resolved-dns-answer.h"
#include "in-addr-util.h"
#include "set.h"
typedef struct DnsAnswer DnsAnswer;
typedef struct DnsQuestion DnsQuestion;
typedef struct EtcHosts EtcHosts;
typedef struct Manager Manager;
typedef struct EtcHosts {
Hashmap *by_address;
Hashmap *by_name;
Set *no_address;
} EtcHosts;
typedef struct EtcHostsItemByAddress {
struct in_addr_data address;
+1
View File
@@ -7,6 +7,7 @@ _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
#include <stddef.h>
#include "conf-parser.h"
#include "resolved-conf.h"
#include "resolved-dns-server.h"
#include "resolved-manager.h"
%}
struct ConfigPerfItem;
+5
View File
@@ -9,10 +9,15 @@
#include "bus-get-properties.h"
#include "bus-message-util.h"
#include "bus-polkit.h"
#include "dns-domain.h"
#include "log-link.h"
#include "parse-util.h"
#include "resolve-util.h"
#include "resolved-bus.h"
#include "resolved-def.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-link.h"
#include "resolved-link-bus.h"
#include "resolved-llmnr.h"
#include "resolved-mdns.h"
+3 -2
View File
@@ -3,8 +3,9 @@
#include "sd-bus.h"
#include "bus-util.h"
#include "resolved-link.h"
#include "bus-object.h"
typedef struct Link Link;
extern const BusObjectImplementation link_object;
+5
View File
@@ -6,6 +6,7 @@
#include "sd-network.h"
#include "alloc-util.h"
#include "dns-domain.h"
#include "env-file.h"
#include "fd-util.h"
#include "fileio.h"
@@ -14,7 +15,11 @@
#include "mkdir.h"
#include "netif-util.h"
#include "parse-util.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-link.h"
#include "resolved-llmnr.h"
#include "resolved-mdns.h"
+6 -5
View File
@@ -6,17 +6,18 @@
#include "sd-netlink.h"
#include "in-addr-util.h"
#include "list.h"
#include "network-util.h"
#include "ratelimit.h"
#include "resolve-util.h"
typedef struct DnsResourceRecord DnsResourceRecord;
typedef struct DnsScope DnsScope;
typedef struct DnsSearchDomain DnsSearchDomain;
typedef struct DnsServer DnsServer;
typedef struct Link Link;
typedef struct LinkAddress LinkAddress;
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
typedef struct Manager Manager;
#define LINK_SEARCH_DOMAINS_MAX 256
#define LINK_DNS_SERVERS_MAX 256
+4
View File
@@ -6,6 +6,10 @@
#include "errno-util.h"
#include "fd-util.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-transaction.h"
#include "resolved-link.h"
#include "resolved-llmnr.h"
#include "resolved-manager.h"
+11
View File
@@ -33,13 +33,24 @@
#include "random-util.h"
#include "resolved-bus.h"
#include "resolved-conf.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-stub.h"
#include "resolved-dns-transaction.h"
#include "resolved-dnssd.h"
#include "resolved-etc-hosts.h"
#include "resolved-link.h"
#include "resolved-llmnr.h"
#include "resolved-manager.h"
#include "resolved-mdns.h"
#include "resolved-resolv-conf.h"
#include "resolved-socket-graveyard.h"
#include "resolved-util.h"
#include "resolved-varlink.h"
#include "socket-util.h"
+17 -15
View File
@@ -3,6 +3,7 @@
#include <sys/stat.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-netlink.h"
#include "sd-network.h"
@@ -13,27 +14,28 @@
#include "list.h"
#include "ordered-set.h"
#include "resolve-util.h"
typedef struct Manager Manager;
#include "resolved-dns-query.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-stream.h"
#include "resolved-dns-stub.h"
#include "resolved-dns-trust-anchor.h"
#include "resolved-link.h"
#include "resolved-socket-graveyard.h"
#include "resolved-dnstls.h"
#include "resolved-etc-hosts.h"
typedef enum DnsServerType DnsServerType;
typedef struct DnsQuery DnsQuery;
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsSearchDomain DnsSearchDomain;
typedef struct DnsScope DnsScope;
typedef struct DnsServer DnsServer;
typedef struct Link Link;
typedef struct LinkAddress LinkAddress;
typedef struct SocketGraveyard SocketGraveyard;
#define MANAGER_SEARCH_DOMAINS_MAX 256
#define MANAGER_DNS_SERVERS_MAX 256
typedef struct EtcHosts {
Hashmap *by_address;
Hashmap *by_name;
Set *no_address;
} EtcHosts;
struct Manager {
typedef struct Manager {
sd_event *event;
ResolveSupport llmnr_support;
@@ -170,7 +172,7 @@ struct Manager {
size_t n_socket_graveyard;
struct sigrtmin18_info sigrtmin18_info;
};
} Manager;
/* Manager */
+8
View File
@@ -5,7 +5,15 @@
#include <arpa/inet.h>
#include "alloc-util.h"
#include "dns-domain.h"
#include "fd-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-transaction.h"
#include "resolved-link.h"
#include "resolved-manager.h"
#include "resolved-mdns.h"
#include "sort-util.h"
+1 -1
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "resolved-manager.h"
typedef struct Manager Manager;
#define MDNS_PORT 5353
#define MDNS_ANNOUNCE_DELAY (1 * USEC_PER_SEC)
+5
View File
@@ -14,7 +14,12 @@
#include "ordered-set.h"
#include "path-util.h"
#include "resolved-conf.h"
#include "resolved-dns-cache.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-stub.h"
#include "resolved-manager.h"
#include "resolved-resolv-conf.h"
#include "stat-util.h"
#include "string-table.h"
+5 -1
View File
@@ -1,7 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "resolved-manager.h"
#include <errno.h>
#include "macro.h"
typedef struct Manager Manager;
int manager_check_resolv_conf(const Manager *m);
int manager_read_resolv_conf(Manager *m);
+1
View File
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "resolved-manager.h"
#include "resolved-socket-graveyard.h"
#define SOCKET_GRAVEYARD_USEC (5 * USEC_PER_SEC)
+6 -2
View File
@@ -1,9 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct SocketGraveyard SocketGraveyard;
#include "sd-event.h"
#include "resolved-manager.h"
#include "list.h"
#include "time-util.h"
typedef struct Manager Manager;
typedef struct SocketGraveyard SocketGraveyard;
struct SocketGraveyard {
Manager *manager;
+14
View File
@@ -1,10 +1,24 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "bus-polkit.h"
#include "dns-domain.h"
#include "dns-type.h"
#include "glyph-util.h"
#include "in-addr-util.h"
#include "json-util.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-synthesize.h"
#include "resolved-dns-transaction.h"
#include "resolved-link.h"
#include "resolved-manager.h"
#include "resolved-varlink.h"
#include "socket-netlink.h"
#include "varlink-io.systemd.Resolve.h"
+1 -1
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "resolved-manager.h"
typedef struct Manager Manager;
int manager_varlink_init(Manager *m);
void manager_varlink_done(Manager *m);
+2
View File
@@ -1,7 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "dns-type.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "list.h"
+2
View File
@@ -1,7 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "dns-type.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "log.h"
+5
View File
@@ -1,10 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "log.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-query.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-transaction.h"
#include "resolved-link.h"
#include "resolved-manager.h"
#include "tests.h"
+1
View File
@@ -2,6 +2,7 @@
#include "log.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-synthesize.h"
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "dns-type.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-zone.h"
+1
View File
@@ -6,6 +6,7 @@
#include "alloc-util.h"
#include "hexdecoct.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-rr.h"
#include "string-util.h"
+2
View File
@@ -2,11 +2,13 @@
#include "sd-daemon.h"
#include "dns-type.h"
#include "fd-util.h"
#include "iovec-util.h"
#include "log.h"
#include "main-func.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-question.h"
#include "resolved-manager.h"
#include "socket-netlink.h"
#include "socket-util.h"
+3
View File
@@ -4,6 +4,9 @@
#include <linux/if.h>
#include "netlink-internal.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-scope.h"
#include "resolved-dns-server.h"
#include "resolved-link.h"
#include "resolved-manager.h"
+4
View File
@@ -1,8 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-json.h"
#include "hexdecoct.h"
#include "log.h"
#include "resolved-dns-answer.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
#include "tests.h"
TEST(dns_packet_new) {