resolved: read the per-interface LLMNR setting from networkd and act on it
This commit is contained in:
parent
b3df0b34c1
commit
19b50b5ba7
|
@ -42,6 +42,7 @@ int link_new(Manager *m, Link **ret, int ifindex) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
l->ifindex = ifindex;
|
l->ifindex = ifindex;
|
||||||
|
l->llmnr_support = SUPPORT_YES;
|
||||||
|
|
||||||
r = hashmap_put(m->links, INT_TO_PTR(ifindex), l);
|
r = hashmap_put(m->links, INT_TO_PTR(ifindex), l);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -92,7 +93,7 @@ static void link_allocate_scopes(Link *l) {
|
||||||
} else
|
} else
|
||||||
l->unicast_scope = dns_scope_free(l->unicast_scope);
|
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) {
|
if (!l->llmnr_ipv4_scope) {
|
||||||
r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
|
r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -101,7 +102,7 @@ static void link_allocate_scopes(Link *l) {
|
||||||
} else
|
} else
|
||||||
l->llmnr_ipv4_scope = dns_scope_free(l->llmnr_ipv4_scope);
|
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) {
|
if (!l->llmnr_ipv6_scope) {
|
||||||
r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
|
r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -188,10 +189,40 @@ clear:
|
||||||
return r;
|
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) {
|
int link_update_monitor(Link *l) {
|
||||||
assert(l);
|
assert(l);
|
||||||
|
|
||||||
link_update_dns_servers(l);
|
link_update_dns_servers(l);
|
||||||
|
link_update_llmnr_support(l);
|
||||||
link_allocate_scopes(l);
|
link_allocate_scopes(l);
|
||||||
link_add_rrs(l, false);
|
link_add_rrs(l, false);
|
||||||
|
|
||||||
|
@ -353,6 +384,7 @@ void link_address_add_rrs(LinkAddress *a, bool force_remove) {
|
||||||
if (!force_remove &&
|
if (!force_remove &&
|
||||||
link_address_relevant(a) &&
|
link_address_relevant(a) &&
|
||||||
a->link->llmnr_ipv4_scope &&
|
a->link->llmnr_ipv4_scope &&
|
||||||
|
a->link->llmnr_support == SUPPORT_YES &&
|
||||||
a->link->manager->llmnr_support == SUPPORT_YES) {
|
a->link->manager->llmnr_support == SUPPORT_YES) {
|
||||||
|
|
||||||
if (!a->link->manager->host_ipv4_key) {
|
if (!a->link->manager->host_ipv4_key) {
|
||||||
|
@ -409,6 +441,7 @@ void link_address_add_rrs(LinkAddress *a, bool force_remove) {
|
||||||
if (!force_remove &&
|
if (!force_remove &&
|
||||||
link_address_relevant(a) &&
|
link_address_relevant(a) &&
|
||||||
a->link->llmnr_ipv6_scope &&
|
a->link->llmnr_ipv6_scope &&
|
||||||
|
a->link->llmnr_support == SUPPORT_YES &&
|
||||||
a->link->manager->llmnr_support == SUPPORT_YES) {
|
a->link->manager->llmnr_support == SUPPORT_YES) {
|
||||||
|
|
||||||
if (!a->link->manager->host_ipv6_key) {
|
if (!a->link->manager->host_ipv6_key) {
|
||||||
|
|
|
@ -59,6 +59,8 @@ struct Link {
|
||||||
LIST_HEAD(DnsServer, dns_servers);
|
LIST_HEAD(DnsServer, dns_servers);
|
||||||
DnsServer *current_dns_server;
|
DnsServer *current_dns_server;
|
||||||
|
|
||||||
|
Support llmnr_support;
|
||||||
|
|
||||||
DnsScope *unicast_scope;
|
DnsScope *unicast_scope;
|
||||||
DnsScope *llmnr_ipv4_scope;
|
DnsScope *llmnr_ipv4_scope;
|
||||||
DnsScope *llmnr_ipv6_scope;
|
DnsScope *llmnr_ipv6_scope;
|
||||||
|
|
|
@ -30,6 +30,15 @@
|
||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
|
|
||||||
typedef struct Manager Manager;
|
typedef struct Manager Manager;
|
||||||
|
typedef enum Support Support;
|
||||||
|
|
||||||
|
enum Support {
|
||||||
|
SUPPORT_NO,
|
||||||
|
SUPPORT_YES,
|
||||||
|
SUPPORT_RESOLVE,
|
||||||
|
_SUPPORT_MAX,
|
||||||
|
_SUPPORT_INVALID = -1
|
||||||
|
};
|
||||||
|
|
||||||
#include "resolved-dns-query.h"
|
#include "resolved-dns-query.h"
|
||||||
#include "resolved-dns-server.h"
|
#include "resolved-dns-server.h"
|
||||||
|
@ -37,14 +46,6 @@ typedef struct Manager Manager;
|
||||||
#include "resolved-dns-stream.h"
|
#include "resolved-dns-stream.h"
|
||||||
#include "resolved-link.h"
|
#include "resolved-link.h"
|
||||||
|
|
||||||
typedef enum Support {
|
|
||||||
SUPPORT_NO,
|
|
||||||
SUPPORT_YES,
|
|
||||||
SUPPORT_RESOLVE,
|
|
||||||
_SUPPORT_MAX,
|
|
||||||
_SUPPORT_INVALID = -1
|
|
||||||
} Support;
|
|
||||||
|
|
||||||
struct Manager {
|
struct Manager {
|
||||||
sd_event *event;
|
sd_event *event;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue