summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-03-13 20:46:45 +0100
committerTom Gundersen <teg@jklm.no>2014-03-14 12:44:17 +0100
commit06f021a8048583d66202e3ac5cd0a12386d33ac2 (patch)
tree407112a3da562091ca371ebd1cff2e9f5bf3faf8
parent0ea51a1129b9984a3c6d96cef1b0e33c99b5e9cf (diff)
networkd: allow more than one static DNS server
-rw-r--r--man/systemd.network.xml4
-rw-r--r--src/network/networkd-address.c4
-rw-r--r--src/network/networkd-manager.c15
-rw-r--r--src/network/networkd-network.c10
-rw-r--r--src/network/networkd.h4
5 files changed, 27 insertions, 10 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 4118fc9b65..7609128f3f 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -221,8 +221,8 @@
<term><varname>DNS=</varname></term>
<listitem>
<para>A DNS server address, which must be in the format described in
- <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
- .</para>
+ <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
+ This option may be specified repeatedly.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index c92418967b..414b3bccfa 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -225,7 +225,7 @@ int config_parse_dns(const char *unit,
const char *rvalue,
void *data,
void *userdata) {
- Address **dns = data;
+ Set **dns = data;
_cleanup_address_free_ Address *n = NULL;
int r;
@@ -246,7 +246,7 @@ int config_parse_dns(const char *unit,
return 0;
}
- *dns = n;
+ set_put(*dns, n);
n = NULL;
return 0;
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 8c2f5efbd3..c730e7148d 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -442,10 +442,17 @@ int manager_update_resolv_conf(Manager *m) {
}
}
- HASHMAP_FOREACH(link, m->links, i)
- if (link->network && link->network->dns)
- append_dns(f, &link->network->dns->in_addr.in,
- link->network->dns->family, &count);
+ HASHMAP_FOREACH(link, m->links, i) {
+ if (link->network && link->network->dns) {
+ Address *address;
+ Iterator j;
+
+ SET_FOREACH(address, link->network->dns, j) {
+ append_dns(f, &address->in_addr.in,
+ address->family, &count);
+ }
+ }
+ }
fflush(f);
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 6437ff4230..6e9915b75d 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -69,6 +69,10 @@ static int network_load_one(Manager *manager, const char *filename) {
if (!network->routes_by_section)
return log_oom();
+ network->dns = set_new(NULL, NULL);
+ if (!network->dns)
+ return log_oom();
+
network->filename = strdup(filename);
if (!network->filename)
return log_oom();
@@ -136,6 +140,7 @@ int network_load(Manager *manager) {
void network_free(Network *network) {
Route *route;
Address *address;
+ Iterator i;
if (!network)
return;
@@ -150,7 +155,10 @@ void network_free(Network *network) {
free(network->description);
- address_free(network->dns);
+ SET_FOREACH(address, network->dns, i)
+ address_free(address);
+
+ set_free(network->dns);
hashmap_free(network->vlans);
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 0c0171993d..311350c1e2 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -33,6 +33,7 @@
#include "rtnl-util.h"
#include "hashmap.h"
#include "list.h"
+#include "set.h"
#include "condition-util.h"
typedef struct NetDev NetDev;
@@ -130,11 +131,12 @@ struct Network {
LIST_HEAD(Address, static_addresses);
LIST_HEAD(Route, static_routes);
- Address *dns;
Hashmap *addresses_by_section;
Hashmap *routes_by_section;
+ Set *dns;
+
LIST_FIELDS(Network, networks);
};