[systemd-commits] 2 commits - TODO src/resolve src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Oct 22 07:54:19 PDT 2014
TODO | 2 +-
src/resolve/resolved-dns-stream.c | 2 +-
src/resolve/resolved-manager.c | 22 +---------------------
src/resolve/resolved-manager.h | 1 -
src/shared/missing.h | 9 +++++++++
5 files changed, 12 insertions(+), 24 deletions(-)
New commits:
commit f62531c57204d25530491cfc6dda8d69c60f692e
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Oct 22 16:54:06 2014 +0200
update TODO
diff --git a/TODO b/TODO
index ddc8e58..f45b02c 100644
--- a/TODO
+++ b/TODO
@@ -41,7 +41,7 @@ External:
Features:
-* if the loopback is guaranteed to always have ifindex == 1, get rid of manager_is_loopback_ifindex() in resolved
+* what to do about udev db binary stability for apps?
* add a system-wide shutdown timeout, similar to the startup timeout we already have (see fdo bz #84110)
commit a5f035960006556beab51c42e6948985635e261a
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Oct 22 16:52:38 2014 +0200
resolved: simplify detection of packets from the loopback device
We can simplify our code quite a bit if we explicitly check for the
ifindex being 1 on Linux as a loopback check. Apparently, this is
hardcoded on Linux on the kernel, and effectively exported to userspace
via rtnl and such, hence we should be able to rely on it.
diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c
index 8aad5e4..3690679 100644
--- a/src/resolve/resolved-dns-stream.c
+++ b/src/resolve/resolved-dns-stream.c
@@ -157,7 +157,7 @@ static int dns_stream_identify(DnsStream *s) {
* device if the connection 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 (s->ifindex > 0 && manager_ifindex_is_loopback(s->manager, s->ifindex) != 0)
+ if (s->ifindex == LOOPBACK_IFINDEX)
s->ifindex = 0;
/* If we don't know the interface index still, we look for the
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 74f4ad5..c4a5b08 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -960,7 +960,7 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
* 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
@@ -1695,26 +1695,6 @@ fail:
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;
diff --git a/src/resolve/resolved-manager.h b/src/resolve/resolved-manager.h
index 78cbfc0..1151029 100644
--- a/src/resolve/resolved-manager.h
+++ b/src/resolve/resolved-manager.h
@@ -139,7 +139,6 @@ int manager_llmnr_ipv6_udp_fd(Manager *m);
int manager_llmnr_ipv4_tcp_fd(Manager *m);
int manager_llmnr_ipv6_tcp_fd(Manager *m);
-int manager_ifindex_is_loopback(Manager *m, int ifindex);
int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr);
LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr);
diff --git a/src/shared/missing.h b/src/shared/missing.h
index a88d9e4..bb4f8f2 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -527,3 +527,12 @@ static inline int setns(int fd, int nstype) {
#ifndef BPF_XOR
# define BPF_XOR 0xa0
#endif
+
+/* Note that LOOPBACK_IFINDEX is currently not exported by the
+ * kernel/glibc, but hardcoded internally by the kernel. However, as
+ * it is exported to userspace indirectly via rtnetlink and the
+ * ioctls, and made use of widely we define it here too, in a way that
+ * is compatible with the kernel's internal definition. */
+#ifndef LOOPBACK_IFINDEX
+#define LOOPBACK_IFINDEX 1
+#endif
More information about the systemd-commits
mailing list