summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorDaniel Wang <wonderfly@users.noreply.github.com>2017-05-13 07:19:32 -0700
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-05-13 10:19:32 -0400
commitb85bc551c3cbd26b03c79c8d416389e7ac501760 (patch)
treea5b129384f9606bc612d5d23c91a59cf5f8b6350 /src/network
parent6e4177315f632e03afea43b6d99100bd434f3403 (diff)
downloadsystemd-b85bc551c3cbd26b03c79c8d416389e7ac501760.tar.gz
systemd-b85bc551c3cbd26b03c79c8d416389e7ac501760.tar.bz2
systemd-b85bc551c3cbd26b03c79c8d416389e7ac501760.zip
network: Implement DHCP Option 119 (Domain Search List) (#5932)
This adds a modified version of dhcp6_option_parse_domainname() that is able to parse compressed domain names, borrowing the idea from dns_packet_read_name(). It also adds pieces in networkd-link and networkd-manager to properly save/load the added option field. Resolves #2710.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c13
-rw-r--r--src/network/networkd-manager.c15
2 files changed, 21 insertions, 7 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 6ed8380942..37bebcf191 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -3266,6 +3266,7 @@ int link_save(Link *link) {
sd_dhcp6_lease *dhcp6_lease = NULL;
const char *dhcp_domainname = NULL;
char **dhcp6_domains = NULL;
+ char **dhcp_domains = NULL;
unsigned j;
if (link->dhcp6_client) {
@@ -3375,13 +3376,16 @@ int link_save(Link *link) {
fputc('\n', f);
if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO) {
- if (link->dhcp_lease)
+ 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 (dhcp6_lease)
(void) sd_dhcp6_lease_get_domains(dhcp6_lease, &dhcp6_domains);
}
fputs("DOMAINS=", f);
+ space = false;
fputstrv(f, link->network->search_domains, NULL, &space);
if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_YES) {
@@ -3389,6 +3393,8 @@ int link_save(Link *link) {
if (dhcp_domainname)
fputs_with_space(f, dhcp_domainname, NULL, &space);
+ if (dhcp_domains)
+ fputstrv(f, dhcp_domains, NULL, &space);
if (dhcp6_domains)
fputstrv(f, dhcp6_domains, NULL, &space);
@@ -3399,13 +3405,16 @@ int link_save(Link *link) {
fputc('\n', f);
fputs("ROUTE_DOMAINS=", f);
- fputstrv(f, link->network->route_domains, NULL, NULL);
+ space = false;
+ fputstrv(f, link->network->route_domains, NULL, &space);
if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_ROUTE) {
NDiscDNSSL *dd;
if (dhcp_domainname)
fputs_with_space(f, dhcp_domainname, NULL, &space);
+ if (dhcp_domains)
+ fputstrv(f, dhcp_domains, NULL, &space);
if (dhcp6_domains)
fputstrv(f, dhcp6_domains, NULL, &space);
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index ea1c320809..5f10b4f993 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -961,15 +961,20 @@ static int manager_save(Manager *m) {
if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO) {
const char *domainname;
+ char **domains = NULL;
+ OrderedSet *target_domains = (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_YES) ? search_domains : route_domains;
r = sd_dhcp_lease_get_domainname(link->dhcp_lease, &domainname);
if (r >= 0) {
+ r = ordered_set_put_strdup(target_domains, domainname);
+ if (r < 0)
+ return r;
+ } else if (r != -ENODATA)
+ return r;
- if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_YES)
- r = ordered_set_put_strdup(search_domains, domainname);
- else
- r = ordered_set_put_strdup(route_domains, domainname);
-
+ r = sd_dhcp_lease_get_search_domains(link->dhcp_lease, &domains);
+ if (r >= 0) {
+ r = ordered_set_put_strdupv(target_domains, domains);
if (r < 0)
return r;
} else if (r != -ENODATA)