Whamcloud - gitweb
LU-17621 lnet: fix conns_per_peer bounds check 26/54326/4
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Fri, 8 Mar 2024 03:28:43 +0000 (08:58 +0530)
committerOleg Drokin <green@whamcloud.com>
Sat, 23 Mar 2024 06:12:03 +0000 (06:12 +0000)
Logical opreator '||' would always result in 'TRUE',
allowing any arbitrary conns_per_peer value to be set.
Change Logical operator from '||' to '&&' to correctly
compare that the value is within range.

Test-Parameters: trivial testlist=sanity-lnet
Fixes: 9b05e872482e ("LU-10391 lnet: support updating LNet local NI settings")
CoverityID: 415060 ("Logically dead code")
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: Ibcaf18060cae1fc62fe41ee6237abaad1fd2de7f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54326
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lnet/klnds/o2iblnd/o2iblnd.c

index 4277f8b..03fce9f 100644 (file)
@@ -1382,7 +1382,7 @@ kiblnd_nl_set(int cmd, struct nlattr *attr, int type, void *data)
                break;
        case LNET_NET_O2IBLND_TUNABLES_ATTR_CONNS_PER_PEER:
                num = nla_get_s64(attr);
-               if (num > -1 || num < 128)
+               if (num >= 0 && num < 128)
                        tunables->lnd_tun_u.lnd_o2ib.lnd_conns_per_peer = num;
                else
                        rc = -ERANGE;