Skip to content

Commit

Permalink
Merge pull request acassen#2385 from pqarmitage/updates
Browse files Browse the repository at this point in the history
More intelligent testing for, and including, some kernel headers
  • Loading branch information
pqarmitage committed Feb 20, 2024
2 parents c3c592e + 6eb9303 commit 3084a92
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
56 changes: 34 additions & 22 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1142,37 +1142,49 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([[
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/prctl.h sys/socket.h sys/time.h syslog.h unistd.h],
[], [AC_MSG_ERROR([Missing/unusable system header file <$ac_header>])])
AS_IF([test .$enable_lvs != .no],
[AC_CHECK_HEADERS([net/if_arp.h],
[], [AC_MSG_ERROR([Missing/unusable <$ac_header> - is glibc headers package installed?])])
])
# check for kernel headers
SAV_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $kernelinc"
dnl -- linux/errqueue.h need sys/time.h before Linux < v5.1
AC_MSG_CHECKING([linux/errqueue.h needs sys/time.h])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <fcntl.h>
#include <linux/errqueue.h>
int main(void)
{
}
]])],
AC_CHECK_HEADERS([linux/types.h],
[], [AC_MSG_ERROR([Missing/unusable kernel header file <$ac_header> - is kernel headers package installed?])])
AS_IF([test .$enable_vrrp != .no],
[
AC_MSG_RESULT([no])
],
AC_CHECK_HEADERS([linux/ethtool.h linux/if_ether.h linux/if_packet.h linux/ip.h linux/sockios.h],
[], [AC_MSG_ERROR([Missing/unusable kernel header file <$ac_header> - is kernel headers package installed?])])
AC_CHECK_HEADERS([linux/fib_rules.h linux/if_addr.h linux/if_link.h],
[], [AC_MSG_ERROR([Missing/unusable kernel header file <$ac_header> - is kernel headers package installed?])],
[[$NETLINK_EXTRA_INCLUDE]])
])
AS_IF([test .$enable_lvs != .no],
[
AC_MSG_RESULT([yes])
AC_DEFINE([ERRQUEUE_NEEDS_SYS_TIME], [ 1 ], [Define to 1 if linux/errqueue.h needs sys/time.h])
AC_CHECK_HEADERS([linux/icmp.h linux/icmpv6.h linux/errqueue.h],
[], [AC_MSG_ERROR([Missing/unusable kernel header file <$ac_header> - is kernel headers package installed?])])
dnl -- linux/errqueue.h need sys/time.h before Linux < v5.1
AC_MSG_CHECKING([linux/errqueue.h needs sys/time.h])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <fcntl.h>
#include <linux/errqueue.h>
int main(void)
{
}
]])],
[
AC_MSG_RESULT([no])
],
[
AC_MSG_RESULT([yes])
AC_DEFINE([ERRQUEUE_NEEDS_SYS_TIME], [ 1 ], [Define to 1 if linux/errqueue.h needs sys/time.h])
])
])
AC_CHECK_HEADERS([asm/types.h linux/ethtool.h linux/icmpv6.h linux/if_ether.h linux/if_packet.h linux/ip.h linux/sockios.h linux/types.h],
[], [AC_MSG_ERROR([Missing/unusable kernel header file <$ac_header>])])
AC_CHECK_HEADERS([linux/fib_rules.h linux/if_addr.h linux/if_link.h],
[], [AC_MSG_ERROR([Missing/unusable kernel header file <$ac_header>])],
[[$NETLINK_EXTRA_INCLUDE]])
AC_CHECK_HEADERS([linux/if_arp.h],
[], [AC_MSG_ERROR([Missing/unusable <$ac_header>])],
[[#include <sys/socket.h>]])
CPPFLAGS="$SAV_CPPFLAGS"
# Checks for typedefs, structures, and compiler characteristics.
Expand Down
8 changes: 4 additions & 4 deletions keepalived/core/keepalived_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@
#include <time.h>
#ifdef _WITH_VRRP_
#include <linux/version.h>
#ifdef _WITH_VRRP_
#include <linux/fib_rules.h>
#endif
#endif
#include <linux/ip.h>
#include <linux/if_link.h>
#endif
#include <unistd.h>
#include <inttypes.h>
#include <linux/if_link.h>

#ifdef THREAD_DUMP
#include "scheduler.h"
Expand Down Expand Up @@ -2672,6 +2670,8 @@ void
register_keepalived_netlink_addresses(void)
{
register_thread_address("kernel_netlink", kernel_netlink);
#ifdef _WITH_VRRP_
register_thread_address("delayed_if_flags_change_thread", delayed_if_flags_change_thread);
#endif
}
#endif
2 changes: 2 additions & 0 deletions keepalived/core/layer4.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
#include <fcntl.h>
#include <netinet/in.h>
#include <net/if.h>
#ifdef _WITH_LVS_
#include <linux/icmp.h>
#include <linux/icmpv6.h>
#ifdef ERRQUEUE_NEEDS_SYS_TIME
#include <sys/time.h>
#endif
#include <linux/errqueue.h>
#endif

#include "layer4.h"
#include "logger.h"
Expand Down

0 comments on commit 3084a92

Please sign in to comment.