summaryrefslogtreecommitdiff
path: root/src/resolve
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-04 23:08:03 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-04 23:08:03 +0200
commit19b50b5ba7ee8c1bfb330377309e4bab7a7531d8 (patch)
tree07291bc727cc5d50fa04dcf0d1d79112e3ac8539 /src/resolve
parentb3df0b34c14ffdaf8f2d72c08ff59da14cd6f7d7 (diff)
resolved: read the per-interface LLMNR setting from networkd and act on it
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/resolved-link.c37
-rw-r--r--src/resolve/resolved-link.h2
-rw-r--r--src/resolve/resolved-manager.h17
3 files changed, 46 insertions, 10 deletions
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index 2c02f09473..e1cdd6091d 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -42,6 +42,7 @@ int link_new(Manager *m, Link **ret, int ifindex) {
return -ENOMEM;
l->ifindex = ifindex;
+ l->llmnr_support = SUPPORT_YES;
r = hashmap_put(m->links, INT_TO_PTR(ifindex), l);
if (r < 0)
@@ -92,7 +93,7 @@ static void link_allocate_scopes(Link *l) {
} else
l->unicast_scope = dns_scope_free(l->unicast_scope);
- if (link_relevant(l, AF_INET) && l->manager->llmnr_support != SUPPORT_NO) {
+ if (link_relevant(l, AF_INET) && l->llmnr_support != SUPPORT_NO && l->manager->llmnr_support != SUPPORT_NO) {
if (!l->llmnr_ipv4_scope) {
r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
if (r < 0)
@@ -101,7 +102,7 @@ static void link_allocate_scopes(Link *l) {
} else
l->llmnr_ipv4_scope = dns_scope_free(l->llmnr_ipv4_scope);
- if (link_relevant(l, AF_INET6) && l->manager->llmnr_support != SUPPORT_NO) {
+ if (link_relevant(l, AF_INET6) && l->llmnr_support != SUPPORT_NO && l->manager->llmnr_support != SUPPORT_NO) {
if (!l->llmnr_ipv6_scope) {
r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
if (r < 0)
@@ -188,10 +189,40 @@ clear:
return r;
}
+static int link_update_llmnr_support(Link *l) {
+ _cleanup_free_ char *b = NULL;
+ int r;
+
+ assert(l);
+
+ r = sd_network_get_llmnr(l->ifindex, &b);
+ if (r < 0)
+ goto clear;
+
+ r = parse_boolean(b);
+ if (r < 0) {
+ if (streq(b, "resolve"))
+ l->llmnr_support = SUPPORT_RESOLVE;
+ else
+ goto clear;
+
+ } else if (r > 0)
+ l->llmnr_support = SUPPORT_YES;
+ else
+ l->llmnr_support = SUPPORT_NO;
+
+ return 0;
+
+clear:
+ l->llmnr_support = SUPPORT_YES;
+ return r;
+}
+
int link_update_monitor(Link *l) {
assert(l);
link_update_dns_servers(l);
+ link_update_llmnr_support(l);
link_allocate_scopes(l);
link_add_rrs(l, false);
@@ -353,6 +384,7 @@ void link_address_add_rrs(LinkAddress *a, bool force_remove) {
if (!force_remove &&
link_address_relevant(a) &&
a->link->llmnr_ipv4_scope &&
+ a->link->llmnr_support == SUPPORT_YES &&
a->link->manager->llmnr_support == SUPPORT_YES) {
if (!a->link->manager->host_ipv4_key) {
@@ -409,6 +441,7 @@ void link_address_add_rrs(LinkAddress *a, bool force_remove) {
if (!force_remove &&
link_address_relevant(a) &&
a->link->llmnr_ipv6_scope &&
+ a->link->llmnr_support == SUPPORT_YES &&
a->link->manager->llmnr_support == SUPPORT_YES) {
if (!a->link->manager->host_ipv6_key) {
diff --git a/src/resolve/resolved-link.h b/src/resolve/resolved-link.h
index 38bb392710..af9a8ab365 100644
--- a/src/resolve/resolved-link.h
+++ b/src/resolve/resolved-link.h
@@ -59,6 +59,8 @@ struct Link {
LIST_HEAD(DnsServer, dns_servers);
DnsServer *current_dns_server;
+ Support llmnr_support;
+
DnsScope *unicast_scope;
DnsScope *llmnr_ipv4_scope;
DnsScope *llmnr_ipv6_scope;
diff --git a/src/resolve/resolved-manager.h b/src/resolve/resolved-manager.h
index 1fd4be41a4..9d824e1751 100644
--- a/src/resolve/resolved-manager.h
+++ b/src/resolve/resolved-manager.h
@@ -30,20 +30,21 @@
#include "hashmap.h"
typedef struct Manager Manager;
+typedef enum Support Support;
-#include "resolved-dns-query.h"
-#include "resolved-dns-server.h"
-#include "resolved-dns-scope.h"
-#include "resolved-dns-stream.h"
-#include "resolved-link.h"
-
-typedef enum Support {
+enum Support {
SUPPORT_NO,
SUPPORT_YES,
SUPPORT_RESOLVE,
_SUPPORT_MAX,
_SUPPORT_INVALID = -1
-} Support;
+};
+
+#include "resolved-dns-query.h"
+#include "resolved-dns-server.h"
+#include "resolved-dns-scope.h"
+#include "resolved-dns-stream.h"
+#include "resolved-link.h"
struct Manager {
sd_event *event;