resolved-link.c revision 1ade96e980d3c0855a04140f4728b3ffd429bbea
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek This file is part of systemd.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek Copyright 2014 Lennart Poettering
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek (at your option) any later version.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekint link_new(Manager *m, Link **ret, int ifindex) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = hashmap_ensure_allocated(&m->links, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = hashmap_put(m->links, INT_TO_PTR(ifindex), l);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_server_unlink_marked(l->dns_servers);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_search_domain_unlink_all(l->search_domains);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek link_address_free(l->addresses);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek hashmap_remove(l->manager->links, INT_TO_PTR(l->ifindex));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_scope_free(l->unicast_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_scope_free(l->llmnr_ipv4_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_scope_free(l->llmnr_ipv6_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_scope_free(l->mdns_ipv4_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic void link_allocate_scopes(Link *l) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = dns_scope_new(l->manager, &l->unicast_scope, l, DNS_PROTOCOL_DNS, AF_UNSPEC);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to allocate DNS scope: %m");
670b110c3b59dfa335ac43065b2038400d1d04a9Zbigniew Jędrzejewski-Szmek l->unicast_scope = dns_scope_free(l->unicast_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (link_relevant(l, AF_INET) &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->llmnr_support != SUPPORT_NO &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->manager->llmnr_support != SUPPORT_NO) {
670b110c3b59dfa335ac43065b2038400d1d04a9Zbigniew Jędrzejewski-Szmek r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to allocate LLMNR IPv4 scope: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->llmnr_ipv4_scope = dns_scope_free(l->llmnr_ipv4_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (link_relevant(l, AF_INET6) &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->llmnr_support != SUPPORT_NO &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->manager->llmnr_support != SUPPORT_NO &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to allocate LLMNR IPv6 scope: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->llmnr_ipv6_scope = dns_scope_free(l->llmnr_ipv6_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (link_relevant(l, AF_INET) &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->mdns_support != SUPPORT_NO &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->manager->mdns_support != SUPPORT_NO) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = dns_scope_new(l->manager, &l->mdns_ipv4_scope, l, DNS_PROTOCOL_MDNS, AF_INET);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to allocate mDNS IPv4 scope: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->mdns_ipv4_scope = dns_scope_free(l->mdns_ipv4_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (link_relevant(l, AF_INET6) &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->mdns_support != SUPPORT_NO &&
0371ca0dac1d70b2e5060a3c4e6fbbc2bdbd8671Florian Weimer r = dns_scope_new(l->manager, &l->mdns_ipv6_scope, l, DNS_PROTOCOL_MDNS, AF_INET6);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to allocate mDNS IPv6 scope: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->mdns_ipv6_scope = dns_scope_free(l->mdns_ipv6_scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekvoid link_add_rrs(Link *l, bool force_remove) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek LIST_FOREACH(addresses, a, l->addresses)
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek link_address_add_rrs(a, force_remove);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekint link_update_rtnl(Link *l, sd_netlink_message *m) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek const char *n = NULL;
348ced909724a1331b85d57aede80a102a00e428Zbigniew Jędrzejewski-Szmek r = sd_rtnl_message_link_get_flags(m, &l->flags);
348ced909724a1331b85d57aede80a102a00e428Zbigniew Jędrzejewski-Szmek sd_netlink_message_read_u32(m, IFLA_MTU, &l->mtu);
348ced909724a1331b85d57aede80a102a00e428Zbigniew Jędrzejewski-Szmek if (sd_netlink_message_read_string(m, IFLA_IFNAME, &n) >= 0) {
348ced909724a1331b85d57aede80a102a00e428Zbigniew Jędrzejewski-Szmek strncpy(l->name, n, sizeof(l->name)-1);
348ced909724a1331b85d57aede80a102a00e428Zbigniew Jędrzejewski-Szmekstatic int link_update_dns_servers(Link *l) {
348ced909724a1331b85d57aede80a102a00e428Zbigniew Jędrzejewski-Szmek _cleanup_strv_free_ char **nameservers = NULL;
348ced909724a1331b85d57aede80a102a00e428Zbigniew Jędrzejewski-Szmek r = sd_network_link_get_dns(l->ifindex, &nameservers);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_server_mark_all(l->dns_servers);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek STRV_FOREACH(nameserver, nameservers) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = in_addr_from_string_auto(*nameserver, &family, &a);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek s = dns_server_find(l->dns_servers, family, &a);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = dns_server_new(l->manager, NULL, DNS_SERVER_LINK, l, family, &a);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_server_unlink_marked(l->dns_servers);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_server_unlink_all(l->dns_servers);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int link_update_llmnr_support(Link *l) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_network_link_get_llmnr(l->ifindex, &b);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l->llmnr_support = SUPPORT_RESOLVE;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek } else if (r > 0)
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int link_update_search_domains(Link *l) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_strv_free_ char **domains = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_network_link_get_domains(l->ifindex, &domains);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* networkd knows nothing about this interface, and that's fine. */
de0671ee7fe465e108f62dcbbbe9366f81dd9e9aZbigniew Jędrzejewski-Szmek dns_search_domain_mark_all(l->search_domains);
43cf8388ea4ffed1801468d4b650d6e48eefce9eMichal Schmidt r = dns_search_domain_find(l->search_domains, *i, &d);
cbd671772c9ce053a7050ddd29de170eb9efac7eZbigniew Jędrzejewski-Szmek dns_search_domain_move_back_and_unmark(d);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = dns_search_domain_new(l->manager, NULL, DNS_SEARCH_DOMAIN_LINK, l, *i);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_search_domain_unlink_marked(l->search_domains);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_search_domain_unlink_all(l->search_domains);
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek r = link_update_search_domains(l);
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to read search domains for interface %s, ignoring: %m", l->name);
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmekbool link_relevant(Link *l, int family) {
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek _cleanup_free_ char *state = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* A link is relevant if it isn't a loopback or pointopoint
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * device, has a link beat, can do multicast and has at least
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * one relevant IP address */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (l->flags & (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_DORMANT))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if ((l->flags & (IFF_UP|IFF_LOWER_UP|IFF_MULTICAST)) != (IFF_UP|IFF_LOWER_UP|IFF_MULTICAST))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek sd_network_link_get_operational_state(l->ifindex, &state);
43cf8388ea4ffed1801468d4b650d6e48eefce9eMichal Schmidt if (state && !STR_IN_SET(state, "unknown", "degraded", "routable"))
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek if (a->family == family && link_address_relevant(a))
26687bf8a907009dedcff79346860ed41511405eOleksii ShevchukLinkAddress *link_find_address(Link *l, int family, const union in_addr_union *in_addr) {
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk if (a->family == family && in_addr_equal(family, &a->in_addr, in_addr))
43cf8388ea4ffed1801468d4b650d6e48eefce9eMichal SchmidtDnsServer* link_set_dns_server(Link *l, DnsServer *s) {
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt in_addr_to_string(s->family, &s->address, &ip);
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering log_info("Switching to DNS server %s for interface %s.", strna(ip), l->name);
ea69bd41c5923f4f278a09bb7d8cb1abcfa122e1Lennart Poettering dns_cache_flush(&l->unicast_scope->cache);
63c8666b824e8762ffb73647e1caee165dfbc868Zbigniew Jędrzejewski-Szmek link_set_dns_server(l, l->dns_servers);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* Change to the next one, but make sure to follow the linked
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * list only if this server is actually still linked. */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (l->current_dns_server->linked && l->current_dns_server->servers_next) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek link_set_dns_server(l, l->current_dns_server->servers_next);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek link_set_dns_server(l, l->dns_servers);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekint link_address_new(Link *l, LinkAddress **ret, int family, const union in_addr_union *in_addr) {
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering LIST_PREPEND(addresses, l->addresses, a);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart PoetteringLinkAddress *link_address_free(LinkAddress *a) {
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering LIST_REMOVE(addresses, a->link->addresses, a);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering if (a->family == AF_INET && a->link->llmnr_ipv4_scope)
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_address_rr);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering else if (a->family == AF_INET6 && a->link->llmnr_ipv6_scope)
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv6_scope->zone, a->llmnr_address_rr);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering if (a->family == AF_INET && a->link->llmnr_ipv4_scope)
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_ptr_rr);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering else if (a->family == AF_INET6 && a->link->llmnr_ipv6_scope)
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering dns_zone_remove_rr(&a->link->llmnr_ipv6_scope->zone, a->llmnr_ptr_rr);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering dns_resource_record_unref(a->llmnr_address_rr);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering dns_resource_record_unref(a->llmnr_ptr_rr);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poetteringvoid link_address_add_rrs(LinkAddress *a, bool force_remove) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->link->llmnr_support == SUPPORT_YES &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->link->manager->llmnr_support == SUPPORT_YES) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!a->link->manager->llmnr_host_ipv4_key) {
2678031a179a9b91fc799f8ef951a548c66c4b49Lennart Poettering a->link->manager->llmnr_host_ipv4_key = dns_resource_key_new(DNS_CLASS_IN, DNS_TYPE_A, a->link->manager->llmnr_hostname);
2678031a179a9b91fc799f8ef951a548c66c4b49Lennart Poettering if (!a->link->manager->llmnr_host_ipv4_key) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->llmnr_address_rr = dns_resource_record_new(a->link->manager->llmnr_host_ipv4_key);
fa6ac76083b8ffc1309876459f54f9f0e2843731Lennart Poettering a->llmnr_address_rr->a.in_addr = a->in_addr.in;
2678031a179a9b91fc799f8ef951a548c66c4b49Lennart Poettering a->llmnr_address_rr->ttl = LLMNR_DEFAULT_TTL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = dns_resource_record_new_reverse(&a->llmnr_ptr_rr, a->family, &a->in_addr, a->link->manager->llmnr_hostname);
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering a->llmnr_ptr_rr->ttl = LLMNR_DEFAULT_TTL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = dns_zone_put(&a->link->llmnr_ipv4_scope->zone, a->link->llmnr_ipv4_scope, a->llmnr_address_rr, true);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to add A record to LLMNR zone: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = dns_zone_put(&a->link->llmnr_ipv4_scope->zone, a->link->llmnr_ipv4_scope, a->llmnr_ptr_rr, false);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to add IPv6 PTR record to LLMNR zone: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_address_rr);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->llmnr_address_rr = dns_resource_record_unref(a->llmnr_address_rr);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_ptr_rr);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->llmnr_ptr_rr = dns_resource_record_unref(a->llmnr_ptr_rr);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->link->llmnr_support == SUPPORT_YES &&
8266e1c04db8cabe3c68510a0c1f07c09ecdb2e8Lennart Poettering a->link->manager->llmnr_support == SUPPORT_YES) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!a->link->manager->llmnr_host_ipv6_key) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->link->manager->llmnr_host_ipv6_key = dns_resource_key_new(DNS_CLASS_IN, DNS_TYPE_AAAA, a->link->manager->llmnr_hostname);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!a->link->manager->llmnr_host_ipv6_key) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->llmnr_address_rr = dns_resource_record_new(a->link->manager->llmnr_host_ipv6_key);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->llmnr_address_rr->aaaa.in6_addr = a->in_addr.in6;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->llmnr_address_rr->ttl = LLMNR_DEFAULT_TTL;
3b3154df7e2773332bb814e167187367a0ccae4aLennart Poettering r = dns_resource_record_new_reverse(&a->llmnr_ptr_rr, a->family, &a->in_addr, a->link->manager->llmnr_hostname);
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering a->llmnr_ptr_rr->ttl = LLMNR_DEFAULT_TTL;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = dns_zone_put(&a->link->llmnr_ipv6_scope->zone, a->link->llmnr_ipv6_scope, a->llmnr_address_rr, true);
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering log_warning_errno(r, "Failed to add AAAA record to LLMNR zone: %m");
d378991747d67fff1d4dc39e7fb2bc8f49f1b561Mirco Tischler r = dns_zone_put(&a->link->llmnr_ipv6_scope->zone, a->link->llmnr_ipv6_scope, a->llmnr_ptr_rr, false);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek log_warning_errno(r, "Failed to add IPv6 PTR record to LLMNR zone: %m");
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek dns_zone_remove_rr(&a->link->llmnr_ipv6_scope->zone, a->llmnr_address_rr);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->llmnr_address_rr = dns_resource_record_unref(a->llmnr_address_rr);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek dns_zone_remove_rr(&a->link->llmnr_ipv6_scope->zone, a->llmnr_ptr_rr);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek a->llmnr_ptr_rr = dns_resource_record_unref(a->llmnr_ptr_rr);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_debug_errno(r, "Failed to update address RRs: %m");
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmekint link_address_update_rtnl(LinkAddress *a, sd_netlink_message *m) {
de0671ee7fe465e108f62dcbbbe9366f81dd9e9aZbigniew Jędrzejewski-Szmek r = sd_rtnl_message_addr_get_flags(m, &a->flags);
c2457105d76e3daf159f554a9bafb9751b23d756Holger Hans Peter Freyther sd_rtnl_message_addr_get_scope(m, &a->scope);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekbool link_address_relevant(LinkAddress *a) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (a->flags & (IFA_F_DEPRECATED|IFA_F_TENTATIVE))