diff --git a/configure.ac b/configure.ac index 608765b61..509de590e 100644 --- a/configure.ac +++ b/configure.ac @@ -331,6 +331,15 @@ if (test "${have_libnl2}" = "yes"); then have_libnl="yes" fi +PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [have_libnl2=yes], [have_libnl2=no]) +if (test "${have_libnl2}" = "yes"); then + AC_DEFINE(HAVE_LIBNL3, 1, [Define if you require specific libnl-3 support]) + LIBNL_CFLAGS="$LIBNL3_CFLAGS" + LIBNL_LIBS="$LIBNL3_LIBS" + libnl_version="3" + have_libnl="yes" +fi + if (test "${have_libnl}" = "no"); then AC_MSG_ERROR([libnl development header are required]) fi diff --git a/src/nm-netlink-compat.h b/src/nm-netlink-compat.h index 6101b307a..867c9f4ee 100644 --- a/src/nm-netlink-compat.h +++ b/src/nm-netlink-compat.h @@ -51,6 +51,13 @@ int rtnl_route_get_dst_len(struct rtnl_route *); struct nl_addr * rtnl_route_get_gateway(struct rtnl_route *); #endif +/* libnl-2 API compatibility for libnl-3 */ +#ifdef HAVE_LIBNL3 +static inline int __rtnl_link_alloc_cache(struct nl_sock *h, struct nl_cache **cache) { + return rtnl_link_alloc_cache (h, AF_UNSPEC, cache); +} +#define rtnl_link_alloc_cache __rtnl_link_alloc_cache +#endif /* libnl-1.0 compat functions */ #ifdef HAVE_LIBNL1