Skip to content

Commit

Permalink
Fix build on xenial
Browse files Browse the repository at this point in the history
- xenial's cmake version (3.5.1) builds everything fine and test suite
  passes, so lower the minimum to that.

- add a hack for xenial's kernel header & glibc version breaking if both
  net/if.h and linux/if.h get included.  The only thing we actually need
  from net/if.h that linux/if.h doesn't have is `if_nametoindex`, so
  just hack that definition in for xenial's specific glibc/kernel header
  versions.
  • Loading branch information
jagerman committed Oct 11, 2019
1 parent 8e8abbc commit 6a35fea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Lowest version - android ndk 3.6.0
cmake_minimum_required(VERSION 3.6.0)
cmake_minimum_required(VERSION 3.5.1)

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
Expand Down
15 changes: 14 additions & 1 deletion llarp/net/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
#ifndef ANDROID
#include <ifaddrs.h>
#endif
#include <net/if.h>

// Work around for broken glibc/linux header definitions in xenial that makes
// including both net/if.h (which we need for if_nametoindex) and linux/if.h
// (which tuntap.h includes) impossible. When we stop supporting xenial we can
// remove this mess and just include net/if.h here.
#if defined(Linux) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 23
# include <linux/version.h>
# if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
# define _NET_IF_H 1
# include <linux/if.h>
extern "C" unsigned int if_nametoindex (const char *__ifname) __THROW;
# endif
#else
# include <net/if.h>
#endif

#include <net/net_addr.hpp>
Expand Down

0 comments on commit 6a35fea

Please sign in to comment.