resolved-manager.c revision 90ab504273a7f186ebb76e6acfb778b4e0d7c91b
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2014 Tom Gundersen <teg@jklm.no>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering#define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC)
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poetteringstatic int manager_process_link(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userdata) {
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering r = sd_rtnl_message_link_get_ifindex(mm, &ifindex);
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering l = hashmap_get(m->links, INT_TO_PTR(ifindex));
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering log_debug("Found new link %i/%s", ifindex, l->name);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering log_debug("Removing link %i/%s", l->ifindex, l->name);
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering log_warning("Failed to process RTNL link message: %s", strerror(-r));
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poetteringstatic int manager_process_address(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userdata) {
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen r = sd_rtnl_message_addr_get_ifindex(mm, &ifindex);
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen l = hashmap_get(m->links, INT_TO_PTR(ifindex));
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen r = sd_rtnl_message_addr_get_family(mm, &family);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering r = sd_rtnl_message_read_in_addr(mm, IFA_LOCAL, &address.in);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering r = sd_rtnl_message_read_in_addr(mm, IFA_ADDRESS, &address.in);
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering r = sd_rtnl_message_read_in6_addr(mm, IFA_LOCAL, &address.in6);
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering r = sd_rtnl_message_read_in6_addr(mm, IFA_ADDRESS, &address.in6);
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering a = link_find_address(l, family, &address);
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering r = link_address_new(l, &a, family, &address);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering log_warning("Failed to process RTNL address message: %s", strerror(-r));
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringstatic int manager_rtnl_listen(Manager *m) {
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering _cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL, *reply = NULL;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering /* First, subscibe to interfaces coming and going */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering r = sd_rtnl_open(&m->rtnl, 3, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR, RTNLGRP_IPV6_IFADDR);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering r = sd_rtnl_attach_event(m->rtnl, m->event, 0);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering r = sd_rtnl_add_match(m->rtnl, RTM_NEWLINK, manager_process_link, m);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering r = sd_rtnl_add_match(m->rtnl, RTM_DELLINK, manager_process_link, m);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering r = sd_rtnl_add_match(m->rtnl, RTM_NEWADDR, manager_process_address, m);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering r = sd_rtnl_add_match(m->rtnl, RTM_DELADDR, manager_process_address, m);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering /* Then, enumerate all links */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering r = sd_rtnl_message_new_link(m->rtnl, &req, RTM_GETLINK, 0);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_rtnl_message_request_dump(req, true);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_rtnl_call(m->rtnl, req, 0, &reply);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering for (i = reply; i; i = sd_rtnl_message_next(i)) {
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering /* Finally, enumerate all addresses, too */
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_rtnl_message_new_addr(m->rtnl, &req, RTM_GETADDR, 0, AF_UNSPEC);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_rtnl_message_request_dump(req, true);
b64513580ce627578351b76a502455e7bc62cae4Lennart Poettering r = sd_rtnl_call(m->rtnl, req, 0, &reply);
b64513580ce627578351b76a502455e7bc62cae4Lennart Poettering for (i = reply; i; i = sd_rtnl_message_next(i)) {
b64513580ce627578351b76a502455e7bc62cae4Lennart Poettering r = manager_process_address(m->rtnl, i, m);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poetteringstatic int on_network_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
d74fb368b18f0fbd9a4fe6f15691bbea7f3c4a01Tom Gundersen log_warning("Failed to update monitor information for %i: %s", l->ifindex, strerror(-r));
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen log_warning("Could not update resolv.conf: %s", strerror(-r));
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenstatic int manager_network_monitor_listen(Manager *m) {
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_network_monitor_new(&m->network_monitor, NULL);
84129d46cd6e95e142973da93aede4c7433c9600Lennart Poettering fd = sd_network_monitor_get_fd(m->network_monitor);
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen events = sd_network_monitor_get_events(m->network_monitor);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_event_add_io(m->event, &m->network_event_source, fd, events, &on_network_event, m);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poetteringstatic int determine_hostname(char **ret) {
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering _cleanup_free_ char *h = NULL, *n = NULL;
4e0b8b17a7465653f4e7b819dad5f8e30d64c0c4Tom Gundersen log_error("System hostname is not UTF-8 clean.");
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering log_error("System hostname '%s' cannot be normalized.", h);
b652d4a2099d1c167584dcc1d179d47c58dc38a2Lennart Poetteringstatic int on_hostname_change(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
b652d4a2099d1c167584dcc1d179d47c58dc38a2Lennart Poettering return 0; /* ignore invalid hostnames */
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen log_info("System hostname changed to '%s'.", h);
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenstatic int manager_watch_hostname(Manager *m) {
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen m->hostname_fd = open("/proc/sys/kernel/hostname", O_RDONLY|O_CLOEXEC|O_NDELAY|O_NOCTTY);
011842775f750711833526d5bba1b818713947f5Lennart Poettering log_warning("Failed to watch hostname: %m");
011842775f750711833526d5bba1b818713947f5Lennart Poettering r = sd_event_add_io(m->event, &m->hostname_event_source, m->hostname_fd, 0, on_hostname_change, m);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering /* kernels prior to 3.2 don't support polling this file. Ignore the failure. */
011842775f750711833526d5bba1b818713947f5Lennart Poettering m->hostname_fd = safe_close(m->hostname_fd);
011842775f750711833526d5bba1b818713947f5Lennart Poettering log_error("Failed to add hostname event source: %s", strerror(-r));
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poettering log_info("Defaulting to hostname 'linux'.");
6cb08a8930bdaca950b152b1e8b82466ed59511cLennart Poettering log_info("Using system hostname '%s'.", m->hostname);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poetteringstatic void manager_llmnr_stop(Manager *m) {
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering m->llmnr_ipv4_udp_event_source = sd_event_source_unref(m->llmnr_ipv4_udp_event_source);
6a1a5eec43892dee3ff6e208bceb1931c25c782eLennart Poettering m->llmnr_ipv4_udp_fd = safe_close(m->llmnr_ipv4_udp_fd);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering m->llmnr_ipv6_udp_event_source = sd_event_source_unref(m->llmnr_ipv6_udp_event_source);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering m->llmnr_ipv6_udp_fd = safe_close(m->llmnr_ipv6_udp_fd);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering m->llmnr_ipv4_tcp_event_source = sd_event_source_unref(m->llmnr_ipv4_tcp_event_source);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering m->llmnr_ipv4_tcp_fd = safe_close(m->llmnr_ipv4_tcp_fd);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering m->llmnr_ipv6_tcp_event_source = sd_event_source_unref(m->llmnr_ipv6_tcp_event_source);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering m->llmnr_ipv6_tcp_fd = safe_close(m->llmnr_ipv6_tcp_fd);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poetteringstatic int manager_llmnr_start(Manager *m) {
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering log_warning("There appears to be another LLMNR respondering running. Turning off LLMNR support.");
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering _cleanup_(manager_freep) Manager *m = NULL;
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering m->llmnr_ipv4_udp_fd = m->llmnr_ipv6_udp_fd = -1;
6cb08a8930bdaca950b152b1e8b82466ed59511cLennart Poettering m->llmnr_ipv4_tcp_fd = m->llmnr_ipv6_tcp_fd = -1;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen r = manager_parse_dns_server(m, DNS_SERVER_FALLBACK, DNS_SERVERS);
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poettering sd_event_add_signal(m->event, NULL, SIGTERM, NULL, NULL);
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poettering sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poettering r = dns_scope_new(m, &m->unicast_scope, NULL, DNS_PROTOCOL_DNS, AF_UNSPEC);
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen manager_flush_dns_servers(m, DNS_SERVER_SYSTEM);
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen manager_flush_dns_servers(m, DNS_SERVER_FALLBACK);
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering sd_event_source_unref(m->network_event_source);
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering sd_network_monitor_unref(m->network_monitor);
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering sd_event_source_unref(m->dns_ipv4_event_source);
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering sd_event_source_unref(m->dns_ipv6_event_source);
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt sd_bus_slot_unref(m->prepare_for_sleep_slot);
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt sd_event_source_unref(m->bus_retry_event_source);
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering dns_resource_key_unref(m->host_ipv4_key);
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering dns_resource_key_unref(m->host_ipv6_key);
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering sd_event_source_unref(m->hostname_event_source);
636e813dc98ea40c58c6c85bc5e7e3c9f0904ea2Lennart Poetteringint manager_read_resolv_conf(Manager *m) {
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering /* Reads the system /etc/resolv.conf, if it exists and is not
636e813dc98ea40c58c6c85bc5e7e3c9f0904ea2Lennart Poettering * symlinked to our own resolv.conf instance */
636e813dc98ea40c58c6c85bc5e7e3c9f0904ea2Lennart Poettering log_warning("Failed to open /etc/resolv.conf: %m");
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering /* Have we already seen the file? */
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering /* Is it symlinked to our own file? */
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering if (stat("/run/systemd/resolve/resolv.conf", &own) >= 0 &&
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering log_warning("Failed to open /etc/resolv.conf: %m");
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering log_error("Failed to stat open file: %m");
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering FOREACH_LINE(line, f, r = -errno; goto clear) {
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering const char *a;
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering r = in_addr_from_string_auto(a, &family, &address);
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering log_warning("Failed to parse name server %s.", a);
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering if (s->family == family && in_addr_equal(family, &s->address, &address) > 0)
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering r = dns_server_new(m, NULL, DNS_SERVER_SYSTEM, NULL, family, &address);
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering LIST_FOREACH_SAFE(servers, s, nx, m->dns_servers)
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poetteringstatic void write_resolve_conf_server(DnsServer *s, FILE *f, unsigned *count) {
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering r = in_addr_to_string(s->family, &s->address, &t);
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering log_warning("Invalid DNS address. Ignoring: %s", strerror(-r));
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen fputs("# Too many DNS servers configured, the following entries may be ignored.\n", f);
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen static const char path[] = "/run/systemd/resolve/resolv.conf";
unsigned count = 0;
DnsServer *s;
Iterator i;
Link *l;
assert(m);
/* Read the system /etc/resolv.conf first */
if (!dns)
return -ENOMEM;
if (r == -EEXIST)
if (r == -EEXIST)
if (r == -EEXIST)
"# only through the symlink at /etc/resolv.conf. To manage\n"
"# resolv.conf(5) in a different way, replace the symlink by a\n"
r = fflush_and_check(f);
goto fail;
r = -errno;
goto fail;
fail:
} control;
int ms = 0, r;
ssize_t l;
assert(m);
return -errno;
if (ms < 0)
return -EIO;
return -errno;
return -EIO;
return -EAFNOSUPPORT;
case IPV6_PKTINFO: {
if (p->ifindex <= 0)
case IPV6_HOPLIMIT:
case IP_PKTINFO: {
if (p->ifindex <= 0)
case IP_TTL:
p->ifindex = 0;
if (p->ifindex <= 0)
*ret = p;
p = NULL;
if (dns_packet_validate_reply(p) > 0) {
assert(m);
if (m->dns_ipv4_fd >= 0)
return m->dns_ipv4_fd;
if (m->dns_ipv4_fd < 0)
return -errno;
r = -errno;
goto fail;
r = sd_event_add_io(m->event, &m->dns_ipv4_event_source, m->dns_ipv4_fd, EPOLLIN, on_dns_packet, m);
goto fail;
return m->dns_ipv4_fd;
fail:
assert(m);
if (m->dns_ipv6_fd >= 0)
return m->dns_ipv6_fd;
if (m->dns_ipv6_fd < 0)
return -errno;
r = -errno;
goto fail;
r = sd_event_add_io(m->event, &m->dns_ipv6_event_source, m->dns_ipv6_fd, EPOLLIN, on_dns_packet, m);
goto fail;
return m->dns_ipv6_fd;
fail:
return -errno;
return -ETIMEDOUT;
static int manager_ipv4_send(Manager *m, int fd, int ifindex, const struct in_addr *addr, uint16_t port, DnsPacket *p) {
} control;
assert(m);
assert(p);
if (ifindex > 0) {
static int manager_ipv6_send(Manager *m, int fd, int ifindex, const struct in6_addr *addr, uint16_t port, DnsPacket *p) {
} control;
assert(m);
assert(p);
if (ifindex > 0) {
int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *addr, uint16_t port, DnsPacket *p) {
assert(m);
assert(p);
log_debug("Sending %s packet with id %u on interface %i/%s", DNS_PACKET_QR(p) ? "response" : "query", DNS_PACKET_ID(p), ifindex, af_to_name(family));
return -EAFNOSUPPORT;
DnsServer *s;
assert(m);
return NULL;
assert(m);
if (m->current_dns_server == s)
m->current_dns_server = s;
if (m->unicast_scope)
Link *l;
assert(m);
/* Try to read updates resolv.conf */
if (!m->current_dns_server)
if (!m->current_dns_server) {
bool found = false;
Iterator i;
if (l->dns_servers) {
found = true;
if (!found)
return m->current_dns_server;
assert(m);
if (!m->current_dns_server)
Link *l;
Iterator i;
if (l->mtu <= 0)
return mtu;
if (!scope) {
if (dns_packet_validate_reply(p) > 0) {
} else if (dns_packet_validate_query(p) > 0) {
assert(m);
if (m->llmnr_ipv4_udp_fd >= 0)
return m->llmnr_ipv4_udp_fd;
if (m->llmnr_ipv4_udp_fd < 0)
return -errno;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = sd_event_add_io(m->event, &m->llmnr_ipv4_udp_event_source, m->llmnr_ipv4_udp_fd, EPOLLIN, on_llmnr_packet, m);
goto fail;
return m->llmnr_ipv4_udp_fd;
fail:
assert(m);
if (m->llmnr_ipv6_udp_fd >= 0)
return m->llmnr_ipv6_udp_fd;
if (m->llmnr_ipv6_udp_fd < 0)
return -errno;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = sd_event_add_io(m->event, &m->llmnr_ipv6_udp_event_source, m->llmnr_ipv6_udp_fd, EPOLLIN, on_llmnr_packet, m);
r = -errno;
goto fail;
return m->llmnr_ipv6_udp_fd;
fail:
assert(s);
if (!scope) {
if (s->write_packet)
dns_stream_free(s);
int cfd, r;
if (cfd < 0) {
return -errno;
assert(m);
if (m->llmnr_ipv4_tcp_fd >= 0)
return m->llmnr_ipv4_tcp_fd;
if (m->llmnr_ipv4_tcp_fd < 0)
return -errno;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = sd_event_add_io(m->event, &m->llmnr_ipv4_tcp_event_source, m->llmnr_ipv4_tcp_fd, EPOLLIN, on_llmnr_stream, m);
goto fail;
return m->llmnr_ipv4_tcp_fd;
fail:
assert(m);
if (m->llmnr_ipv6_tcp_fd >= 0)
return m->llmnr_ipv6_tcp_fd;
if (m->llmnr_ipv6_tcp_fd < 0)
return -errno;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = sd_event_add_io(m->event, &m->llmnr_ipv6_tcp_event_source, m->llmnr_ipv6_tcp_fd, EPOLLIN, on_llmnr_stream, m);
r = -errno;
goto fail;
return m->llmnr_ipv6_tcp_fd;
fail:
Link *l;
assert(m);
if (ifindex <= 0)
return -EINVAL;
LinkAddress *a;
assert(m);
Iterator i;
Link *l;
assert(m);
link_add_rrs(l, true);
link_add_rrs(l, false);
uint64_t u, a;
assert(m);
assert(p);
while (p > m->hostname) {
if (*p == 0 || safe_atou64(p, &u) < 0 || u <= 0)
random_bytes(&a, sizeof(a));
return -ENOMEM;
m->hostname = h;
LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr) {
Iterator i;
Link *l;
assert(m);
LinkAddress *a;
return NULL;
assert(m);
assert(p);
Link *l;
assert(m);
assert(p);
return NULL;
return l->llmnr_ipv4_scope;
return l->llmnr_ipv6_scope;
return NULL;
DnsScope *s;
assert(m);
assert(m);
if (t == DNS_SERVER_SYSTEM)
while (m->dns_servers)
if (t == DNS_SERVER_FALLBACK)
while (m->fallback_dns_servers)