]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: synthesize NODATA instead of NXDOMAIN if gateway exists, but of other protocol 17821/head
authorLennart Poettering <lennart@poettering.net>
Fri, 6 Nov 2020 09:26:44 +0000 (10:26 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Dec 2020 22:23:11 +0000 (23:23 +0100)
Fixes: #11192
src/resolve/resolved-dns-synthesize.c

index 67f0dda246d4a71eff57ed04ab10c66ac74a826c..f08d62116abda047156fd292032d3d34a4063c2b 100644 (file)
@@ -322,8 +322,24 @@ static int synthesize_gateway_rr(Manager *m, const DnsResourceKey *key, int ifin
         af = dns_type_to_af(key->type);
         if (af >= 0) {
                 n = local_gateways(m->rtnl, ifindex, af, &addresses);
-                if (n <= 0)
-                        return n;  /* < 0 means: error; == 0 means we have no gateway */
+                if (n < 0) /* < 0 means: error */
+                        return n;
+
+                if (n == 0) { /* == 0 means we have no gateway */
+                        /* See if there's a gateway on the other protocol */
+                        if (af == AF_INET)
+                                n = local_gateways(m->rtnl, ifindex, AF_INET6, NULL);
+                        else {
+                                assert(af == AF_INET6);
+                                n = local_gateways(m->rtnl, ifindex, AF_INET, NULL);
+                        }
+                        if (n <= 0) /* error (if < 0) or really no gateway at all (if == 0) */
+                                return n;
+
+                        /* We have a gateway on the other protocol. Let's return > 0 without adding any RR to
+                         * the answer, i.e. synthesize NODATA (and not NXDOMAIN!) */
+                        return 1;
+                }
         }
 
         r = answer_add_addresses_rr(answer, dns_resource_key_name(key), addresses, n);