@@ -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