diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/conf_macros.m4 | 7 | ||||
-rw-r--r-- | src/external/libnl.m4 | 49 | ||||
-rw-r--r-- | src/monitor/monitor_netlink.c | 32 |
3 files changed, 27 insertions, 61 deletions
diff --git a/src/conf_macros.m4 b/src/conf_macros.m4 index 5898bc7f..d759c48e 100644 --- a/src/conf_macros.m4 +++ b/src/conf_macros.m4 @@ -240,15 +240,14 @@ AC_DEFUN([WITH_SEMANAGE], AC_DEFUN([WITH_LIBNL], [ AC_ARG_WITH([libnl], [AC_HELP_STRING([--with-libnl], - [Whether to build with libnetlink support [yes]] + [Whether to build with libnetlink support [AUTO]] ) ], [], with_libnl=yes ) if test x"$with_libnl" = xyes; then - HAVE_LIBNL=1 - AC_SUBST(HAVE_LIBNL) - AC_DEFINE_UNQUOTED(HAVE_LIBNL, 1, [Build with libnetlink support]) + BUILD_LIBNL=1 + AC_SUBST(BUILD_LIBNL) fi ]) diff --git a/src/external/libnl.m4 b/src/external/libnl.m4 index ed8f95b6..36619ff8 100644 --- a/src/external/libnl.m4 +++ b/src/external/libnl.m4 @@ -1,35 +1,34 @@ dnl A macro to check the availability and version of libnetlink + AC_DEFUN([AM_CHECK_LIBNL], [ - PKG_CHECK_MODULES(libnl, libnl-1) - - AC_CHECK_HEADERS(netlink.h) - AC_CHECK_LIB(nl, nl_connect, [ LIBNL_LIBS="-lnl" ], [AC_MSG_ERROR([libnl is required])]) + PKG_CHECK_MODULES(libnl, libnl-1 >= 1.1,[ + HAVE_LIBNL=1 + AC_SUBST(HAVE_LIBNL) + AC_DEFINE_UNQUOTED(HAVE_LIBNL, 1, [Build with libnetlink support]) - AC_CHECK_LIB([nl], - [nl_handle_get_fd], - [AC_DEFINE([HAVE_LIBNL_OLDER_THAN_1_1], 1, [Does libnl have pre-1.1 API?]) - ], - ) + AC_CHECK_HEADERS(netlink.h) + AC_CHECK_LIB(nl, nl_connect, [ LIBNL_LIBS="-lnl" ], [AC_MSG_ERROR([libnl is required])]) - dnl Check if this particular version of libnl supports particular functions - AC_CHECK_LIB([nl], - [nl_socket_add_membership], - [AC_DEFINE([HAVE_NL_SOCKET_ADD_MEMBERSHIP], 1, [Does libnl have nl_socket_add_membership?]) - ], - ) + dnl Check if this particular version of libnl supports particular functions + AC_CHECK_LIB([nl], + [nl_socket_add_membership], + [AC_DEFINE([HAVE_NL_SOCKET_ADD_MEMBERSHIP], 1, [Does libnl have nl_socket_add_membership?]) + ], + ) - AC_CHECK_LIB([nl], - [nl_socket_modify_cb], - [AC_DEFINE([HAVE_NL_SOCKET_MODIFY_CB], 1, [Does libnl have nl_socket_modify_cb?]) - ], - ) + AC_CHECK_LIB([nl], + [nl_socket_modify_cb], + [AC_DEFINE([HAVE_NL_SOCKET_MODIFY_CB], 1, [Does libnl have nl_socket_modify_cb?]) + ], + ) - AC_CHECK_LIB([nl], - [nl_set_passcred], - [AC_DEFINE([HAVE_NL_SET_PASSCRED], 1, [Does libnl have nl_set_passcred?]) - ], - ) + AC_CHECK_LIB([nl], + [nl_set_passcred], + [AC_DEFINE([HAVE_NL_SET_PASSCRED], 1, [Does libnl have nl_set_passcred?]) + ], + ) + ],[AC_MSG_WARN([Netlink support unavailable or too old])]) AC_SUBST(LIBNL_CFLAGS) AC_SUBST(LIBNL_LIBS) diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c index 29a182b9..33be7c85 100644 --- a/src/monitor/monitor_netlink.c +++ b/src/monitor/monitor_netlink.c @@ -49,20 +49,11 @@ #define SOL_NETLINK 270 #endif -#ifdef HAVE_LIBNL_OLDER_THAN_1_1 -#define nlw_get_fd nl_handle_get_fd -#define nlw_recvmsgs_default nl_recvmsgs_def -#define nlw_get_pid nl_handle_get_pid -#define nlw_object_match nl_object_match -#define NLW_OK NL_PROCEED -#define OBJ_CAST(ptr) ((struct nl_object *) (ptr)) -#else #define nlw_get_fd nl_socket_get_fd #define nlw_recvmsgs_default nl_recvmsgs_default #define nlw_get_pid nl_socket_get_local_port #define nlw_object_match nl_object_match_filter #define NLW_OK NL_OK -#endif struct netlink_ctx { #ifdef HAVE_LIBNL @@ -182,19 +173,6 @@ static int nlw_group_subscribe(struct nl_handle *nlh) * Callbacks for validating and receiving messages *******************************************************************/ -#ifdef HAVE_LIBNL_OLDER_THAN_1_1 -static int event_msg_recv(struct sockaddr_nl *nla, struct nlmsghdr *hdr, - void *arg) -{ - struct netlink_ctx *ctx = (struct netlink_ctx *) arg; - - if (!nlw_accept_message(ctx->nlh, nla, hdr)) { - return NL_SKIP; - } - - return NLW_OK; -} -#else static int event_msg_recv(struct nl_msg *msg, void *arg) { struct netlink_ctx *ctx = (struct netlink_ctx *) arg; @@ -218,24 +196,14 @@ static int event_msg_recv(struct nl_msg *msg, void *arg) return NLW_OK; } -#endif static void link_msg_handler(struct nl_object *obj, void *arg); -#ifdef HAVE_LIBNL_OLDER_THAN_1_1 -static int event_msg_ready(struct sockaddr_nl *nla, struct nlmsghdr *hdr, - void *arg) -{ - nl_msg_parse(hdr, &link_msg_handler, arg); - return NLW_OK; -} -#else static int event_msg_ready(struct nl_msg *msg, void *arg) { nl_msg_parse(msg, &link_msg_handler, arg); return NLW_OK; } -#endif static int nlw_set_callbacks(struct nl_handle *nlh, void *data) { |