From 8059dbbe97a61e287efe0ae9d1f7767d362aa2d7 Mon Sep 17 00:00:00 2001 From: Sonia Sharma Date: Wed, 31 Jan 2018 02:49:19 -0800 Subject: [PATCH] LU-10554 lnet: Remove LASSERT on userspace data If the net information is not provided while adding NI, it results in an LBUG. Remove the LASSERT on userspace input and handle it gracefully. Test-Parameters: trivial Change-Id: I9d2b6f94cb35e94bc81d5c52936d32cbf833e597 Signed-off-by: Sonia Sharma Reviewed-on: https://review.whamcloud.com/31100 Tested-by: Jenkins Reviewed-by: Amir Shehata Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lnet/lnet/api-ni.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index b3e3eed..59171f3 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -1846,8 +1846,6 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun) if (lnet_net_unique(net->net_id, &the_lnet.ln_nets, &net_l)) { lnd_type = LNET_NETTYP(net->net_id); - LASSERT(libcfs_isknown_lnd(lnd_type)); - mutex_lock(&the_lnet.ln_lnd_mutex); lnd = lnet_find_lnd_by_type(lnd_type); @@ -2747,7 +2745,7 @@ int lnet_dyn_add_ni(struct lnet_ioctl_config_ni *conf) struct lnet_ni *ni; struct lnet_ioctl_config_lnd_tunables *tun = NULL; int rc, i; - __u32 net_id; + __u32 net_id, lnd_type; /* get the tunables if they are available */ if (conf->lic_cfg_hdr.ioc_len >= @@ -2761,6 +2759,12 @@ int lnet_dyn_add_ni(struct lnet_ioctl_config_ni *conf) tun); net_id = LNET_NIDNET(conf->lic_nid); + lnd_type = LNET_NETTYP(net_id); + + if (!libcfs_isknown_lnd(lnd_type)) { + CERROR("No valid net and lnd information provided\n"); + return -EINVAL; + } net = lnet_net_alloc(net_id, NULL); if (!net) -- 1.8.3.1