network: dhcp4: introduce RoutesToNTP= boolean setting

This commit is contained in:
Yu Watanabe
2021-04-27 00:01:18 +09:00
parent 949b2c95c9
commit d7b0450639
6 changed files with 38 additions and 0 deletions
+8
View File
@@ -1641,6 +1641,14 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<filename>systemd-timesyncd.service</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>RoutesToNTP=</varname></term>
<listitem>
<para>When true, the routes to the NTP servers received from the DHCP server will be
configured. When <varname>UseNTP=</varname> is disabled, this setting is ignored.
Defaults to true.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UseSIP=</varname></term>
<listitem>
+26
View File
@@ -549,6 +549,28 @@ static int link_set_routes_to_dns(Link *link, const struct in_addr *gw) {
return link_set_routes_to_servers(link, dns, r, gw);
}
static int link_set_routes_to_ntp(Link *link, const struct in_addr *gw) {
const struct in_addr *ntp;
int r;
assert(link);
assert(link->dhcp_lease);
assert(link->network);
assert(gw);
if (!link->network->dhcp_use_ntp ||
!link->network->dhcp_routes_to_ntp)
return 0;
r = sd_dhcp_lease_get_ntp(link->dhcp_lease, &ntp);
if (IN_SET(r, 0, -ENODATA))
return 0;
if (r < 0)
return r;
return link_set_routes_to_servers(link, ntp, r, gw);
}
static int link_set_dhcp_routes(Link *link) {
struct in_addr gw = {};
Route *rt;
@@ -592,6 +614,10 @@ static int link_set_dhcp_routes(Link *link) {
if (r < 0)
return log_link_error_errno(link, r, "DHCP error: Could not set routes to DNS servers: %m");
r = link_set_routes_to_ntp(link, &gw);
if (r < 0)
return log_link_error_errno(link, r, "DHCP error: Could not set routes to NTP servers: %m");
return 0;
}
+1
View File
@@ -197,6 +197,7 @@ DHCPv4.ClientIdentifier, config_parse_dhcp_client_identifier
DHCPv4.UseDNS, config_parse_dhcp_use_dns, 0, 0
DHCPv4.RoutesToDNS, config_parse_bool, 0, offsetof(Network, dhcp_routes_to_dns)
DHCPv4.UseNTP, config_parse_dhcp_use_ntp, 0, 0
DHCPv4.RoutesToNTP, config_parse_bool, 0, offsetof(Network, dhcp_routes_to_ntp)
DHCPv4.UseSIP, config_parse_bool, 0, offsetof(Network, dhcp_use_sip)
DHCPv4.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_use_mtu)
DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname)
+1
View File
@@ -304,6 +304,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp_duid.type = _DUID_TYPE_INVALID,
.dhcp_critical = -1,
.dhcp_use_ntp = true,
.dhcp_routes_to_ntp = true,
.dhcp_use_sip = true,
.dhcp_use_dns = true,
.dhcp_routes_to_dns = true,
+1
View File
@@ -142,6 +142,7 @@ struct Network {
bool dhcp_routes_to_dns;
bool dhcp_use_ntp;
bool dhcp_use_ntp_set;
bool dhcp_routes_to_ntp;
bool dhcp_use_sip;
bool dhcp_use_mtu;
bool dhcp_use_routes;
@@ -94,6 +94,7 @@ UseGateway=
IAID=
UserClass=
UseNTP=
RoutesToNTP=
UseSIP=
UseMTU=
UseDomainName=