]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: make dns_scope_good_domain() take DnsQuery*
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Feb 2022 22:50:30 +0000 (07:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Feb 2022 22:53:57 +0000 (07:53 +0900)
src/resolve/resolved-dns-query.c
src/resolve/resolved-dns-scope.c
src/resolve/resolved-dns-scope.h

index 7dc346794e6843c28591fea814cffeffa8a48e97..c0bb40937a967c9b17e64ec3e503001a1b6f668d 100644 (file)
@@ -737,13 +737,8 @@ int dns_query_go(DnsQuery *q) {
 
         LIST_FOREACH(scopes, s, q->manager->dns_scopes) {
                 DnsScopeMatch match;
-                const char *name;
 
-                name = dns_question_first_name(dns_query_question_for_protocol(q, s->protocol));
-                if (!name)
-                        continue;
-
-                match = dns_scope_good_domain(s, q->ifindex, q->flags, name);
+                match = dns_scope_good_domain(s, q);
                 assert(match >= 0);
                 if (match > found) { /* Does this match better? If so, remember how well it matched, and the first one
                                       * that matches this well */
@@ -769,13 +764,8 @@ int dns_query_go(DnsQuery *q) {
 
         LIST_FOREACH(scopes, s, first->scopes_next) {
                 DnsScopeMatch match;
-                const char *name;
-
-                name = dns_question_first_name(dns_query_question_for_protocol(q, s->protocol));
-                if (!name)
-                        continue;
 
-                match = dns_scope_good_domain(s, q->ifindex, q->flags, name);
+                match = dns_scope_good_domain(s, q);
                 assert(match >= 0);
                 if (match < found)
                         continue;
index c3a2e2fc60519bcb1d1f13e963eca45d9a3644dc..69101fb5a2ba06fca229f62ee462d6c84b7ea281 100644 (file)
@@ -584,11 +584,13 @@ static DnsScopeMatch match_subnet_reverse_lookups(
 
 DnsScopeMatch dns_scope_good_domain(
                 DnsScope *s,
-                int ifindex,
-                uint64_t flags,
-                const char *domain) {
+                DnsQuery *q) {
 
+        DnsQuestion *question;
         DnsSearchDomain *d;
+        const char *domain;
+        uint64_t flags;
+        int ifindex;
 
         /* This returns the following return values:
          *
@@ -602,7 +604,18 @@ DnsScopeMatch dns_scope_good_domain(
          */
 
         assert(s);
-        assert(domain);
+        assert(q);
+
+        question = dns_query_question_for_protocol(q, s->protocol);
+        if (!question)
+                return DNS_SCOPE_NO;
+
+        domain = dns_question_first_name(question);
+        if (!domain)
+                return DNS_SCOPE_NO;
+
+        ifindex = q->ifindex;
+        flags = q->flags;
 
         /* Checks if the specified domain is something to look up on this scope. Note that this accepts
          * non-qualified hostnames, i.e. those without any search path suffixed. */
index a2b9546b3805a390257258e116060518be1d3779..1f9d22b7d18a0b721330aa1e5a9c33b08ac6c8d6 100644 (file)
@@ -10,7 +10,7 @@ typedef struct DnsScope DnsScope;
 #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"
@@ -76,7 +76,7 @@ int dns_scope_emit_udp(DnsScope *s, int fd, int af, DnsPacket *p);
 int dns_scope_socket_tcp(DnsScope *s, int family, const union in_addr_union *address, DnsServer *server, uint16_t port, union sockaddr_union *ret_socket_address);
 int dns_scope_socket_udp(DnsScope *s, DnsServer *server);
 
-DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain);
+DnsScopeMatch dns_scope_good_domain(DnsScope *s, DnsQuery *q);
 bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key);
 
 DnsServer *dns_scope_get_dns_server(DnsScope *s);