From a5f035960006556beab51c42e6948985635e261a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Oct 2014 16:52:38 +0200 Subject: 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. --- src/shared/missing.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/shared/missing.h') diff --git a/src/shared/missing.h b/src/shared/missing.h index a88d9e414b..bb4f8f23a8 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 -- cgit v1.2.3-54-g00ecf