Whamcloud - gitweb
LU-16801 lnet: Use dynamic allocation for LND tunables 72/50872/2
authorChris Horn <chris.horn@hpe.com>
Fri, 5 May 2023 18:27:00 +0000 (12:27 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 May 2023 07:06:25 +0000 (07:06 +0000)
Increasing size of lnet_ioctl_config_lnd_tunables can cause us to
trip Werror=frame-larger-than warning in lnet_net_cmd() and its
call to static function lnet_genl_parse_local_ni() (seen on
ubuntu2004 and ubuntu2204.) Dynamically allocate this memory instead.

Also modify how LND tunables are initialized in
handle_yaml_config_ni() to match what is done in
lnet_genl_parse_local_ni().

Test-Parameters: trivial
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Change-Id: I6d169ac44521e98958feee70fc5ed73ffb8a7fcd
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50872
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/api-ni.c
lnet/utils/lnetconfig/liblnetconfig.c

index bde1df9..36fa905 100644 (file)
@@ -5069,16 +5069,21 @@ lnet_genl_parse_local_ni(struct nlattr *entry, struct genl_info *info,
                         bool *ni_list)
 {
        bool create = info->nlhdr->nlmsg_flags & NLM_F_CREATE;
-       struct lnet_ioctl_config_lnd_tunables tun;
+       struct lnet_ioctl_config_lnd_tunables *tun;
        struct nlattr *settings;
        int rem3, rc = 0;
 
-       memset(&tun, 0, sizeof(tun));
+       LIBCFS_ALLOC(tun, sizeof(struct lnet_ioctl_config_lnd_tunables));
+       if (!tun) {
+               GENL_SET_ERR_MSG(info, "cannot allocate memory for tunables");
+               GOTO(out, rc = -ENOMEM);
+       }
+
        /* Use LND defaults */
-       tun.lt_cmn.lct_peer_timeout = -1;
-       tun.lt_cmn.lct_peer_tx_credits = -1;
-       tun.lt_cmn.lct_peer_rtr_credits = -1;
-       tun.lt_cmn.lct_max_tx_credits = -1;
+       tun->lt_cmn.lct_peer_timeout = -1;
+       tun->lt_cmn.lct_peer_tx_credits = -1;
+       tun->lt_cmn.lct_peer_rtr_credits = -1;
+       tun->lt_cmn.lct_max_tx_credits = -1;
        conf->lic_ncpts = 0;
 
        nla_for_each_nested(settings, entry, rem3) {
@@ -5124,7 +5129,7 @@ lnet_genl_parse_local_ni(struct nlattr *entry, struct genl_info *info,
                                GOTO(out, rc = -EINVAL);
                        }
 
-                       rc = lnet_genl_parse_tunables(settings, &tun);
+                       rc = lnet_genl_parse_tunables(settings, tun);
                        if (rc < 0) {
                                GENL_SET_ERR_MSG(info,
                                                 "failed to parse tunables");
@@ -5149,7 +5154,7 @@ lnet_genl_parse_local_ni(struct nlattr *entry, struct genl_info *info,
                        }
 
                        rc = lnet_genl_parse_lnd_tunables(settings,
-                                                         &tun.lt_tun, lnd);
+                                                         &tun->lt_tun, lnd);
                        if (rc < 0) {
                                GENL_SET_ERR_MSG(info,
                                                 "failed to parse lnd tunables");
@@ -5238,7 +5243,7 @@ lnet_genl_parse_local_ni(struct nlattr *entry, struct genl_info *info,
                        GOTO(out, rc);
                }
 
-               rc = lnet_dyn_add_ni(conf, net_id, &tun);
+               rc = lnet_dyn_add_ni(conf, net_id, tun);
                switch (rc) {
                case -ENOENT:
                        GENL_SET_ERR_MSG(info,
@@ -5256,6 +5261,9 @@ lnet_genl_parse_local_ni(struct nlattr *entry, struct genl_info *info,
                }
        }
 out:
+       if (tun)
+               LIBCFS_FREE(tun, sizeof(struct lnet_ioctl_config_lnd_tunables));
+
        return rc;
 }
 
index ec326ef..208743d 100644 (file)
@@ -4547,6 +4547,11 @@ static int handle_yaml_config_ni(struct cYAML *tree, struct cYAML **show_rc,
        bool found = false;
 
        memset(&tunables, 0, sizeof(tunables));
+       /* Use LND defaults */
+       tunables.lt_cmn.lct_peer_timeout = -1;
+       tunables.lt_cmn.lct_peer_tx_credits = -1;
+       tunables.lt_cmn.lct_peer_rtr_credits = -1;
+       tunables.lt_cmn.lct_max_tx_credits = -1;
 
        INIT_LIST_HEAD(&nw_descr.network_on_rule);
        INIT_LIST_HEAD(&nw_descr.nw_intflist);