]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: flush the global DNS cache if /etc/resolv.conf is touched
authorLennart Poettering <lennart@poettering.net>
Thu, 26 Nov 2015 23:23:32 +0000 (00:23 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 26 Nov 2015 23:46:51 +0000 (00:46 +0100)
After all /etc/resolv.conf is usually done when the network
configuration changes, which is a good reason to flush the global cache.

See: #2038

src/resolve/resolved-resolv-conf.c

index 63bde1c2f4194ae54269d6917b8fd7fb8d8ecc82..956f380f3c8499de4ecc6a17f29149185bb20915 100644 (file)
@@ -129,6 +129,15 @@ int manager_read_resolv_conf(Manager *m) {
          * resolve VPN domains. */
         manager_set_dns_server(m, m->dns_servers);
 
+        /* Unconditionally flush the cache when /etc/resolv.conf is
+         * modified, even if the data it contained was completely
+         * identical to the previous version we used. We do this
+         * because altering /etc/resolv.conf is typically done when
+         * the network configuration changes, and that should be
+         * enough to flush the global unicast DNS cache. */
+        if (m->unicast_scope)
+                dns_cache_flush(&m->unicast_scope->cache);
+
         return 0;
 
 clear: