diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-03-13 11:40:22 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-03-13 16:28:19 +0100 |
commit | f225a338c39e07262e8e18850643531d76deaa06 (patch) | |
tree | 1086025dba59159d9468a159447cd47aa1fcaec7 /src | |
parent | network: use userdata instead data in conf parsers (diff) | |
download | systemd-f225a338c39e07262e8e18850643531d76deaa06.tar.xz systemd-f225a338c39e07262e8e18850643531d76deaa06.zip |
network: also introduce UseDomains= for [DHCPv6] section
When we split [DHCP] section into [DHCPv4] and [DHCPv6], UseDomains=
setting was forgot to be introduced in [DHCPv6] section.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-dhcp-common.c | 46 | ||||
-rw-r--r-- | src/network/networkd-ndisc.c | 4 | ||||
-rw-r--r-- | src/network/networkd-ndisc.h | 1 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 11 | ||||
-rw-r--r-- | src/network/networkd-network.h | 3 | ||||
-rw-r--r-- | src/network/networkd-state-file.c | 12 |
6 files changed, 61 insertions, 16 deletions
diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c index 67e5e46dec..0de1892fc9 100644 --- a/src/network/networkd-dhcp-common.c +++ b/src/network/networkd-dhcp-common.c @@ -386,6 +386,49 @@ int config_parse_dhcp_use_dns( return 0; } +int config_parse_dhcp_use_domains( + const char* unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + Network *network = userdata; + DHCPUseDomains d; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + d = dhcp_use_domains_from_string(rvalue); + if (d < 0) { + log_syntax(unit, LOG_WARNING, filename, line, d, + "Failed to parse %s=%s, ignoring assignment: %m", lvalue, rvalue); + return 0; + } + + if (streq_ptr(section, "DHCPv4")) { + network->dhcp_use_domains = d; + network->dhcp_use_domains_set = true; + } else if (streq_ptr(section, "DHCPv6")) { + network->dhcp6_use_domains = d; + network->dhcp6_use_domains_set = true; + } else { /* [DHCP] section */ + if (!network->dhcp_use_domains_set) + network->dhcp_use_domains = d; + if (!network->dhcp6_use_domains_set) + network->dhcp6_use_domains = d; + } + + return 0; +} + int config_parse_dhcp_use_ntp( const char* unit, const char *filename, @@ -861,9 +904,6 @@ int config_parse_dhcp_request_options( } } -DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_use_domains, dhcp_use_domains, DHCPUseDomains, - "Failed to parse DHCP use domains setting"); - static const char* const dhcp_use_domains_table[_DHCP_USE_DOMAINS_MAX] = { [DHCP_USE_DOMAINS_NO] = "no", [DHCP_USE_DOMAINS_ROUTE] = "route", diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 035e80dab0..ba7c184b66 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -1555,8 +1555,10 @@ int config_parse_address_generation_type( return 0; } +DEFINE_CONFIG_PARSE_ENUM(config_parse_ipv6_accept_ra_use_domains, dhcp_use_domains, DHCPUseDomains, + "Failed to parse UseDomains= setting"); DEFINE_CONFIG_PARSE_ENUM(config_parse_ipv6_accept_ra_start_dhcp6_client, ipv6_accept_ra_start_dhcp6_client, IPv6AcceptRAStartDHCP6Client, - "Failed to parse DHCPv6Client= setting") + "Failed to parse DHCPv6Client= setting"); static const char* const ipv6_accept_ra_start_dhcp6_client_table[_IPV6_ACCEPT_RA_START_DHCP6_CLIENT_MAX] = { [IPV6_ACCEPT_RA_START_DHCP6_CLIENT_NO] = "no", [IPV6_ACCEPT_RA_START_DHCP6_CLIENT_ALWAYS] = "always", diff --git a/src/network/networkd-ndisc.h b/src/network/networkd-ndisc.h index 8984d88611..13e9547311 100644 --- a/src/network/networkd-ndisc.h +++ b/src/network/networkd-ndisc.h @@ -79,6 +79,7 @@ void ndisc_flush(Link *link); CONFIG_PARSER_PROTOTYPE(config_parse_ndisc_address_filter); CONFIG_PARSER_PROTOTYPE(config_parse_address_generation_type); CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_accept_ra_start_dhcp6_client); +CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_accept_ra_use_domains); const char* ipv6_accept_ra_start_dhcp6_client_to_string(IPv6AcceptRAStartDHCP6Client i) _const_; IPv6AcceptRAStartDHCP6Client ipv6_accept_ra_start_dhcp6_client_from_string(const char *s) _pure_; diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index a611134068..7d38d7077a 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -199,7 +199,7 @@ DHCPv4.UseNTP, config_parse_dhcp_use_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) -DHCPv4.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains) +DHCPv4.UseDomains, config_parse_dhcp_use_domains, 0, 0 DHCPv4.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_use_routes) DHCPv4.UseGateway, config_parse_tristate, 0, offsetof(Network, dhcp_use_gateway) DHCPv4.RequestOptions, config_parse_dhcp_request_options, AF_INET, 0 @@ -230,6 +230,7 @@ DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_li DHCPv6.UseAddress, config_parse_bool, 0, offsetof(Network, dhcp6_use_address) DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0 DHCPv6.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp6_use_hostname) +DHCPv6.UseDomains, config_parse_dhcp_use_domains, 0, 0 DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0 DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit) DHCPv6.MUDURL, config_parse_dhcp6_mud_url, 0, 0 @@ -245,7 +246,7 @@ DHCPv6.RouteMetric, config_parse_dhcp_route_metric, IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix) IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix) IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns) -IPv6AcceptRA.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, ipv6_accept_ra_use_domains) +IPv6AcceptRA.UseDomains, config_parse_ipv6_accept_ra_use_domains, 0, offsetof(Network, ipv6_accept_ra_use_domains) IPv6AcceptRA.DHCPv6Client, config_parse_ipv6_accept_ra_start_dhcp6_client, 0, offsetof(Network, ipv6_accept_ra_start_dhcp6_client) IPv6AcceptRA.RouteTable, config_parse_section_route_table, 0, 0 IPv6AcceptRA.RouterAllowList, config_parse_ndisc_address_filter, 0, offsetof(Network, ndisc_allow_listed_router) @@ -466,8 +467,8 @@ DHCP.UseDNS, config_parse_dhcp_use_dns, DHCP.UseNTP, config_parse_dhcp_use_ntp, 0, 0 DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_use_mtu) DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname) -DHCP.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains) -DHCP.UseDomainName, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains) +DHCP.UseDomains, config_parse_dhcp_use_domains, 0, 0 +DHCP.UseDomainName, config_parse_dhcp_use_domains, 0, 0 DHCP.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_use_routes) DHCP.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize) DHCP.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname) @@ -485,7 +486,7 @@ DHCP.IAID, config_parse_iaid, DHCP.ListenPort, config_parse_uint16, 0, offsetof(Network, dhcp_client_port) DHCP.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit) DHCP.ForceDHCPv6PDOtherInformation, config_parse_bool, 0, offsetof(Network, dhcp6_force_pd_other_information) -DHCPv4.UseDomainName, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains) +DHCPv4.UseDomainName, config_parse_dhcp_use_domains, 0, 0 DHCPv4.CriticalConnection, config_parse_tristate, 0, offsetof(Network, dhcp_critical) IPv6AcceptRA.DenyList, config_parse_ndisc_address_filter, 0, offsetof(Network, ndisc_deny_listed_prefix) IPv6AcceptRA.BlackList, config_parse_ndisc_address_filter, 0, offsetof(Network, ndisc_deny_listed_prefix) diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index e859b590c6..6fe8a76c13 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -151,6 +151,7 @@ struct Network { bool dhcp_send_release; bool dhcp_send_decline; DHCPUseDomains dhcp_use_domains; + bool dhcp_use_domains_set; Set *dhcp_deny_listed_ip; Set *dhcp_allow_listed_ip; Set *dhcp_request_options; @@ -165,6 +166,8 @@ struct Network { bool dhcp6_use_ntp; bool dhcp6_use_ntp_set; bool dhcp6_rapid_commit; + DHCPUseDomains dhcp6_use_domains; + bool dhcp6_use_domains_set; uint8_t dhcp6_pd_length; uint32_t dhcp6_route_metric; bool dhcp6_route_metric_set; diff --git a/src/network/networkd-state-file.c b/src/network/networkd-state-file.c index 9c5c5047b3..52f7ce2d9f 100644 --- a/src/network/networkd-state-file.c +++ b/src/network/networkd-state-file.c @@ -504,14 +504,12 @@ int link_save(Link *link) { /************************************************************/ - if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO) { - if (link->dhcp_lease) { - (void) sd_dhcp_lease_get_domainname(link->dhcp_lease, &dhcp_domainname); - (void) sd_dhcp_lease_get_search_domains(link->dhcp_lease, &dhcp_domains); - } - if (link->dhcp6_lease) - (void) sd_dhcp6_lease_get_domains(link->dhcp6_lease, &dhcp6_domains); + if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO && link->dhcp_lease) { + (void) sd_dhcp_lease_get_domainname(link->dhcp_lease, &dhcp_domainname); + (void) sd_dhcp_lease_get_search_domains(link->dhcp_lease, &dhcp_domains); } + if (link->network->dhcp6_use_domains != DHCP_USE_DOMAINS_NO && link->dhcp6_lease) + (void) sd_dhcp6_lease_get_domains(link->dhcp6_lease, &dhcp6_domains); fputs("DOMAINS=", f); space = false; |