resolved: bind socket to interface during connect()
authorLennart Poettering <lennart@poettering.net>
Thu, 5 Nov 2020 17:22:38 +0000 (18:22 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 2 Dec 2020 14:15:02 +0000 (15:15 +0100)
commitd301c52383ca7cfa6b7cda87d7a4209c234a532c
tree3b27506267b9bfd170c9e318bf334b77c2ba903b
parent3132597182c806e5193aebb0b67cdc0f73154a51
resolved: bind socket to interface during connect()

Apparently, IF_UNICAST_IF does not influence the routing decisions done
during connect(). But SO_BINDTODEVICE/SO_BINDTOINDEX does, which however
brings a lot of other semantics with it, we are not so interested in
(i.e. it doesn't not allow packets from any other iface to us, even if
routing otherwise allows it).

Hence, let's bind to the ifindex immediately before the connect() and
unbind right after again, so that we get the semantics we want, but not
the ones we don't.

Fixes: #11935
Replaces: #12004
src/resolve/resolved-dns-scope.c
src/resolve/resolved.c