[PATCH nfs-utils 05/17] build: add libnl3 and netlink header support for exportd and mountd

Jeff Layton
2026-03-16T15:16:58Z

Add libnl3 dependency and netlink header detection for exportd and
mountd builds. Update the nfsd_netlink.h sentinel to check for
NFSD_A_EXPKEY_SEQNO to ensure the system header includes expkey
support. Add AC_COMPILE_IFELSE check for sunrpc_netlink.h using
SUNRPC_CMD_CACHE_NOTIFY as sentinel.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
configure.ac | 32 +++++++++++++++++++-------------
support/export/Makefile.am | 3 ++-
utils/exportd/Makefile.am | 2 +-
utils/mountd/Makefile.am | 2 +-
4 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index b134c98c7c6e1ba56c2b2a0b4e8d614d58093f35..f8c04fbfeaaafa63c07f7552dd7c71ef234eab10 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,26 +252,32 @@ AC_ARG_ENABLE(nfsdcltrack,
enable_nfsdcltrack=$enableval,
enable_nfsdcltrack="no")

+PKG_CHECK_MODULES(LIBNL3, libnl-3.0 >= 3.1)
+PKG_CHECK_MODULES(LIBNLGENL3, libnl-genl-3.0 >= 3.1)
+
+AC_CHECK_HEADERS(linux/nfsd_netlink.h)
+
+# ensure we have the expkey attributes
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/nfsd_netlink.h>]],
+ [[int foo = NFSD_A_EXPKEY_SEQNO;]])],
+ [AC_DEFINE([USE_SYSTEM_NFSD_NETLINK_H], 1,
+ ["Use system's linux/nfsd_netlink.h"])])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/lockd_netlink.h>]],
+ [[int foo = LOCKD_CMD_SERVER_GET;]])],
+ [AC_DEFINE([USE_SYSTEM_LOCKD_NETLINK_H], 1,
+ ["Use system's linux/lockd_netlink.h"])])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/sunrpc_netlink.h>]],
+ [[int foo = SUNRPC_CMD_CACHE_NOTIFY;]])],
+ [AC_DEFINE([USE_SYSTEM_SUNRPC_NETLINK_H], 1,
+ ["Use system's linux/sunrpc_netlink.h"])])
+
AC_ARG_ENABLE(nfsdctl,
[AS_HELP_STRING([--disable-nfsdctl],[disable nfsdctl program for controlling nfsd@<:@default=no@:>@])],
enable_nfsdctl=$enableval,
enable_nfsdctl="yes")
AM_CONDITIONAL(CONFIG_NFSDCTL, [test "$enable_nfsdctl" = "yes" ])
if test "$enable_nfsdctl" = yes; then
- PKG_CHECK_MODULES(LIBNL3, libnl-3.0 >= 3.1)
- PKG_CHECK_MODULES(LIBNLGENL3, libnl-genl-3.0 >= 3.1)
PKG_CHECK_MODULES(LIBREADLINE, readline)
- AC_CHECK_HEADERS(linux/nfsd_netlink.h)
-
- # ensure we have the MIN_THREADS attribute
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/nfsd_netlink.h>]],
- [[int foo = NFSD_A_SERVER_MIN_THREADS;]])],
- [AC_DEFINE([USE_SYSTEM_NFSD_NETLINK_H], 1,
- ["Use system's linux/nfsd_netlink.h"])])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/lockd_netlink.h>]],
- [[int foo = LOCKD_CMD_SERVER_GET;]])],
- [AC_DEFINE([USE_SYSTEM_LOCKD_NETLINK_H], 1,
- ["Use system's linux/lockd_netlink.h"])])
fi

AC_ARG_ENABLE(nfsv4server,
diff --git a/support/export/Makefile.am b/support/export/Makefile.am
index 7338e1c7e719b2684745e0d71810c9f52d08a3c9..ae7ace44112b889f1c461c5473fb1bd42a42f182 100644
--- a/support/export/Makefile.am
+++ b/support/export/Makefile.am
@@ -14,7 +14,8 @@ libexport_a_SOURCES = client.c export.c hostname.c \
xtab.c mount_clnt.c mount_xdr.c \
cache.c auth.c v4root.c fsloc.c \
v4clients.c
-libexport_a_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) -I$(top_srcdir)/support/reexport
+libexport_a_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) -I$(top_srcdir)/support/reexport \
+ $(LIBNL3_CFLAGS) $(LIBNLGENL3_CFLAGS)

BUILT_SOURCES = $(GENFILES)

diff --git a/utils/exportd/Makefile.am b/utils/exportd/Makefile.am
index 26078c9b11b54d2af7bce0273f1cac577f0d8097..e25166b1aa1871492d11a83decd63e76a1528f9b 100644
--- a/utils/exportd/Makefile.am
+++ b/utils/exportd/Makefile.am
@@ -18,7 +18,7 @@ exportd_LDADD = ../../support/export/libexport.a \
../../support/misc/libmisc.a \
../../support/reexport/libreexport.a \
$(OPTLIBS) $(LIBBLKID) $(LIBPTHREAD) \
- -luuid
+ -luuid $(LIBNL3_LIBS) $(LIBNLGENL3_LIBS)

exportd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \
-I$(top_srcdir)/support/export
diff --git a/utils/mountd/Makefile.am b/utils/mountd/Makefile.am
index 197ef29b4fe4a855da3b26c701fa0b41916ea59c..808baf318fe54ccee13cf60b4cd71ade0444508b 100644
--- a/utils/mountd/Makefile.am
+++ b/utils/mountd/Makefile.am
@@ -20,7 +20,7 @@ mountd_LDADD = ../../support/export/libexport.a \
../../support/reexport/libreexport.a \
$(OPTLIBS) \
$(LIBBSD) $(LIBWRAP) $(LIBNSL) $(LIBBLKID) -luuid $(LIBTIRPC) \
- $(LIBPTHREAD)
+ $(LIBPTHREAD) $(LIBNL3_LIBS) $(LIBNLGENL3_LIBS)

mountd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \
-I$(top_builddir)/support/include \

--
2.53.0