summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-dhcp6.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-04-03 12:34:40 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-04-03 12:55:25 +0200
commit612caa2626ba898708f4b8a2bdbb6c1014e84d63 (patch)
tree08d8a7e0a300b2c090276d790c4ae3a2b383281b /src/network/networkd-dhcp6.c
parentdhcp: make option names singular (diff)
downloadsystemd-612caa2626ba898708f4b8a2bdbb6c1014e84d63.tar.xz
systemd-612caa2626ba898708f4b8a2bdbb6c1014e84d63.zip
network: dhcp6: request DNS servers or friends only when they will be used
Diffstat (limited to 'src/network/networkd-dhcp6.c')
-rw-r--r--src/network/networkd-dhcp6.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index d4b61ad79e..16014dbaff 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -622,6 +622,29 @@ static int dhcp6_configure(Link *link) {
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to set MUD URL: %m");
}
+ if (link->network->dhcp6_use_dns) {
+ r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_DNS_SERVER);
+ if (r < 0)
+ return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request DNS servers: %m");
+ }
+
+ if (link->network->dhcp6_use_domains > 0) {
+ r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_DOMAIN);
+ if (r < 0)
+ return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request domains: %m");
+ }
+
+ if (link->network->dhcp6_use_ntp) {
+ r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_NTP_SERVER);
+ if (r < 0)
+ return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request NTP servers: %m");
+
+ /* If the server does not provide NTP servers, then we fallback to use SNTP servers. */
+ r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_SNTP_SERVER);
+ if (r < 0)
+ return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request SNTP servers: %m");
+ }
+
SET_FOREACH(request_options, link->network->dhcp6_request_options) {
uint32_t option = PTR_TO_UINT32(request_options);