resolved-link.c revision 6f4dedb250f2d607eceefaa491f338becbeee7c0
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier This file is part of systemd.
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier Copyright 2014 Lennart Poettering
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier systemd is free software; you can redistribute it and/or modify it
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier under the terms of the GNU Lesser General Public License as published by
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier the Free Software Foundation; either version 2.1 of the License, or
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier (at your option) any later version.
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier systemd is distributed in the hope that it will be useful, but
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier WITHOUT ANY WARRANTY; without even the implied warranty of
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier Lesser General Public License for more details.
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier You should have received a copy of the GNU Lesser General Public License
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier along with systemd; If not, see <http://www.gnu.org/licenses/>.
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalierint link_new(Manager *m, Link **ret, int ifindex) {
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier r = hashmap_ensure_allocated(&m->links, NULL, NULL);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier r = hashmap_put(m->links, INT_TO_PTR(ifindex), l);
cda134ab1eac84f874aacf8e885a07112a7fd5ceLennart Poettering hashmap_remove(l->manager->links, INT_TO_PTR(l->ifindex));
cda134ab1eac84f874aacf8e885a07112a7fd5ceLennart Poetteringstatic void link_allocate_scopes(Link *l) {
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier r = dns_scope_new(l->manager, &l->unicast_scope, l, DNS_PROTOCOL_DNS, AF_UNSPEC);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier log_warning("Failed to allocate DNS scope: %s", strerror(-r));
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier l->unicast_scope = dns_scope_free(l->unicast_scope);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier if (link_relevant(l, AF_INET) && l->manager->use_llmnr) {
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier log_warning("Failed to allocate LLMNR IPv4 scope: %s", strerror(-r));
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier l->llmnr_ipv4_scope = dns_scope_free(l->llmnr_ipv4_scope);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier if (link_relevant(l, AF_INET6) && l->manager->use_llmnr) {
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier log_warning("Failed to allocate LLMNR IPv6 scope: %s", strerror(-r));
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier l->llmnr_ipv6_scope = dns_scope_free(l->llmnr_ipv6_scope);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalierint link_update_rtnl(Link *l, sd_rtnl_message *m) {
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier const char *n = NULL;
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier r = sd_rtnl_message_link_get_flags(m, &l->flags);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier sd_rtnl_message_read_u32(m, IFLA_MTU, &l->mtu);
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier if (sd_rtnl_message_read_string(m, IFLA_IFNAME, &n) >= 0) {
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalierstatic int link_update_dns_servers(Link *l) {
641d1f99b8c4c5427a1fedcb4740586a130ac6cfRonny Chevalier _cleanup_strv_free_ char **nameservers = NULL;
s->marked = true;
goto clear;
union in_addr_union a;
int family;
goto clear;
s->marked = false;
goto clear;
if (s->marked)
dns_server_free(s);
while (l->dns_servers)
assert(l);
LinkAddress *a;
assert(l);
LinkAddress *a;
assert(l);
return NULL;
DnsServer *s;
assert(l);
return NULL;
assert(l);
if (!l->current_dns_server)
return l->current_dns_server;
assert(l);
if (!l->current_dns_server) {
if (l->current_dns_server)
if (!l->current_dns_server)
LinkAddress *a;
assert(l);
return -ENOMEM;
a->link = l;
if (ret)
*ret = a;
return NULL;
if (a->link)
free(a);
return NULL;
assert(a);
assert(m);
assert(a);