Skip to content

Commit 7a7967a

Browse files
committed
build/netlink: Update tests and remove dead code
Remove the libnl v1/v3 checks, because no one calls them. The netlink reachable component does use libnl, but uses the route interface specifically, which is a libnl v3 thing, so have it call OAC_CHECK_PACKAGE directly looking for the route interface. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 4a37981 commit 7a7967a

File tree

2 files changed

+46
-195
lines changed

2 files changed

+46
-195
lines changed

config/opal_check_libnl.m4

Lines changed: 17 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,23 @@ AC_DEFUN([OPAL_LIBNL_SANITY_INIT], [
3838
opal_libnl_version=0
3939
opal_libnlv1_libs=
4040
opal_libnlv3_libs=
41+
4142
AC_ARG_WITH([libnl],
4243
[AS_HELP_STRING([--with-libnl(=DIR)],
43-
[Directory prefix for libnl (typically only necessary if libnl is installed in a location that the compiler/linker will not search by default)])])
44-
45-
# The --with options carry two pieces of information: 1) do
46-
# you want a specific version of libnl, and 2) where that
47-
# version of libnl lives. For simplicity, let's separate
48-
# those two pieces of information.
49-
case "$with_libnl" in
50-
no)
51-
# Nope, don't want it
52-
opal_want_libnl=no
53-
;;
54-
"")
55-
# Just try to build with libnl
56-
opal_want_libnl=try
57-
opal_libnl_location=
58-
;;
59-
yes)
60-
# Yes, definitely want it
61-
opal_want_libnl=yes
62-
opal_libnl_location=
63-
;;
64-
*)
65-
# Yes, definitely want it -- at a specific location
66-
opal_want_libnl=yes
67-
opal_libnl_location=$with_libnl
68-
;;
69-
esac
44+
[Directory prefix for libnlv3 (typically only necessary if libnl is installed in a location that the compiler/linker will not search by default)])])
45+
AC_ARG_WITH([libn-libdirl],
46+
[AS_HELP_STRING([--with-libnl-libdir=DIR],
47+
[Directory prefix for libnlv3 libs(typically only necessary if libnl is installed in a location that the compiler/linker will not search by default)])])
48+
49+
# ugly hack to deal with potentially alternate locations for
50+
# libnl3 headers. Note that if the pkg-config file is found,
51+
# this ugly hack won't be used.
52+
AS_IF([test -n "$with_libnl_incdir"],
53+
[# skip check if someone above set incdir],
54+
[test -d "/usr/include/libnl3"],
55+
[with_libnl_incdir="/usr/include/libnl3"],
56+
[test -d "/usr/local/include/libnl3"],
57+
[with_libnl_incdir="/usr/local/include/libnl3"])
7058

7159
OAC_CHECK_PACKAGE_VERIFY_COMMANDS([[OPAL_LIBNL_CHECK_PACKAGE_CALLBACK]])
7260
])
@@ -106,10 +94,10 @@ AC_DEFUN([OPAL_LIBNL_CHECK_PACKAGE_CALLBACK], [
10694

10795
dnl OPAL_LIBNL_SANITY_CHECK(lib, function, LIBS, libnl_check_ok)
10896
dnl
109-
dnl This macro is invoked from OPAL_CHECK_PACKAGE to make sure that
97+
dnl This macro is invoked from CHECK_PACKAGE to make sure that
11098
dnl new libraries that are added to LIBS do not pull in conflicting
11199
dnl versions of libnl. E.g., if we already have a library in LIBS
112-
dnl that pulls in libnl v3, if OPAL_CHECK_PACKAGE is later called that
100+
dnl that pulls in libnl v3, if CHECK_PACKAGE is later called that
113101
dnl pulls in a library that pulls in libnl v1, this macro will detect
114102
dnl the conflict and will abort configure.
115103
dnl
@@ -220,159 +208,6 @@ EOF
220208
OPAL_VAR_SCOPE_POP([ldd_output libnl_sane this_requires_v1 this_requires_v3 result_msg])
221209
])
222210

223-
dnl
224-
dnl Check for libnl-3.
225-
dnl
226-
dnl Inputs:
227-
dnl
228-
dnl $1: prefix where to look for libnl-3
229-
dnl $2: var name prefix of _CPPFLAGS and _LDFLAGS and _LIBS
230-
dnl
231-
dnl Outputs:
232-
dnl
233-
dnl - Set $2_CPPFLAGS necessary to compile with libnl-3
234-
dnl - Set $2_LDFLAGS necessary to link with libnl-3
235-
dnl - Set $2_LIBS necessary to link with libnl-3
236-
dnl - Set OPAL_HAVE_LIBNL3 1 if libnl-3 will be used
237-
dnl
238-
AC_DEFUN([OPAL_CHECK_LIBNL_V3],[
239-
OPAL_VAR_SCOPE_PUSH([CPPFLAGS_save opal_tmp_CPPFLAGS LIBS_save LDFLAGS_save])
240-
AC_MSG_NOTICE([checking for libnl v3])
241-
242-
AS_IF([test "$opal_want_libnl" != "no"],
243-
[AS_IF([test -z "$opal_libnl_location"],
244-
[AC_MSG_CHECKING([for /usr/include/libnl3])
245-
AS_IF([test -d "/usr/include/libnl3"],
246-
[opal_tmp_CPPFLAGS=-I/usr/include/libnl3
247-
opal_libnlv3_happy=1
248-
AC_MSG_RESULT([found])],
249-
[AC_MSG_RESULT([not found])
250-
AC_MSG_CHECKING([for /usr/local/include/libnl3])
251-
AS_IF([test -d "/usr/local/include/libnl3"],
252-
[opal_tmp_CPPFLAGS=-I/usr/local/include/netlink3
253-
opal_libnlv3_happy=1
254-
AC_MSG_RESULT([found])],
255-
[opal_libnlv3_happy=0
256-
AC_MSG_RESULT([not found])])])],
257-
[AC_MSG_CHECKING([for $1/include/libnl3])
258-
AS_IF([test -d "$1/include/libnl3"],
259-
[opal_tmp_CPPFLAGS="-I$1/include/libnl3"
260-
opal_libnlv3_happy=1
261-
AC_MSG_RESULT([found])],
262-
[opal_libnlv3_happy=0
263-
AC_MSG_RESULT([not found])])])
264-
CPPFLAGS_save=$CPPFLAGS
265-
CPPFLAGS="$opal_tmp_CPPFLAGS $CPPFLAGS"
266-
267-
# Random note: netlink/version.h is only in libnl v3 - it is not in libnl v1.
268-
# Also, nl_recvmsgs_report is only in libnl v3.
269-
AS_IF([test $opal_libnlv3_happy -eq 1],
270-
[OPAL_CHECK_PACKAGE([$2],
271-
[netlink/version.h],
272-
[nl-3],
273-
[nl_recvmsgs_report],
274-
[],
275-
[$1],
276-
[],
277-
[],
278-
[opal_libnlv3_happy=0])
279-
280-
# Note that OPAL_CHECK_PACKAGE is going to add
281-
# -I$dir/include into $2_CPPFLAGS. But because libnl v3
282-
# puts the headers in $dir/include/libnl3, we need to
283-
# overwrite $2_CPPFLAGS with -I$dir/include/libnl3. We can do
284-
# this unconditionally; we don't have to check for
285-
# success (checking for success occurs below).
286-
$2_CPPFLAGS=$opal_tmp_CPPFLAGS])
287-
288-
# If we found libnl-3, we *also* need libnl-route-3
289-
LIBS_save=$LIBS
290-
LDFLAGS_save=$LDFLAGS
291-
AS_IF([test -n "$$2_LDFLAGS"],
292-
[LDFLAGS="$$2_LDFLAGS $LDFLAGS"])
293-
AS_IF([test $opal_libnlv3_happy -eq 1],
294-
[AC_SEARCH_LIBS([nl_rtgen_request],
295-
[nl-route-3],
296-
[],
297-
[opal_libnlv3_happy=0])])
298-
LIBS=$LIBS_save
299-
LDFLAGS=$LDFLAGS_save
300-
301-
# Just because libnl* is evil, double check that the
302-
# netlink/version.h we found was for libnl v3. As far as we
303-
# know, netlink/version.h only first appeared in version
304-
# 3... but let's really be sure.
305-
AS_IF([test $opal_libnlv3_happy -eq 1],
306-
[AC_MSG_CHECKING([to ensure these really are libnl v3 headers])
307-
AS_IF([test -n "$$2_CPPFLAGS"],
308-
[CPPFLAGS="$$2_CPPFLAGS $CPPFLAGS"])
309-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
310-
#include <netlink/netlink.h>
311-
#include <netlink/version.h>
312-
#ifndef LIBNL_VER_MAJ
313-
#error "LIBNL_VER_MAJ not defined!"
314-
#endif
315-
/* to the best of our knowledge, version.h only exists in libnl v3 */
316-
#if LIBNL_VER_MAJ != 3
317-
#error "LIBNL_VER_MAJ != 3, I am sad"
318-
#endif
319-
]])],
320-
[AC_MSG_RESULT([yes])],
321-
[AC_MSG_RESULT([no])
322-
opal_libnlv3_happy=0])])
323-
324-
CPPFLAGS=$CPPFLAGS_save],
325-
326-
[opal_libnlv3_happy=0])
327-
328-
# If we found everything
329-
AS_IF([test $opal_libnlv3_happy -eq 1],
330-
[$2_LIBS="-lnl-3 -lnl-route-3"
331-
OPAL_HAVE_LIBNL3=1],
332-
[# OPAL_CHECK_PACKAGE(...,nl_recvmsgs_report,...) might have set the variables below
333-
# so reset them if libnl v3 cannot be used
334-
$2_CPPFLAGS=""
335-
$2_LDFLAGS=""
336-
$2_LIBS=""])
337-
338-
OPAL_VAR_SCOPE_POP
339-
])
340-
341-
dnl
342-
dnl Check for libnl.
343-
dnl
344-
dnl Inputs:
345-
dnl
346-
dnl $1: prefix where to look for libnl
347-
dnl $2: var name prefix of _CPPFLAGS and _LDFLAGS and _LIBS
348-
dnl
349-
dnl Outputs:
350-
dnl
351-
dnl - Set $2_CPPFLAGS necessary to compile with libnl
352-
dnl - Set $2_LDFLAGS necessary to link with libnl
353-
dnl - Set $2_LIBS necessary to link with libnl
354-
dnl - Set OPAL_HAVE_LIBNL3 0 if libnl will be used
355-
dnl
356-
AC_DEFUN([OPAL_CHECK_LIBNL_V1],[
357-
AC_MSG_NOTICE([checking for libnl v1])
358-
359-
AS_IF([test "$opal_want_libnl" != "no"],
360-
[OPAL_CHECK_PACKAGE([$2],
361-
[netlink/netlink.h],
362-
[nl],
363-
[nl_connect],
364-
[-lm],
365-
[$1],
366-
[],
367-
[opal_libnlv1_happy=1],
368-
[opal_libnlv1_happy=0])],
369-
[opal_libnlv1_happy=0])
370-
371-
AS_IF([test $opal_libnlv1_happy -eq 1],
372-
[$2_LIBS="-lnl -lm"
373-
OPAL_HAVE_LIBNL3=0])
374-
])
375-
376211
dnl
377212
dnl Summarize libnl and libnl3 usage,
378213
dnl and abort if conflict is found

opal/mca/reachable/netlink/configure.m4

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,41 @@ AC_DEFUN([MCA_opal_reachable_netlink_CONFIG],[
2020

2121
OPAL_VAR_SCOPE_PUSH([opal_reachable_netlink_happy])
2222

23-
opal_reachable_netlink_happy=1
24-
AC_CHECK_HEADER([linux/netlink.h], [],
25-
[opal_reachable_netlink_happy=0], [
26-
#include <sys/types.h>
27-
#include <net/if.h>
28-
])
29-
3023
# this is terrible, but libnl-1 and libnl-3 are incompatible in
3124
# weird ways, and once there are libraries in LIBS for one, the
3225
# other is hard to get right. So if someone has already decided
3326
# we have libnl version 1, get out. Otherwise, see if we have
3427
# libnl-3, which is the only version supported by the netlink
3528
# component.
36-
AS_IF([test $opal_libnl_version -eq 1],
37-
[opal_reachable_netlink_happy=0],
38-
[OPAL_CHECK_LIBNL_V3([$opal_libnl_location],
39-
[reachable_netlink])
40-
AS_IF([test "$OPAL_HAVE_LIBNL3" != "1"],
41-
[opal_reachable_netlink_happy=0])])
29+
AS_IF([test $opal_libnl_version -eq 3],
30+
[# Use the libnl base options for the route search
31+
with_libnl_route=${with_libnl}
32+
with_libnl_route_libdir=${with_libnl_libdir}
33+
with_libnl_route_incdir=${with_libnl_incdir}
34+
35+
# The first argument of OAC_CHECK_PACKAGE must be a valid
36+
# shell variable name, which means no dashs. Deal with that
37+
# by being explicit with our module.
38+
m4_define([libnl_route_pkgconfig_module], [libnl-route-3.0])
39+
OAC_CHECK_PACKAGE([libnl_route],
40+
[reachable_netlink],
41+
[netlink/route/route.h],
42+
[nl-route-3 nl-3],
43+
[rtnl_route_get],
44+
[opal_reachable_netlink_happy=1],
45+
[opal_reachable_netlink_happy=0])
46+
47+
# See if we have linux/netlink.h, which is part of the kernal
48+
# ABI headers and not the libnl3 package (so we assume are in
49+
# default includes, as opposed to the libnl directory.
50+
AS_IF([test ${opal_reachable_netlink_happy} -eq 1],
51+
[AC_CHECK_HEADER([linux/netlink.h], [],
52+
[opal_reachable_netlink_happy=0], [
53+
#include <sys/types.h>
54+
#include <net/if.h>
55+
])])],
56+
[AC_MSG_NOTICE([Disabling component because libnl v1 already linked])
57+
opal_reachable_netlink_happy=0])
4258

4359
AS_IF([test $opal_reachable_netlink_happy -eq 1],
4460
[$1],

0 commit comments

Comments
 (0)