network: Introduce IPv6RA UseDNR= option

Same as the DHCP v4/v6 options, this controls the use of DNR received
from ipv6ra.
This commit is contained in:
Ronan Pigott 2024-01-22 14:37:42 -07:00
parent bd73de3575
commit 9250f56b5b
6 changed files with 19 additions and 0 deletions

View file

@ -3353,6 +3353,16 @@ Token=prefixstable:2002:da8:1::</programlisting></para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>UseDNR=</varname></term>
<listitem>
<para> When true, the DNR servers received in the Router Advertisement will be used. Defaults to
the value of <option>UseDNS=</option>.</para>
<xi:include href="version-info.xml" xpointer="v256"/>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><varname>UseDomains=</varname></term> <term><varname>UseDomains=</varname></term>
<listitem> <listitem>

View file

@ -109,6 +109,9 @@ bool link_get_use_dnr(Link *link, NetworkConfigSource proto) {
case NETWORK_CONFIG_SOURCE_DHCP6: case NETWORK_CONFIG_SOURCE_DHCP6:
n = link->network->dhcp6_use_dnr; n = link->network->dhcp6_use_dnr;
break; break;
case NETWORK_CONFIG_SOURCE_NDISC:
n = link->network->ndisc_use_dnr;
break;
default: default:
assert_not_reached(); assert_not_reached();
} }

View file

@ -1868,6 +1868,9 @@ static int ndisc_router_process_encrypted_dns(Link *link, sd_ndisc_router *rt) {
sd_dns_resolver *res; sd_dns_resolver *res;
_cleanup_(ndisc_dnr_freep) NDiscDNR *new_entry = NULL; _cleanup_(ndisc_dnr_freep) NDiscDNR *new_entry = NULL;
if (!link_get_use_dnr(link, NETWORK_CONFIG_SOURCE_NDISC))
return 0;
r = sd_ndisc_router_get_sender_address(rt, &router); r = sd_ndisc_router_get_sender_address(rt, &router);
if (r < 0) if (r < 0)
return log_link_warning_errno(link, r, "Failed to get gateway address from RA: %m"); return log_link_warning_errno(link, r, "Failed to get gateway address from RA: %m");

View file

@ -306,6 +306,7 @@ IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool,
IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ndisc_use_onlink_prefix) IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ndisc_use_onlink_prefix)
IPv6AcceptRA.UsePREF64, config_parse_bool, 0, offsetof(Network, ndisc_use_pref64) IPv6AcceptRA.UsePREF64, config_parse_bool, 0, offsetof(Network, ndisc_use_pref64)
IPv6AcceptRA.UseDNS, config_parse_tristate, 0, offsetof(Network, ndisc_use_dns) IPv6AcceptRA.UseDNS, config_parse_tristate, 0, offsetof(Network, ndisc_use_dns)
IPv6AcceptRA.UseDNR, config_parse_tristate, 0, offsetof(Network, ndisc_use_dnr)
IPv6AcceptRA.UseDomains, config_parse_use_domains, 0, offsetof(Network, ndisc_use_domains) IPv6AcceptRA.UseDomains, config_parse_use_domains, 0, offsetof(Network, ndisc_use_domains)
IPv6AcceptRA.UseMTU, config_parse_bool, 0, offsetof(Network, ndisc_use_mtu) IPv6AcceptRA.UseMTU, config_parse_bool, 0, offsetof(Network, ndisc_use_mtu)
IPv6AcceptRA.UseHopLimit, config_parse_bool, 0, offsetof(Network, ndisc_use_hop_limit) IPv6AcceptRA.UseHopLimit, config_parse_bool, 0, offsetof(Network, ndisc_use_hop_limit)

View file

@ -482,6 +482,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.ndisc = -1, .ndisc = -1,
.ndisc_use_redirect = true, .ndisc_use_redirect = true,
.ndisc_use_dns = -1, .ndisc_use_dns = -1,
.ndisc_use_dnr = -1,
.ndisc_use_gateway = true, .ndisc_use_gateway = true,
.ndisc_use_captive_portal = true, .ndisc_use_captive_portal = true,
.ndisc_use_route_prefix = true, .ndisc_use_route_prefix = true,

View file

@ -343,6 +343,7 @@ struct Network {
/* NDisc support */ /* NDisc support */
int ndisc; int ndisc;
int ndisc_use_dnr;
bool ndisc_use_redirect; bool ndisc_use_redirect;
int ndisc_use_dns; int ndisc_use_dns;
bool ndisc_use_gateway; bool ndisc_use_gateway;