summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c16
-rw-r--r--src/network/networkd-network-gperf.gperf1
-rw-r--r--src/network/networkd-network.c28
-rw-r--r--src/network/networkd.h13
4 files changed, 55 insertions, 3 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 9eb2e89091..d25343ba2b 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1722,6 +1722,7 @@ int link_save(Link *link) {
if (link->network) {
char **address;
+ char **domain;
fputs("DNS=", f);
@@ -1763,15 +1764,26 @@ int link_save(Link *link) {
fputs("\n", f);
+ fprintf(f, "DOMAINS=");
+
if (link->network->dhcp_domains &&
link->dhcp_lease) {
const char *domainname;
r = sd_dhcp_lease_get_domainname(link->dhcp_lease, &domainname);
- if (r >= 0)
- fprintf(f, "DOMAINS=%s\n", domainname);
+ if (r >= 0) {
+ fputs(domainname, f);
+ if (link->network->domains)
+ fputs(" ", f);
+ }
}
+ STRV_FOREACH(domain, link->network->domains)
+ fprintf(f, "%s%s", *domain,
+ (domain + 1 ? " " : ""));
+
+ fputs("\n", f);
+
fprintf(f, "LLMNR=%s\n",
llmnr_support_to_string(link->network->llmnr));
}
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 9cd7a4aa61..c5b9614a2b 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -37,6 +37,7 @@ Network.IPv4LL, config_parse_bool, 0,
Network.IPv4LLRoute, config_parse_bool, 0, offsetof(Network, ipv4ll_route)
Network.Address, config_parse_address, 0, 0
Network.Gateway, config_parse_gateway, 0, 0
+Network.Domains, config_parse_domains, 0, offsetof(Network, domains)
Network.DNS, config_parse_strv, 0, offsetof(Network, dns)
Network.LLMNR, config_parse_llmnr, 0, offsetof(Network, llmnr)
Network.NTP, config_parse_strv, 0, offsetof(Network, ntp)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index e13e4a0f62..bbc5d279e9 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -341,6 +341,34 @@ int config_parse_netdev(const char *unit,
return 0;
}
+int config_parse_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) {
+ char ***domains = data;
+ char **domain;
+ int r;
+
+ r = config_parse_strv(unit, filename, line, section, section_line,
+ lvalue, ltype, rvalue, domains, userdata);
+ if (r < 0)
+ return r;
+
+ strv_uniq(*domains);
+
+ STRV_FOREACH(domain, *domains)
+ if (is_localhost(*domain) || !hostname_is_valid(*domain))
+ strv_remove(*domains, *domain);
+
+ return 0;
+}
+
int config_parse_tunnel(const char *unit,
const char *filename,
unsigned line,
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 90e798dbf5..a9867d9e7f 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -111,7 +111,7 @@ struct Network {
Hashmap *addresses_by_section;
Hashmap *routes_by_section;
- char **dns, **ntp;
+ char **domains, **dns, **ntp;
LLMNRSupport llmnr;
@@ -224,6 +224,17 @@ int config_parse_netdev(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);
+int config_parse_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);
+
int config_parse_tunnel(const char *unit,
const char *filename,
unsigned line,