From 1fdb21ac697c3686d19fca5ac045f8b0edc3edd3 Mon Sep 17 00:00:00 2001 From: Sonia Sharma Date: Tue, 19 Mar 2019 19:14:13 -0400 Subject: [PATCH] LU-9121 lnet: Add the ioctl handler for "add policy" The ioctl handler for "add policy" de-marshals the udsp rules passed from userspace and then add the rules if there is no copy of the same rules already added. Apply the rules to the existing LNet constructs. Change-Id: Ia76ecdea6de94e1dbcfe71bfcb5a1753fb3c874d Test-Parameters: trivial testlist=lnet-selftest,sanity-lnet Signed-off-by: Sonia Sharma Signed-off-by: Amir Shehata Reviewed-on: https://review.whamcloud.com/34514 Reviewed-by: Serguei Smirnov Tested-by: jenkins Tested-by: Maloo Reviewed-by: Chris Horn --- lnet/include/uapi/linux/lnet/libcfs_ioctl.h | 3 ++- lnet/lnet/api-ni.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lnet/include/uapi/linux/lnet/libcfs_ioctl.h b/lnet/include/uapi/linux/lnet/libcfs_ioctl.h index e6419f0..2ac0c31 100644 --- a/lnet/include/uapi/linux/lnet/libcfs_ioctl.h +++ b/lnet/include/uapi/linux/lnet/libcfs_ioctl.h @@ -149,7 +149,8 @@ struct libcfs_ioctl_data { #define IOC_LIBCFS_SET_HEALHV _IOWR(IOC_LIBCFS_TYPE, 102, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_GET_LOCAL_HSTATS _IOWR(IOC_LIBCFS_TYPE, 103, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_GET_RECOVERY_QUEUE _IOWR(IOC_LIBCFS_TYPE, 104, IOCTL_CONFIG_SIZE) -#define IOC_LIBCFS_MAX_NR 104 +#define IOC_LIBCFS_ADD_UDSP _IOWR(IOC_LIBCFS_TYPE, 105, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_MAX_NR 105 extern int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data); diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 8528b83..2e9ba1b 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -4191,6 +4191,22 @@ LNetCtl(unsigned int cmd, void *arg) return 0; } + case IOC_LIBCFS_ADD_UDSP: { + struct lnet_ioctl_udsp *ioc_udsp = arg; + __u32 bulk_size = ioc_udsp->iou_hdr.ioc_len; + + mutex_lock(&the_lnet.ln_api_mutex); + rc = lnet_udsp_demarshal_add(arg, bulk_size); + if (!rc) { + rc = lnet_udsp_apply_policies(NULL, false); + CDEBUG(D_NET, "policy application returned %d\n", rc); + rc = 0; + } + mutex_unlock(&the_lnet.ln_api_mutex); + + return rc; + } + default: ni = lnet_net2ni_addref(data->ioc_net); if (ni == NULL) -- 1.8.3.1