resolved: define source address for proxy-only stub replies
authorBenjamin Franzke <benjaminfranzke@googlemail.com>
Tue, 31 May 2022 19:36:55 +0000 (21:36 +0200)
committerBenjamin Franzke <benjaminfranzke@googlemail.com>
Tue, 31 May 2022 20:38:47 +0000 (22:38 +0200)
commitdfa14e2859418593b2f9bfae8936d780148c4e6a
treee58f6f54b3ffab9799018850c2d7ff576b67e14d
parent1c1cb8ec6f16c9c38806b2aba86e4d80e569b0d7
resolved: define source address for proxy-only stub replies

DnsPacket.ifindex=1 (loopback) is normalized to 0 whenever a message is
received on the loopback iface, so for both listeners, 127.0.0.53 and
127.0.0.54, the ifindex will be set to 0 by manager_recv() for queries
that have a local origin.

Replies to such local messages need to set a proper ifindex in any
case, as the supplied source-address would otherwise be ignored in
manager_ipv4_send() (CMSG generation is skipped due to ifindex > 0 check).

Note that this change only forces `ifindex` to loopback if it was actually
normalized to `0` before (due to a loopback detection) in order to keep the
nat-to-127.0.0.54-from-another-interface usecase that was described in
a8d09063447568d87288a8e868fe386c1da7ce09 intact.
Also note that nat is not supported for the main stub 127.0.0.53 which is
why forcing LOOPBACK_IFINDEX was/is fine for that case.

Fixes #23495
src/resolve/resolved-dns-stub.c