summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-25 22:27:01 +0100
committerLennart Poettering <lennart@poettering.net>2016-01-26 14:42:04 +0100
commitb2a81c0b524fee0a1713720462b6db5c302c3933 (patch)
treea28283ab8ff6d682e279934780bb601a7967baf5 /src/network/networkd-link.c
parent27cb34f57458758ee8615d72c6a60a39d4b92226 (diff)
networkd: optinally use DHCP lease domain info for routing only
This changes the UseDomains= setting of .network files to take an optional third value "route", in addition to the boolean values. If set, the passed domain information is used for routing rules only, but not for the search path logic.
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index b0e0c4f9e7..bf13544dbc 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -2731,6 +2731,8 @@ int link_save(Link *link) {
if (link->network) {
bool space;
sd_dhcp6_lease *dhcp6_lease = NULL;
+ const char *dhcp_domainname = NULL;
+ char **dhcp6_domains = NULL;
if (link->dhcp6_client) {
r = sd_dhcp6_client_get_lease(link->dhcp6_client, &dhcp6_lease);
@@ -2807,34 +2809,42 @@ int link_save(Link *link) {
fputc('\n', f);
- fputs("DOMAINS=", f);
- fputstrv(f, link->network->search_domains, NULL, &space);
-
- if (link->network->dhcp_use_domains &&
- link->dhcp_lease) {
- const char *domainname;
+ 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);
- r = sd_dhcp_lease_get_domainname(link->dhcp_lease, &domainname);
- if (r >= 0) {
- if (space)
- fputc(' ', f);
- fputs(domainname, f);
- space = true;
- }
+ if (dhcp6_lease)
+ (void) sd_dhcp6_lease_get_domains(dhcp6_lease, &dhcp6_domains);
}
- if (link->network->dhcp_use_domains && dhcp6_lease) {
- char **domains;
+ fputs("DOMAINS=", f);
+ fputstrv(f, link->network->search_domains, NULL, &space);
- r = sd_dhcp6_lease_get_domains(dhcp6_lease, &domains);
- if (r >= 0)
- fputstrv(f, domains, NULL, &space);
+ if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_YES && dhcp_domainname) {
+ if (space)
+ fputc(' ', f);
+ fputs(dhcp_domainname, f);
+ space = true;
}
+ if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_YES && dhcp6_domains)
+ fputstrv(f, dhcp6_domains, NULL, &space);
+
fputc('\n', f);
fputs("ROUTE_DOMAINS=", f);
fputstrv(f, link->network->route_domains, NULL, NULL);
+
+ if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_ROUTE && dhcp_domainname) {
+ if (space)
+ fputc(' ', f);
+ fputs(dhcp_domainname, f);
+ space = true;
+ }
+
+ if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_ROUTE && dhcp6_domains)
+ fputstrv(f, dhcp6_domains, NULL, &space);
+
fputc('\n', f);
fprintf(f, "LLMNR=%s\n",