machined: refresh resolve hook addresses per machine
Track which machine the cached address list belongs to and refresh it
when ResolveRecord() advances to another machine. This keeps A/AAAA
reuse for the same machine while avoiding mixed name/address records.
Reproducer: register two machines with private addresses 10.88.1.1
and 10.88.2.1, then call io.systemd.Resolve.Hook.ResolveRecord
with both A questions in one request.
Before: the answer for the second machine used its own name but
reused the first machine's address, e.g. resolve-bug-m2 returned
10.88.1.1 instead of 10.88.2.1.
Follow-up: 3cd929f837
This commit is contained in:
committed by
Yu Watanabe
parent
48b1109b0c
commit
8a5c8b751b
@@ -125,6 +125,7 @@ int vl_method_resolve_record(
|
||||
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
|
||||
|
||||
_cleanup_free_ struct local_address *addresses = NULL;
|
||||
Machine *addresses_machine = NULL;
|
||||
bool found = false, nxdomain = false;
|
||||
int n_addresses = -1;
|
||||
|
||||
@@ -138,10 +139,13 @@ int vl_method_resolve_record(
|
||||
if (!dns_resource_key_is_address(key))
|
||||
continue;
|
||||
|
||||
if (n_addresses < 0) {
|
||||
if (addresses_machine != machine) {
|
||||
addresses = mfree(addresses);
|
||||
n_addresses = machine_get_addresses(machine, &addresses);
|
||||
if (n_addresses < 0)
|
||||
return n_addresses;
|
||||
|
||||
addresses_machine = machine;
|
||||
}
|
||||
|
||||
int family = dns_type_to_af(key->type);
|
||||
|
||||
Reference in New Issue
Block a user