#include "socket-util.h"
#include "af-list.h"
#include "utf8.h"
+#include "fileio-label.h"
#include "resolved-dns-domain.h"
#include "resolved-conf.h"
return 0;
fail:
- log_warning("Failed to process RTNL link message: %s", strerror(-r));
+ log_warning_errno(r, "Failed to process RTNL link message: %m");
return 0;
}
return 0;
fail:
- log_warning("Failed to process RTNL address message: %s", strerror(-r));
+ log_warning_errno(r, "Failed to process RTNL address message: %m");
return 0;
}
HASHMAP_FOREACH(l, m->links, i) {
r = link_update_monitor(l);
if (r < 0)
- log_warning("Failed to update monitor information for %i: %s", l->ifindex, strerror(-r));
+ log_warning_errno(r, "Failed to update monitor information for %i: %m", l->ifindex);
}
r = manager_write_resolv_conf(m);
if (r < 0)
- log_warning("Could not update resolv.conf: %s", strerror(-r));
+ log_warning_errno(r, "Could not update resolv.conf: %m");
return 0;
}
m->hostname_fd = open("/proc/sys/kernel/hostname", O_RDONLY|O_CLOEXEC|O_NDELAY|O_NOCTTY);
if (m->hostname_fd < 0) {
- log_warning("Failed to watch hostname: %m");
+ log_warning_errno(errno, "Failed to watch hostname: %m");
return 0;
}
if (r == -EPERM)
/* kernels prior to 3.2 don't support polling this file. Ignore the failure. */
m->hostname_fd = safe_close(m->hostname_fd);
- else {
- log_error("Failed to add hostname event source: %s", strerror(-r));
- return r;
- }
+ else
+ return log_error_errno(r, "Failed to add hostname event source: %m");
}
r = determine_hostname(&m->hostname);
r = stat("/etc/resolv.conf", &st);
if (r < 0) {
if (errno != ENOENT)
- log_warning("Failed to open /etc/resolv.conf: %m");
+ log_warning_errno(errno, "Failed to open /etc/resolv.conf: %m");
r = -errno;
goto clear;
}
f = fopen("/etc/resolv.conf", "re");
if (!f) {
if (errno != ENOENT)
- log_warning("Failed to open /etc/resolv.conf: %m");
+ log_warning_errno(errno, "Failed to open /etc/resolv.conf: %m");
r = -errno;
goto clear;
}
if (fstat(fileno(f), &st) < 0) {
- log_error("Failed to stat open file: %m");
+ log_error_errno(errno, "Failed to stat open file: %m");
r = -errno;
goto clear;
}
r = in_addr_to_string(s->family, &s->address, &t);
if (r < 0) {
- log_warning("Invalid DNS address. Ignoring: %s", strerror(-r));
+ log_warning_errno(r, "Invalid DNS address. Ignoring: %m");
return;
}
}
}
- r = fopen_temporary(path, &f, &temp_path);
+ r = fopen_temporary_label(path, path, &f, &temp_path);
if (r < 0)
return r;
* device if the packet came from the local host since it
* avoids the routing table in such a case. Let's unset the
* interface index in such a case. */
- if (p->ifindex > 0 && manager_ifindex_is_loopback(m, p->ifindex) != 0)
+ if (p->ifindex == LOOPBACK_IFINDEX)
p->ifindex = 0;
/* If we don't know the interface index still, we look for the
return r;
}
-/* lo having ifindex 1 is hardcoded in the kernel */
-#define LOOPBACK_IFINDEX 1
-
-int manager_ifindex_is_loopback(Manager *m, int ifindex) {
- Link *l;
- assert(m);
-
- if (ifindex <= 0)
- return -EINVAL;
-
- l = hashmap_get(m->links, INT_TO_PTR(ifindex));
- if (!l)
- /* in case we don't yet track the link, rely on the hardcoded value */
- return ifindex == LOOPBACK_IFINDEX;
- else if (l->flags & IFF_LOOPBACK)
- return 1;
-
- return 0;
-}
-
int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr) {
LinkAddress *a;