]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: request incoming ifindex for DNS UDP packets, too
authorLennart Poettering <lennart@poettering.net>
Tue, 4 Dec 2018 22:18:50 +0000 (23:18 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 5 Dec 2018 17:46:23 +0000 (18:46 +0100)
This information is useful to pass back to the caller, as it tells us
where we found the answer.

(While we are at it, fix the socket level for the RECVERR logic)

Fixes: #9778
src/resolve/resolved-dns-scope.c

index ee204435b33964e2759253d69e43de32dec32803..35c3804dbabc98583ce7d42564a68a8f638c0375 100644 (file)
@@ -413,9 +413,25 @@ static int dns_scope_socket(
 
         if (type == SOCK_DGRAM) {
                 /* Set IP_RECVERR or IPV6_RECVERR to get ICMP error feedback. See discussion in #10345. */
-                r = setsockopt_int(fd, SOL_IP, sa.sa.sa_family == AF_INET ? IP_RECVERR : IPV6_RECVERR, true);
-                if (r < 0)
-                        return r;
+
+                if (sa.sa.sa_family == AF_INET) {
+                        r = setsockopt_int(fd, IPPROTO_IP, IP_RECVERR, true);
+                        if (r < 0)
+                                return r;
+
+                        r = setsockopt_int(fd, IPPROTO_IP, IP_PKTINFO, true);
+                        if (r < 0)
+                                return r;
+
+                } else if (sa.sa.sa_family == AF_INET6) {
+                        r = setsockopt_int(fd, IPPROTO_IPV6, IPV6_RECVERR, true);
+                        if (r < 0)
+                                return r;
+
+                        r = setsockopt_int(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, true);
+                        if (r < 0)
+                                return r;
+                }
         }
 
         if (ret_socket_address)