@@ -210,6 +210,18 @@ else()
set(NL_LIBRARIES "")
endif()
+# Older stuff blows up if these headers are included together
+if (NOT NL_KIND EQUAL 0)
+ set(SAFE_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
+ set(CMAKE_REQUIRED_INCLUDES "${NL_INCLUDE_DIRS}")
+ CHECK_C_SOURCE_COMPILES("
+#include <netlink/route/link.h>
+#include <net/if.h>
+ int main(int argc,const char *argv[]) {return 0;}"
+ HAVE_WORKING_IF_H)
+ set(CMAKE_REQUIRED_INCLUDES "${SAFE_CMAKE_REQUIRED_INCLUDES}")
+endif()
+
# Statically determine sizeof(long), this is largely unnecessary, no new code
# should rely on this.
check_type_size("long" SIZEOF_LONG BUILTIN_TYPES_ONLY LANGUAGE C)
@@ -325,6 +337,10 @@ if (NL_KIND EQUAL 1)
endif()
if (NL_KIND EQUAL 0)
message(STATUS " neighbour resolution NOT enabled")
+else()
+ if (NOT HAVE_WORKING_IF_H)
+ message(STATUS " netlink/route/link.h and net/if.h NOT co-includable (old headers)")
+ endif()
endif()
if (NOT HAVE_RDMA_USER_RXE)
message(STATUS " rdma/rdma_user_rxe.h NOT found (old system kernel headers)")
@@ -31,6 +31,8 @@
// FIXME This has been supported in compilers forever, we should just fail to build on such old systems.
#cmakedefine HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE 1
+#cmakedefine HAVE_WORKING_IF_H 1
+
@SIZEOF_LONG_CODE@
#if @NL_KIND@ == 3
@@ -20,10 +20,11 @@
#include <ifaddrs.h>
#include <netdb.h>
#include <assert.h>
-#ifndef _LINUX_IF_H
+#if HAVE_WORKING_IF_H
#include <net/if.h>
#else
-/*Workaround when there's a collision between the includes */
+/* We need this decl from net/if.h but old systems do not let use co-include
+ net/if.h and netlink/route/link.h */
extern unsigned int if_nametoindex(__const char *__ifname) __THROW;
#endif
If not then just use the header directly, otherwise use the work around. The issue is that old libnl libraries include linux/if.h and the declarations there conflict with net/if.h. New libraries do not do this. Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> --- CMakeLists.txt | 16 ++++++++++++++++ buildlib/config.h.in | 2 ++ libibverbs/neigh.c | 5 +++-- 3 files changed, 21 insertions(+), 2 deletions(-)