Whamcloud - gitweb
LU-14195 libcfs: test for nla_strscpy 76/46876/5
authorJames Simmons <jsimmons@infradead.org>
Wed, 25 May 2022 14:20:23 +0000 (10:20 -0400)
committerOleg Drokin <green@whamcloud.com>
Sat, 11 Jun 2022 05:29:50 +0000 (05:29 +0000)
During the development of the Linux 5.10 kernel the function
nla_strlcpy() was replaced by nla_strscpy(). Handle this
change for Lustre.

Test-parameters: trivial
Change-Id: I47f12add619cfd88a3692f0760b8bcc35b7877d9
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/46876
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
contrib/scripts/spelling.txt
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-net.h

index b5e3f24..1f1ed81 100644 (file)
@@ -182,6 +182,7 @@ mti_spec||mdi_spec
 mti_tattr||mdi_tattr
 mti_tpattr||mdi_tpattr
 mti_xattr_buf||mdi_xattr_buf
+nla_strlcpy|nla_strscpy
 OS_STATE_DEGRADED||OS_STATFS_DEGRADED
 OS_STATE_READONLY||OS_STATFS_READONLY
 OS_STATE_NOPRECREATE||OS_STATFS_NOPRECREATE
index c711c85..e1bc40d 100644 (file)
@@ -1772,17 +1772,31 @@ list_cmp_func_t, [
 EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_HAVE_LIST_CMP_FUNC_T
 
-AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [
-       LIBCFS_SRC_HAVE_PROC_OPS
-
-       AC_MSG_CHECKING([for available kernel interfaces to libcfs])
-       LB2_LINUX_TEST_COMPILE_ALL([libcfs])
-       AC_MSG_RESULT([done])
-])
-AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [
-       # 5.6
-       LIBCFS_HAVE_PROC_OPS
+#
+# LIBCFS_NLA_STRSCPY
+#
+# Kernel version 5.10-rc3 commit 872f690341948b502c93318f806d821c56772c42
+# replaced nla_strlcpy() with nla_strscpy().
+#
+AC_DEFUN([LIBCFS_SRC_NLA_STRSCPY], [
+       LB2_LINUX_TEST_SRC([nla_strscpy], [
+               #include <net/netlink.h>
+       ],[
+               if (nla_strscpy(NULL, NULL, 0) < 0)
+                       return -EINVAL;
+       ],[
+       ],[])
 ])
+AC_DEFUN([LIBCFS_NLA_STRSCPY], [
+       AC_MSG_CHECKING([if 'nla_strscpy()' exists])
+       LB2_LINUX_TEST_RESULT([nla_strscpy], [
+               AC_DEFINE(HAVE_NLA_STRSCPY, 1,
+                       ['nla_strscpy' is available])
+               AC_MSG_RESULT(yes)
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+]) # LIBCFS_NLA_STRSCPY
 
 #
 # LIBCFS_HAVE_CIPHER_HEADER
@@ -1834,6 +1848,23 @@ param_set_uint_minmax, [
 ])
 ]) # LIBCFS_PARAM_SET_UINT_MINMAX
 
+AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [
+       # 5.6
+       LIBCFS_SRC_HAVE_PROC_OPS
+       # 5.10
+       LIBCFS_SRC_NLA_STRSCPY
+
+       AC_MSG_CHECKING([for available kernel interfaces to libcfs])
+       LB2_LINUX_TEST_COMPILE_ALL([libcfs])
+       AC_MSG_RESULT([done])
+])
+AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [
+       # 5.6
+       LIBCFS_HAVE_PROC_OPS
+       # 5.10
+       LIBCFS_NLA_STRSCPY
+])
+
 #
 # LIBCFS_PROG_LINUX
 #
index a9502a3..4d43894 100644 (file)
 char *nla_strdup(const struct nlattr *nla, gfp_t flags);
 #endif /* !HAVE_NLA_STRDUP */
 
+#ifndef HAVE_NLA_STRSCPY
+#define nla_strscpy    nla_strlcpy
+#endif /* !HAVE_NLA_STRSCPY */
+
 #ifndef HAVE_NL_PARSE_WITH_EXT_ACK
 
 #define NL_SET_BAD_ATTR(extack, attr)