X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fresolve%2Fresolved-dns-scope.c;h=fd4f5f7e335b7964ba130fd048d0f920b9426bbc;hb=0c9eefb7e3a39db832313b8411a4dcb9fdfe3607;hp=396ae19e488e97eb46a5c49beab16a744d3fe806;hpb=51323288fc628a5cac50914df915545d685b793e;p=elogind.git diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index 396ae19e4..fd4f5f7e3 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -82,10 +82,10 @@ DnsScope* dns_scope_free(DnsScope *s) { dns_transaction_free(t); } - while ((rr = hashmap_steal_first(s->conflict_queue))) + while ((rr = ordered_hashmap_steal_first(s->conflict_queue))) dns_resource_record_unref(rr); - hashmap_free(s->conflict_queue); + ordered_hashmap_free(s->conflict_queue); sd_event_source_unref(s->conflict_event_source); dns_cache_flush(&s->cache); @@ -365,6 +365,13 @@ int dns_scope_good_key(DnsScope *s, DnsResourceKey *key) { int dns_scope_llmnr_membership(DnsScope *s, bool b) { int fd; + assert(s); + + if (s->protocol != DNS_PROTOCOL_LLMNR) + return 0; + + assert(s->link); + if (s->family == AF_INET) { struct ip_mreqn mreqn = { .imr_multiaddr = LLMNR_MULTICAST_IPV4_ADDRESS, @@ -379,7 +386,7 @@ int dns_scope_llmnr_membership(DnsScope *s, bool b) { * one. This is necessary on some devices, such as * veth. */ if (b) - setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreqn, sizeof(mreqn)); + (void)setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreqn, sizeof(mreqn)); if (setsockopt(fd, IPPROTO_IP, b ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP, &mreqn, sizeof(mreqn)) < 0) return -errno; @@ -395,7 +402,7 @@ int dns_scope_llmnr_membership(DnsScope *s, bool b) { return fd; if (b) - setsockopt(fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); + (void)setsockopt(fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); if (setsockopt(fd, IPPROTO_IPV6, b ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) return -errno; @@ -675,7 +682,7 @@ static int on_conflict_dispatch(sd_event_source *es, usec_t usec, void *userdata _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL; _cleanup_(dns_packet_unrefp) DnsPacket *p = NULL; - rr = hashmap_steal_first(scope->conflict_queue); + rr = ordered_hashmap_steal_first(scope->conflict_queue); if (!rr) break; @@ -702,7 +709,7 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) { /* We don't send these queries immediately. Instead, we queue * them, and send them after some jitter delay. */ - r = hashmap_ensure_allocated(&scope->conflict_queue, dns_resource_key_hash_func, dns_resource_key_compare_func); + r = ordered_hashmap_ensure_allocated(&scope->conflict_queue, &dns_resource_key_hash_ops); if (r < 0) { log_oom(); return r; @@ -711,7 +718,7 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) { /* We only place one RR per key in the conflict * messages, not all of them. That should be enough to * indicate where there might be a conflict */ - r = hashmap_put(scope->conflict_queue, rr->key, rr); + r = ordered_hashmap_put(scope->conflict_queue, rr->key, rr); if (r == -EEXIST || r == 0) return 0; if (r < 0) {