mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
networkd: allow more than one static DNS server
This commit is contained in:
parent
0ea51a1129
commit
06f021a804
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue