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) {
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");
}
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");
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,
}
}
out:
+ if (tun)
+ LIBCFS_FREE(tun, sizeof(struct lnet_ioctl_config_lnd_tunables));
+
return 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);