Whamcloud - gitweb
LU-16508 netlink: resv_start_op for [lnet|lustre]_family 00/49800/13
authorShaun Tancheff <shaun.tancheff@hpe.com>
Fri, 10 Feb 2023 18:02:41 +0000 (12:02 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 9 May 2023 05:46:15 +0000 (05:46 +0000)
Linux v5.0-11693-g3b0f31f2b8c9
  genetlink: make policy common to family

struct genl_family adds policy and resv_start_op members

Linux v6.1-rc2-63-g4fa86555d1cd
  genetlink: piggy back on resv_op to default to a reject policy

struct genl_family needs to set a policy and/or indicate the
commands that should be validated.

Set the resv_start_op higher than the largest command accepted.
to avoid a default policy of NLA_REJECT.

When genl_family has a policy provide one.

HPE-bug-id: LUS-11454
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: If38fbe4c9358bb4f9b57e7d25b8a6df1fba63452
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49800
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: xinliang <xinliang.liu@linaro.org>
lnet/lnet/api-ni.c
lnet/selftest/conctl.c
lustre/autoconf/lustre-core.m4
lustre/obdclass/kernelcomm.c

index 224526d..bde1df9 100644 (file)
@@ -5774,6 +5774,9 @@ static struct genl_family lnet_family = {
        .n_ops          = ARRAY_SIZE(lnet_genl_ops),
        .mcgrps         = lnet_mcast_grps,
        .n_mcgrps       = ARRAY_SIZE(lnet_mcast_grps),
+#ifdef GENL_FAMILY_HAS_RESV_START_OP
+       .resv_start_op  = __LNET_CMD_MAX_PLUS_ONE,
+#endif
 };
 
 void LNetDebugPeer(struct lnet_processid *id)
index fef72dc..4cb7dd3 100644 (file)
@@ -1394,6 +1394,9 @@ static struct genl_family lst_family = {
        .n_ops          = ARRAY_SIZE(lst_genl_ops),
        .mcgrps         = lst_mcast_grps,
        .n_mcgrps       = ARRAY_SIZE(lst_mcast_grps),
+#ifdef GENL_FAMILY_HAS_RESV_START_OP
+       .resv_start_op  = __LNET_SELFTEST_CMD_MAX_PLUS_ONE,
+#endif
 };
 
 int lstcon_init_netlink(void)
index 7280e58..fa8f8b1 100644 (file)
@@ -2692,6 +2692,30 @@ AC_DEFUN([LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK], [
 ]) # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
 
 #
+# LC_GENL_FAMILY_HAS_RESV_START_OP
+#
+# Linux v5.0-11693-g3b0f31f2b8c9
+#   genetlink: make policy common to family
+#
+AC_DEFUN([LC_SRC_GENL_FAMILY_HAS_RESV_START_OP], [
+       LB2_LINUX_TEST_SRC([genl_family_has_resv_start_op], [
+               #include <net/genetlink.h>
+       ],[
+               static const struct genl_family family = {
+                       .resv_start_op = 42,
+               };
+               (void)family;
+       ],[-Werror])
+])
+AC_DEFUN([LC_GENL_FAMILY_HAS_RESV_START_OP], [
+       AC_MSG_CHECKING([if struct genl_family has resv_start_op member])
+       LB2_LINUX_TEST_RESULT([genl_family_has_resv_start_op], [
+               AC_DEFINE(GENL_FAMILY_HAS_RESV_START_OP, 1,
+                       [struct genl_family has resv_start_op member])
+       ])
+]) # LC_GENL_FAMILY_HAS_RESV_START_OP
+
+#
 # LC_HAVE_BVEC_ITER_ALL
 #
 # kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
@@ -3786,6 +3810,9 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [
        LC_SRC_UAPI_LINUX_MOUNT_H
        LC_SRC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
 
+       # 5.0
+       LC_SRC_GENL_FAMILY_HAS_RESV_START_OP
+
        # 5.1
        LC_SRC_HAVE_BVEC_ITER_ALL
 
@@ -4033,6 +4060,9 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [
        LC_UAPI_LINUX_MOUNT_H
        LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
 
+       # 5.0
+       LC_GENL_FAMILY_HAS_RESV_START_OP
+
        # 5.1
        LC_HAVE_BVEC_ITER_ALL
 
index 8407825..61cad4a 100644 (file)
@@ -314,6 +314,9 @@ static struct genl_family lustre_family = {
        .n_ops          = ARRAY_SIZE(lustre_genl_ops),
        .mcgrps         = lustre_mcast_grps,
        .n_mcgrps       = ARRAY_SIZE(lustre_mcast_grps),
+#ifdef GENL_FAMILY_HAS_RESV_START_OP
+       .resv_start_op  = __LUSTRE_CMD_MAX_PLUS_ONE,
+#endif
 };
 
 /**