]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: compare port and SNI in dns_server_hash_ops
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 13 Jul 2020 00:11:49 +0000 (09:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 Jul 2020 19:04:49 +0000 (04:04 +0900)
src/resolve/resolved-dns-server.c

index 1bd9c6fcbdbe79ba0d8a0839a7c51c081675d93b..0ace7d37f290df317124e612ed22782c36c4514f 100644 (file)
@@ -609,7 +609,10 @@ static void dns_server_hash_func(const DnsServer *s, struct siphash *state) {
 
         siphash24_compress(&s->family, sizeof(s->family), state);
         siphash24_compress(&s->address, FAMILY_ADDRESS_SIZE(s->family), state);
+        siphash24_compress(&s->port, sizeof(s->port), state);
         siphash24_compress(&s->ifindex, sizeof(s->ifindex), state);
+        if (s->server_name)
+                siphash24_compress(s->server_name, strlen(s->server_name), state);
 }
 
 static int dns_server_compare_func(const DnsServer *x, const DnsServer *y) {
@@ -623,11 +626,15 @@ static int dns_server_compare_func(const DnsServer *x, const DnsServer *y) {
         if (r != 0)
                 return r;
 
+        r = CMP(x->port, y->port);
+        if (r != 0)
+                return r;
+
         r = CMP(x->ifindex, y->ifindex);
         if (r != 0)
                 return r;
 
-        return 0;
+        return streq_ptr(x->server_name, y->server_name);
 }
 
 DEFINE_HASH_OPS(dns_server_hash_ops, DnsServer, dns_server_hash_func, dns_server_compare_func);