summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-18 15:47:57 +0100
committerTom Gundersen <teg@jklm.no>2014-01-18 17:52:10 +0100
commit039ebe6aebaebcaa18375b33caf1db5fe2551621 (patch)
treeef0ed8c3ea7d598b3610948df5f64a2a23cc52e6 /src/network
parentbcbca8291fe3beaed36dd672d8b544840cfc49de (diff)
sd-dhcp-client/networkd: add domainname support
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-gperf.gperf1
-rw-r--r--src/network/networkd-manager.c19
-rw-r--r--src/network/networkd-network.c1
-rw-r--r--src/network/networkd.h1
4 files changed, 17 insertions, 5 deletions
diff --git a/src/network/networkd-gperf.gperf b/src/network/networkd-gperf.gperf
index 7686cdf334..abf6a30975 100644
--- a/src/network/networkd-gperf.gperf
+++ b/src/network/networkd-gperf.gperf
@@ -33,5 +33,6 @@ Route.Destination, config_parse_destination, 0, 0
DHCPv4.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns)
DHCPv4.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu)
DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname)
+DHCPv4.UseDomainName, config_parse_bool, 0, offsetof(Network, dhcp_domainname)
Bridge.Description, config_parse_string, 0, offsetof(Bridge, description)
Bridge.Name, config_parse_ifname, 0, offsetof(Bridge, name)
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index c630ed7ed9..5ab9ba0baf 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -325,6 +325,7 @@ int manager_update_resolv_conf(Manager *m) {
Link *link;
Iterator i;
unsigned count = 0;
+ const char *domainname = NULL;
int r;
assert(m);
@@ -350,12 +351,20 @@ int manager_update_resolv_conf(Manager *m) {
struct in_addr *nameservers;
size_t nameservers_size;
- r = sd_dhcp_client_get_dns(link->dhcp, &nameservers, &nameservers_size);
- if (r >= 0) {
- unsigned j;
+ if (link->network->dhcp_dns) {
+ r = sd_dhcp_client_get_dns(link->dhcp, &nameservers, &nameservers_size);
+ if (r >= 0) {
+ unsigned j;
- for (j = 0; j < nameservers_size; j++)
- append_dns(f, &nameservers[j], AF_INET, &count);
+ for (j = 0; j < nameservers_size; j++)
+ append_dns(f, &nameservers[j], AF_INET, &count);
+ }
+ }
+
+ if (link->network->dhcp_domainname && !domainname) {
+ r = sd_dhcp_client_get_domainname(link->dhcp, &domainname);
+ if (r >= 0)
+ fprintf(f, "domain %s\n", domainname);
}
}
}
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index ff54423221..b6b0c796d2 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -68,6 +68,7 @@ static int network_load_one(Manager *manager, const char *filename) {
network->dhcp_dns = true;
network->dhcp_mtu = true;
network->dhcp_hostname = true;
+ network->dhcp_domainname = true;
r = config_parse(NULL, filename, file, "Match\0Network\0Address\0Route\0DHCPv4\0", config_item_perf_lookup,
(void*) network_gperf_lookup, false, false, network);
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 89f4cf24e7..c684eb8a8f 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -89,6 +89,7 @@ struct Network {
bool dhcp_dns;
bool dhcp_mtu;
bool dhcp_hostname;
+ bool dhcp_domainname;
LIST_HEAD(Address, static_addresses);
LIST_HEAD(Route, static_routes);