summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd/sd-network/sd-network.c19
-rw-r--r--src/network/networkctl.c7
-rw-r--r--src/network/networkd-link.c3
-rw-r--r--src/network/networkd-network.c6
-rw-r--r--src/network/networkd.h1
-rw-r--r--src/systemd/sd-network.h4
6 files changed, 40 insertions, 0 deletions
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
index 4d8b7e7b2c..e30fc3cbf4 100644
--- a/src/libsystemd/sd-network/sd-network.c
+++ b/src/libsystemd/sd-network/sd-network.c
@@ -210,6 +210,25 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) {
return network_get_link_strv("DOMAINS", ifindex, ret);
}
+_public_ int sd_network_link_get_wildcard_domain(int ifindex) {
+ int r;
+ _cleanup_free_ char *p = NULL, *s = NULL;
+
+ assert_return(ifindex > 0, -EINVAL);
+
+ if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0)
+ return -ENOMEM;
+
+ r = parse_env_file(p, NEWLINE, "WILDCARD_DOMAIN", &s, NULL);
+ if (r < 0)
+ return r;
+
+ if (!s)
+ return -EIO;
+
+ return parse_boolean(s);
+}
+
static inline int MONITOR_TO_FD(sd_network_monitor *m) {
return (int) (unsigned long) m - 1;
}
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 33fe8bfc61..bf95aa2c90 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -366,6 +366,13 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
sd_network_link_get_dns(ifindex, &dns);
sd_network_link_get_ntp(ifindex, &ntp);
sd_network_link_get_domains(ifindex, &domains);
+ r = sd_network_link_get_wildcard_domain(ifindex);
+ if (r > 0) {
+ char *wildcard;
+
+ wildcard = strdup("*");
+ strv_push(&domains, wildcard);
+ }
sprintf(devid, "n%i", ifindex);
d = udev_device_new_from_device_id(udev, devid);
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index d25343ba2b..76e642758d 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1784,6 +1784,9 @@ int link_save(Link *link) {
fputs("\n", f);
+ fprintf(f, "WILDCARD_DOMAIN=%s\n",
+ yes_no(link->network->wildcard_domain));
+
fprintf(f, "LLMNR=%s\n",
llmnr_support_to_string(link->network->llmnr));
}
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index bbc5d279e9..f3b2c68430 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -351,6 +351,7 @@ int config_parse_domains(const char *unit,
const char *rvalue,
void *data,
void *userdata) {
+ Network *network = userdata;
char ***domains = data;
char **domain;
int r;
@@ -362,6 +363,11 @@ int config_parse_domains(const char *unit,
strv_uniq(*domains);
+ if (strv_isempty(*domains))
+ network->wildcard_domain = false;
+ else if (strv_find(*domains, "*"))
+ network->wildcard_domain = true;
+
STRV_FOREACH(domain, *domains)
if (is_localhost(*domain) || !hostname_is_valid(*domain))
strv_remove(*domains, *domain);
diff --git a/src/network/networkd.h b/src/network/networkd.h
index a9867d9e7f..c8d89d212b 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -111,6 +111,7 @@ struct Network {
Hashmap *addresses_by_section;
Hashmap *routes_by_section;
+ bool wildcard_domain;
char **domains, **dns, **ntp;
LLMNRSupport llmnr;
diff --git a/src/systemd/sd-network.h b/src/systemd/sd-network.h
index db785077ff..52e398a08d 100644
--- a/src/systemd/sd-network.h
+++ b/src/systemd/sd-network.h
@@ -107,6 +107,10 @@ int sd_network_link_get_llmnr(int ifindex, char **llmnr);
/* Get the DNS domain names for a given link. */
int sd_network_link_get_domains(int ifindex, char ***domains);
+/* Returns whether or not domains that don't match any link should be resolved
+ * on this link. 1 for yes, 0 for no and negative value for error */
+int sd_network_link_get_wildcard_domain(int ifindex);
+
/* Monitor object */
typedef struct sd_network_monitor sd_network_monitor;