[systemd-devel] [RFC PATCH] networkd: add 'search' to resolv.conf

Matthew Monaco matt at 0x01b.net
Sat Mar 29 14:04:11 PDT 2014


From: Matthew Monaco <matthew.monaco at 0x01b.net>

---
 man/systemd.network.xml                  | 6 ++++++
 src/network/networkd-manager.c           | 3 +++
 src/network/networkd-network-gperf.gperf | 1 +
 src/network/networkd-network.c           | 1 +
 src/network/networkd.h                   | 1 +
 5 files changed, 12 insertions(+)

diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index f3b3b31..c2dd145 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -229,6 +229,12 @@
                                         </listitem>
                                 </varlistentry>
                                 <varlistentry>
+                                        <term><varname>DNSSearch=</varname></term>
+                                        <listitem>
+                                                <para>A space separated list of search domains.</para>
+                                        </listitem>
+                                </varlistentry>
+                                <varlistentry>
                                         <term><varname>Bridge=</varname></term>
                                         <listitem>
                                                 <para>The name of the bridge to add the link to.</para>
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index b2cb0fa..893b997 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -447,6 +447,9 @@ int manager_update_resolv_conf(Manager *m) {
                                 append_dns(f, &address->in_addr.in,
                                            address->family, &count);
                         }
+
+                        if (link->network->dns_search)
+                                fprintf(f, "search %s\n", link->network->dns_search);
                 }
         }
 
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 6ba890f..6929cb6 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -34,6 +34,7 @@ Network.IPv4LL,              config_parse_bool,                  0,
 Network.Address,             config_parse_address,               0,                             0
 Network.Gateway,             config_parse_gateway,               0,                             0
 Network.DNS,                 config_parse_dns,                   0,                             offsetof(Network, dns)
+Network.DNSSearch,           config_parse_string,                0,                             offsetof(Network, dns_search)
 Address.Address,             config_parse_address,               0,                             0
 Address.Broadcast,           config_parse_broadcast,             0,                             0
 Address.Label,               config_parse_label,                 0,                             0
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 47fab4e..057f86a 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -159,6 +159,7 @@ void network_free(Network *network) {
                 address_free(address);
 
         set_free(network->dns);
+        free(network->dns_search);
 
         hashmap_free(network->vlans);
 
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 8144031..912ae90 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -136,6 +136,7 @@ struct Network {
         Hashmap *routes_by_section;
 
         Set *dns;
+        char *dns_search;
 
         LIST_FIELDS(Network, networks);
 };
-- 
1.9.1



More information about the systemd-devel mailing list