From a24e12f0209b075e2db80cc3adac1c5afb17031e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 17 Jul 2019 02:47:20 +0900 Subject: network: add DHCPv4.RoutesToDNS= setting --- man/systemd.network.xml | 8 ++++++++ src/network/networkd-dhcp4.c | 6 ++++-- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.h | 1 + test/fuzz/fuzz-network-parser/directives.network | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index cd1aa73f46..041bafc773 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1322,6 +1322,14 @@ project='man-pages'>resolv.conf5. + + RoutesToDNS= + + When true, the routes to the DNS servers received from the DHCP server will be + configured. When UseDNS= is disabled, this setting is ignored. + Defaults to false + + UseNTP= diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index e5ea6b702e..f20254fc82 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -118,7 +118,8 @@ static int link_set_dns_routes(Link *link, const struct in_addr *address) { assert(link->dhcp_lease); assert(link->network); - if (!link->network->dhcp_use_dns) + if (!link->network->dhcp_use_dns || + !link->network->dhcp_routes_to_dns) return 0; n = sd_dhcp_lease_get_dns(link->dhcp_lease, &dns); @@ -408,7 +409,8 @@ static int dhcp_remove_dns_routes(Link *link, sd_dhcp_lease *lease, const struct assert(lease); assert(link->network); - if (!link->network->dhcp_use_dns) + if (!link->network->dhcp_use_dns || + !link->network->dhcp_routes_to_dns) return 0; n = sd_dhcp_lease_get_dns(lease, &dns); diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 3501ffdd10..f5f837ad63 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -142,6 +142,7 @@ Route.FastOpenNoCookie, config_parse_fast_open_no_cookie, Route.TTLPropagate, config_parse_route_ttl_propagate, 0, 0 DHCPv4.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier) DHCPv4.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns) +DHCPv4.RoutesToDNS, config_parse_bool, 0, offsetof(Network, dhcp_routes_to_dns) DHCPv4.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp) DHCPv4.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_use_mtu) DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname) diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 82fad492a8..0fa800841c 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -91,6 +91,7 @@ struct Network { bool dhcp_broadcast; int dhcp_critical; bool dhcp_use_dns; + bool dhcp_routes_to_dns; bool dhcp_use_ntp; bool dhcp_use_mtu; bool dhcp_use_routes; diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 69a4281542..c3af95db0d 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -69,6 +69,7 @@ SendRelease= MaxAttempts= [DHCPv4] UseDNS= +RoutesToDNS= UseDomains= UseRoutes= IAID= -- cgit v1.2.3