X Tutup
Skip to content

Commit ee18f10

Browse files
committed
resolved: synthesize _outbound magic hostname here too
1 parent a1fdbcb commit ee18f10

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

src/resolve/resolved-dns-scope.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ DnsScopeMatch dns_scope_good_domain(
630630
if (dns_name_endswith(domain, "invalid") > 0)
631631
return DNS_SCOPE_NO;
632632

633-
/* Never go to network for the _gateway domain, it's something special, synthesized locally. */
634-
if (is_gateway_hostname(domain))
633+
/* Never go to network for the _gateway or _outbound domain — they're something special, synthesized locally. */
634+
if (is_gateway_hostname(domain) || is_outbound_hostname(domain))
635635
return DNS_SCOPE_NO;
636636

637637
switch (s->protocol) {
@@ -739,6 +739,7 @@ DnsScopeMatch dns_scope_good_domain(
739739

740740
if ((dns_name_is_single_label(domain) && /* only resolve single label names via LLMNR */
741741
!is_gateway_hostname(domain) && /* don't resolve "_gateway" with LLMNR, let local synthesizing logic handle that */
742+
!is_outbound_hostname(domain) && /* similar for "_outbound" */
742743
dns_name_equal(domain, "local") == 0 && /* don't resolve "local" with LLMNR, it's the top-level domain of mDNS after all, see above */
743744
manager_is_own_hostname(s->manager, domain) <= 0)) /* never resolve the local hostname via LLMNR */
744745
return DNS_SCOPE_YES_BASE + 1; /* Return +1, as we consider ourselves authoritative

src/resolve/resolved-dns-synthesize.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,27 +311,33 @@ static int synthesize_system_hostname_ptr(Manager *m, int af, const union in_add
311311
return added;
312312
}
313313

314-
static int synthesize_gateway_rr(Manager *m, const DnsResourceKey *key, int ifindex, DnsAnswer **answer) {
314+
static int synthesize_gateway_rr(
315+
Manager *m,
316+
const DnsResourceKey *key,
317+
int ifindex,
318+
int (*lookup)(sd_netlink *context, int ifindex, int af, struct local_address **ret), /* either local_gateways() or local_outbound() */
319+
DnsAnswer **answer) {
315320
_cleanup_free_ struct local_address *addresses = NULL;
316321
int n = 0, af, r;
317322

318323
assert(m);
319324
assert(key);
325+
assert(lookup);
320326
assert(answer);
321327

322328
af = dns_type_to_af(key->type);
323329
if (af >= 0) {
324-
n = local_gateways(m->rtnl, ifindex, af, &addresses);
330+
n = lookup(m->rtnl, ifindex, af, &addresses);
325331
if (n < 0) /* < 0 means: error */
326332
return n;
327333

328334
if (n == 0) { /* == 0 means we have no gateway */
329335
/* See if there's a gateway on the other protocol */
330336
if (af == AF_INET)
331-
n = local_gateways(m->rtnl, ifindex, AF_INET6, NULL);
337+
n = lookup(m->rtnl, ifindex, AF_INET6, NULL);
332338
else {
333339
assert(af == AF_INET6);
334-
n = local_gateways(m->rtnl, ifindex, AF_INET, NULL);
340+
n = lookup(m->rtnl, ifindex, AF_INET, NULL);
335341
}
336342
if (n <= 0) /* error (if < 0) or really no gateway at all (if == 0) */
337343
return n;
@@ -402,14 +408,24 @@ int dns_synthesize_answer(
402408

403409
} else if (is_gateway_hostname(name)) {
404410

405-
r = synthesize_gateway_rr(m, key, ifindex, &answer);
411+
r = synthesize_gateway_rr(m, key, ifindex, local_gateways, &answer);
406412
if (r < 0)
407413
return log_error_errno(r, "Failed to synthesize gateway RRs: %m");
408414
if (r == 0) { /* if we have no gateway return NXDOMAIN */
409415
nxdomain = true;
410416
continue;
411417
}
412418

419+
} else if (is_outbound_hostname(name)) {
420+
421+
r = synthesize_gateway_rr(m, key, ifindex, local_outbounds, &answer);
422+
if (r < 0)
423+
return log_error_errno(r, "Failed to synthesize outbound RRs: %m");
424+
if (r == 0) { /* if we have no gateway return NXDOMAIN */
425+
nxdomain = true;
426+
continue;
427+
}
428+
413429
} else if ((dns_name_endswith(name, "127.in-addr.arpa") > 0 && dns_name_equal(name, "2.0.0.127.in-addr.arpa") == 0) ||
414430
dns_name_equal(name, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0) {
415431

@@ -431,6 +447,10 @@ int dns_synthesize_answer(
431447
if (v == 0 && w == 0) /* This IP address is neither a local one nor a gateway */
432448
continue;
433449

450+
/* Note that we never synthesize reverse PTR for _outbound, since those are local
451+
* addresses and thus mapped to the local hostname anyway, hence they already have a
452+
* mapping. */
453+
434454
} else
435455
continue;
436456

0 commit comments

Comments
 (0)
X Tutup