resolved-link.c revision 8bea3d6f887e336295a9cc24169f329c05f7383f
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering/***
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering This file is part of systemd.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Copyright 2014 Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is free software; you can redistribute it and/or modify it
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering under the terms of the GNU Lesser General Public License as published by
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering (at your option) any later version.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is distributed in the hope that it will be useful, but
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Lesser General Public License for more details.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering You should have received a copy of the GNU Lesser General Public License
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering***/
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
8bdbb8d9cbe1d35708385573d70984ab4533812dLennart Poettering#include <net/if.h>
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering#include "sd-network.h"
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering#include "strv.h"
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering#include "resolved-link.h"
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering/* RFC 4795 Section 2.8. suggests a TTL of 30s by default */
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering#define LLMNR_DEFAULT_TTL (30)
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poetteringstatic void link_address_add_rrs(LinkAddress *a);
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering
785890acf6d629ff881a1f065f431df1b7fc8c7aLennart Poetteringint link_new(Manager *m, Link **ret, int ifindex) {
f2cbe59e113f08549949a76ac5b9b3972df4cc30Lennart Poettering _cleanup_(link_freep) Link *l = NULL;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering int r;
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering assert(m);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering assert(ifindex > 0);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering r = hashmap_ensure_allocated(&m->links, NULL, NULL);
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen if (r < 0)
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen return r;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering l = new0(Link, 1);
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (!l)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return -ENOMEM;
9d12709626bccc0cae677a7035f62efe6aabb4abLennart Poettering
04d39279245834494baccfdb9349db8bf80abd13Lennart Poettering l->ifindex = ifindex;
023fb90b83871a15ef7f57e8cd126e3426f99b9eLennart Poettering
785890acf6d629ff881a1f065f431df1b7fc8c7aLennart Poettering r = hashmap_put(m->links, INT_TO_PTR(ifindex), l);
785890acf6d629ff881a1f065f431df1b7fc8c7aLennart Poettering if (r < 0)
f2cbe59e113f08549949a76ac5b9b3972df4cc30Lennart Poettering return r;
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering l->manager = m;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering if (ret)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering *ret = l;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering l = NULL;
e56056e93d33619a3acf13e483900b4f8938228fThomas Hindoe Paaboel Andersen
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return 0;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering}
d21ed1ead18d16d35c30299a69d3366847f8a039Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart PoetteringLink *link_free(Link *l) {
785890acf6d629ff881a1f065f431df1b7fc8c7aLennart Poettering
785890acf6d629ff881a1f065f431df1b7fc8c7aLennart Poettering if (!l)
d8f52ed25a9edce75fda5251c977b7898e33887eLennart Poettering return NULL;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering while (l->addresses)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering link_address_free(l->addresses);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering if (l->manager)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering hashmap_remove(l->manager->links, INT_TO_PTR(l->ifindex));
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering dns_scope_free(l->unicast_scope);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering dns_scope_free(l->llmnr_ipv4_scope);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering dns_scope_free(l->llmnr_ipv6_scope);
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering while (l->dns_servers)
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen dns_server_free(l->dns_servers);
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen free(l);
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering return NULL;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering}
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poetteringstatic void link_allocate_scopes(Link *l) {
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering int r;
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering assert(l);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen if (l->dns_servers) {
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen if (!l->unicast_scope) {
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen r = dns_scope_new(l->manager, &l->unicast_scope, l, DNS_PROTOCOL_DNS, AF_UNSPEC);
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen if (r < 0)
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen log_warning("Failed to allocate DNS scope: %s", strerror(-r));
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen }
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen } else
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen l->unicast_scope = dns_scope_free(l->unicast_scope);
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen if (link_relevant(l, AF_INET) && (l->flags & IFF_MULTICAST) && l->manager->use_llmnr) {
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen if (!l->llmnr_ipv4_scope) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering if (r < 0)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering log_warning("Failed to allocate LLMNR IPv4 scope: %s", strerror(-r));
e56056e93d33619a3acf13e483900b4f8938228fThomas Hindoe Paaboel Andersen }
e56056e93d33619a3acf13e483900b4f8938228fThomas Hindoe Paaboel Andersen } else
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering l->llmnr_ipv4_scope = dns_scope_free(l->llmnr_ipv4_scope);
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen if (link_relevant(l, AF_INET6) && (l->flags & IFF_MULTICAST) && l->manager->use_llmnr) {
5b30bef856e89a571df57b7b953e9a1409d9acedLennart Poettering if (!l->llmnr_ipv6_scope) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen if (r < 0)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering log_warning("Failed to allocate LLMNR IPv6 scope: %s", strerror(-r));
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering }
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering } else
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering l->llmnr_ipv6_scope = dns_scope_free(l->llmnr_ipv6_scope);
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen}
5b30bef856e89a571df57b7b953e9a1409d9acedLennart Poettering
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersenstatic void link_add_rrs(Link *l) {
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen LinkAddress *a;
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen
5b30bef856e89a571df57b7b953e9a1409d9acedLennart Poettering LIST_FOREACH(addresses, a, l->addresses)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering link_address_add_rrs(a);
e56056e93d33619a3acf13e483900b4f8938228fThomas Hindoe Paaboel Andersen}
e56056e93d33619a3acf13e483900b4f8938228fThomas Hindoe Paaboel Andersen
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poetteringint link_update_rtnl(Link *l, sd_rtnl_message *m) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering const char *n = NULL;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering int r;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering assert(l);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering assert(m);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering r = sd_rtnl_message_link_get_flags(m, &l->flags);
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering if (r < 0)
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering return r;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering sd_rtnl_message_read_u32(m, IFLA_MTU, &l->mtu);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (sd_rtnl_message_read_string(m, IFLA_IFNAME, &n) >= 0) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering strncpy(l->name, n, sizeof(l->name));
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering char_array_0(l->name);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering }
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering link_allocate_scopes(l);
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering link_add_rrs(l);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering return 0;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering}
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poetteringstatic int link_update_dns_servers(Link *l) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering _cleanup_strv_free_ char **nameservers = NULL;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering char **nameserver;
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering DnsServer *s, *nx;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering int r;
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering assert(l);
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering LIST_FOREACH(servers, s, l->dns_servers)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering s->marked = true;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering r = sd_network_get_dns(l->ifindex, &nameservers);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (r < 0)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering goto clear;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering STRV_FOREACH(nameserver, nameservers) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering union in_addr_union a;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering int family;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering r = in_addr_from_string_auto(*nameserver, &family, &a);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (r < 0)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering goto clear;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering s = link_find_dns_server(l, family, &a);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (s)
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering s->marked = false;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering else {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering r = dns_server_new(l->manager, NULL, l, family, &a);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (r < 0)
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering goto clear;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering }
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering }
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering LIST_FOREACH_SAFE(servers, s, nx, l->dns_servers)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (s->marked)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering dns_server_free(s);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering return 0;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poetteringclear:
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering while (l->dns_servers)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering dns_server_free(l->dns_servers);
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering return r;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering}
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poetteringint link_update_monitor(Link *l) {
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering assert(l);
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering link_update_dns_servers(l);
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering link_allocate_scopes(l);
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering link_add_rrs(l);
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering return 0;
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering}
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poetteringbool link_relevant(Link *l, int family) {
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering _cleanup_free_ char *state = NULL;
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering LinkAddress *a;
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering assert(l);
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering /* A link is relevant if it isn't a loopback device and has at
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering * least one relevant IP address */
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (l->flags & IFF_LOOPBACK)
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering return false;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering sd_network_get_link_operational_state(l->ifindex, &state);
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering if (state && !STR_IN_SET(state, "unknown", "degraded", "routable"))
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering return false;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering LIST_FOREACH(addresses, a, l->addresses)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (a->family == family && link_address_relevant(a))
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering return true;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering return false;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering}
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart PoetteringLinkAddress *link_find_address(Link *l, int family, const union in_addr_union *in_addr) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering LinkAddress *a;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering assert(l);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering LIST_FOREACH(addresses, a, l->addresses)
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering if (a->family == family && in_addr_equal(family, &a->in_addr, in_addr))
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering return a;
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering return NULL;
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering}
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart PoetteringDnsServer* link_find_dns_server(Link *l, int family, const union in_addr_union *in_addr) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering DnsServer *s;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering
10f9c75519671e7c7ab8993b54fe22da7c2d0c38Lennart Poettering assert(l);
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering LIST_FOREACH(servers, s, l->dns_servers)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (s->family == family && in_addr_equal(family, &s->address, in_addr))
8937e7b68940d0fa0d0aab90eb7425fa7dccebc9Lennart Poettering return s;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering return NULL;
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering}
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart PoetteringDnsServer *link_get_dns_server(Link *l) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering assert(l);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (!l->current_dns_server)
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering l->current_dns_server = l->dns_servers;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering return l->current_dns_server;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering}
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poetteringvoid link_next_dns_server(Link *l) {
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen assert(l);
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering /* Switch to the next DNS server */
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (!l->current_dns_server) {
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering l->current_dns_server = l->dns_servers;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (l->current_dns_server)
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering return;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering }
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
d21ed1ead18d16d35c30299a69d3366847f8a039Lennart Poettering if (!l->current_dns_server)
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering return;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (l->current_dns_server->servers_next) {
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering l->current_dns_server = l->current_dns_server->servers_next;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering return;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering }
a7893c6b28772edbc7e1fea3c209caa54d465648Lennart Poettering
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering l->current_dns_server = l->dns_servers;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering}
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poetteringint link_address_new(Link *l, LinkAddress **ret, int family, const union in_addr_union *in_addr) {
a7893c6b28772edbc7e1fea3c209caa54d465648Lennart Poettering LinkAddress *a;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen assert(l);
a7893c6b28772edbc7e1fea3c209caa54d465648Lennart Poettering assert(in_addr);
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersen a = new0(LinkAddress, 1);
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (!a)
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering return -ENOMEM;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
a7893c6b28772edbc7e1fea3c209caa54d465648Lennart Poettering a->family = family;
5b30bef856e89a571df57b7b953e9a1409d9acedLennart Poettering a->in_addr = *in_addr;
5b30bef856e89a571df57b7b953e9a1409d9acedLennart Poettering
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering a->link = l;
9d12709626bccc0cae677a7035f62efe6aabb4abLennart Poettering LIST_PREPEND(addresses, l->addresses, a);
9d12709626bccc0cae677a7035f62efe6aabb4abLennart Poettering
9d12709626bccc0cae677a7035f62efe6aabb4abLennart Poettering if (ret)
9d12709626bccc0cae677a7035f62efe6aabb4abLennart Poettering *ret = a;
9d12709626bccc0cae677a7035f62efe6aabb4abLennart Poettering
9d12709626bccc0cae677a7035f62efe6aabb4abLennart Poettering return 0;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering}
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart PoetteringLinkAddress *link_address_free(LinkAddress *a) {
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (!a)
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering return NULL;
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (a->link) {
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering LIST_REMOVE(addresses, a->link->addresses, a);
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (a->llmnr_address_rr) {
9d12709626bccc0cae677a7035f62efe6aabb4abLennart Poettering
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering if (a->family == AF_INET && a->link->llmnr_ipv4_scope)
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_address_rr);
aa1936ea1a89c2bb968ba33e3274898a4eeae771Lennart Poettering else if (a->family == AF_INET6 && a->link->llmnr_ipv6_scope)
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv6_scope->zone, a->llmnr_address_rr);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering dns_resource_record_unref(a->llmnr_address_rr);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering }
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (a->llmnr_ptr_rr) {
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (a->family == AF_INET && a->link->llmnr_ipv4_scope)
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_ptr_rr);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering else if (a->family == AF_INET6 && a->link->llmnr_ipv6_scope)
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv6_scope->zone, a->llmnr_ptr_rr);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering dns_resource_record_unref(a->llmnr_ptr_rr);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering }
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering }
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering free(a);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering return NULL;
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering}
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poetteringstatic void link_address_add_rrs(LinkAddress *a) {
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering int r;
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering assert(a);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering if (a->family == AF_INET && a->link->llmnr_ipv4_scope) {
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (!a->link->manager->host_ipv4_key) {
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering a->link->manager->host_ipv4_key = dns_resource_key_new(DNS_CLASS_IN, DNS_TYPE_A, a->link->manager->hostname);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (!a->link->manager->host_ipv4_key) {
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering r = -ENOMEM;
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering goto fail;
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering }
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering }
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (!a->llmnr_address_rr) {
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering a->llmnr_address_rr = dns_resource_record_new(a->link->manager->host_ipv4_key);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (!a->llmnr_address_rr) {
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering r = -ENOMEM;
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering goto fail;
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering }
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering a->llmnr_address_rr->a.in_addr = a->in_addr.in;
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering a->llmnr_address_rr->ttl = LLMNR_DEFAULT_TTL;
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering }
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (!a->llmnr_ptr_rr) {
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering r = dns_resource_record_new_reverse(&a->llmnr_ptr_rr, a->family, &a->in_addr, a->link->manager->hostname);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (r < 0)
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering goto fail;
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering a->llmnr_ptr_rr->ttl = LLMNR_DEFAULT_TTL;
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering }
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (link_address_relevant(a)) {
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering r = dns_zone_put(&a->link->llmnr_ipv4_scope->zone, a->llmnr_address_rr);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (r < 0)
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering goto fail;
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering r = dns_zone_put(&a->link->llmnr_ipv4_scope->zone, a->llmnr_ptr_rr);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering if (r < 0)
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering goto fail;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering } else {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_address_rr);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_ptr_rr);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering }
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering }
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (a->family == AF_INET6 && a->link->llmnr_ipv6_scope) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (!a->link->manager->host_ipv6_key) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering a->link->manager->host_ipv6_key = dns_resource_key_new(DNS_CLASS_IN, DNS_TYPE_AAAA, a->link->manager->hostname);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (!a->link->manager->host_ipv6_key) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering r = -ENOMEM;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering goto fail;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering }
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering }
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (!a->llmnr_address_rr) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering a->llmnr_address_rr = dns_resource_record_new(a->link->manager->host_ipv6_key);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (!a->llmnr_address_rr) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering r = -ENOMEM;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering goto fail;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering }
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering a->llmnr_address_rr->aaaa.in6_addr = a->in_addr.in6;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering a->llmnr_address_rr->ttl = LLMNR_DEFAULT_TTL;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering }
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (!a->llmnr_ptr_rr) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering r = dns_resource_record_new_reverse(&a->llmnr_ptr_rr, a->family, &a->in_addr, a->link->manager->hostname);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (r < 0)
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering goto fail;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering a->llmnr_ptr_rr->ttl = LLMNR_DEFAULT_TTL;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering }
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (link_address_relevant(a)) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering r = dns_zone_put(&a->link->llmnr_ipv6_scope->zone, a->llmnr_address_rr);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (r < 0)
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering goto fail;
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering r = dns_zone_put(&a->link->llmnr_ipv6_scope->zone, a->llmnr_ptr_rr);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (r < 0)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering goto fail;
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers } else {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv6_scope->zone, a->llmnr_address_rr);
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers dns_zone_remove_rr(&a->link->llmnr_ipv6_scope->zone, a->llmnr_ptr_rr);
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers }
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poettering }
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poetteringfail:
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering log_debug("Failed to update address RRs: %s", strerror(-r));
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering}
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
a1da85830bfaa77b9eb9c54693e5573559c97e50Tom Gundersenint link_address_update_rtnl(LinkAddress *a, sd_rtnl_message *m) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering int r;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering assert(a);
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering assert(m);
f48e75cb9a8112d35855c44a156934f2ee0edb2eLennart Poettering
56159e0d918e9a9be07988133bb2847779325de0Lennart Poettering r = sd_rtnl_message_addr_get_flags(m, &a->flags);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering if (r < 0)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return r;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering sd_rtnl_message_addr_get_scope(m, &a->scope);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering link_allocate_scopes(a->link);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering link_add_rrs(a->link);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return 0;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering}
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poetteringbool link_address_relevant(LinkAddress *a) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering assert(a);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering if (a->flags & IFA_F_DEPRECATED)
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return false;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering if (IN_SET(a->scope, RT_SCOPE_HOST, RT_SCOPE_NOWHERE))
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return false;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return true;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering}
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering