1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-27 07:22:31 +03:00

Merge pull request #25438 from poettering/localhost-ifindex-tweak

resolved: fix ifindex for contacting per-interface DNS server if it is 127.0.0.1
This commit is contained in:
Yu Watanabe 2022-11-19 15:36:12 +09:00 committed by GitHub
commit da2e6df00a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -424,7 +424,7 @@ static int dns_scope_socket(
return r;
}
if (s->link) {
if (ifindex != 0) {
r = socket_set_unicast_if(fd, sa.sa.sa_family, ifindex);
if (r < 0)
return r;

View File

@ -648,6 +648,11 @@ int dns_server_adjust_opt(DnsServer *server, DnsPacket *packet, DnsServerFeature
int dns_server_ifindex(const DnsServer *s) {
assert(s);
/* For loopback addresses, go via the loopback interface, regardless which interface this is linked
* to. */
if (in_addr_is_localhost(s->family, &s->address))
return LOOPBACK_IFINDEX;
/* The link ifindex always takes precedence */
if (s->link)
return s->link->ifindex;