Whamcloud - gitweb
LU-7734 lnet: configuration fixes
[fs/lustre-release.git] / lnet / utils / lnetconfig / liblnetconfig.c
index a0ade5f..7202e1e 100644 (file)
@@ -1166,7 +1166,7 @@ lustre_lnet_ioctl_config_ni(struct list_head *intf_list,
                conf = (struct lnet_ioctl_config_ni*) data;
                if (i == 0 && tunables != NULL)
                        tun = (struct lnet_ioctl_config_lnd_tunables*)
-                               (data + sizeof(*conf));
+                               conf->lic_bulk;
 
                LIBCFS_IOC_INIT_V2(*conf, lic_cfg_hdr);
                conf->lic_cfg_hdr.ioc_len = len;
@@ -2106,6 +2106,16 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                            == NULL)
                                goto out;
 
+                       if (cYAML_create_number(peer_ni, "min_tx_credits",
+                                               lpni_cri->cr_peer_min_tx_credits)
+                           == NULL)
+                               goto out;
+
+                       if (cYAML_create_number(peer_ni, "tx_q_num_of_buf",
+                                               lpni_cri->cr_peer_tx_qnob)
+                           == NULL)
+                               goto out;
+
                        if (cYAML_create_number(peer_ni, "available_rtr_credits",
                                                lpni_cri->cr_peer_rtr_credits)
                            == NULL)
@@ -2116,11 +2126,6 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                            == NULL)
                                goto out;
 
-                       if (cYAML_create_number(peer_ni, "tx_q_num_of_buf",
-                                               lpni_cri->cr_peer_tx_qnob)
-                           == NULL)
-                               goto out;
-
                        if (cYAML_create_number(peer_ni, "send_count",
                                                lpni_stats->send_count)
                            == NULL)
@@ -2435,10 +2440,10 @@ failed:
 static bool
 yaml_extract_cmn_tunables(struct cYAML *tree,
                          struct lnet_ioctl_config_lnd_cmn_tunables *tunables,
-                         int *num_global_cpts,
                          struct cfs_expr_list **global_cpts)
 {
        struct cYAML *tun, *item, *smp;
+       int rc;
 
        tun = cYAML_get_object_item(tree, "tunables");
        if (tun != NULL) {
@@ -2456,10 +2461,11 @@ yaml_extract_cmn_tunables(struct cYAML *tree,
                        tunables->lct_max_tx_credits = item->cy_valueint;
                smp = cYAML_get_object_item(tun, "CPT");
                if (smp != NULL) {
-                       *num_global_cpts =
-                               cfs_expr_list_parse(smp->cy_valuestring,
+                       rc = cfs_expr_list_parse(smp->cy_valuestring,
                                                 strlen(smp->cy_valuestring),
                                                 0, UINT_MAX, global_cpts);
+                       if (rc != 0)
+                               *global_cpts = NULL;
                }
 
                return true;
@@ -2471,14 +2477,13 @@ yaml_extract_cmn_tunables(struct cYAML *tree,
 static bool
 yaml_extract_tunables(struct cYAML *tree,
                      struct lnet_ioctl_config_lnd_tunables *tunables,
-                     int *num_global_cpts,
                      struct cfs_expr_list **global_cpts,
                      __u32 net_type)
 {
        bool rc;
 
        rc = yaml_extract_cmn_tunables(tree, &tunables->lt_cmn,
-                                      num_global_cpts, global_cpts);
+                                      global_cpts);
 
        if (!rc)
                return rc;
@@ -2519,7 +2524,7 @@ static int handle_yaml_config_ni(struct cYAML *tree, struct cYAML **show_rc,
 {
        struct cYAML *net, *intf, *seq_no, *ip2net = NULL, *local_nis = NULL,
                     *item = NULL;
-       int num_entries = 0, num_global_cpts = 0, rc;
+       int num_entries = 0, rc;
        struct lnet_dlc_network_descr nw_descr;
        struct cfs_expr_list *global_cpts = NULL;
        struct lnet_ioctl_config_lnd_tunables tunables;
@@ -2562,13 +2567,12 @@ static int handle_yaml_config_ni(struct cYAML *tree, struct cYAML **show_rc,
                }
        }
 
-       found = yaml_extract_tunables(tree, &tunables, &num_global_cpts,
-                                     &global_cpts,
+       found = yaml_extract_tunables(tree, &tunables, &global_cpts,
                                      LNET_NETTYP(nw_descr.nw_id));
        seq_no = cYAML_get_object_item(tree, "seq_no");
 
        rc = lustre_lnet_config_ni(&nw_descr,
-                                  (num_global_cpts > 0) ? global_cpts: NULL,
+                                  global_cpts,
                                   (ip2net) ? ip2net->cy_valuestring : NULL,
                                   (found) ? &tunables: NULL,
                                   (seq_no) ? seq_no->cy_valueint : -1,
@@ -2599,7 +2603,7 @@ static int handle_yaml_config_ip2nets(struct cYAML *tree,
        struct lustre_lnet_ip2nets ip2nets;
        struct lustre_lnet_ip_range_descr *ip_range_descr = NULL,
                                          *tmp = NULL;
-       int rc = LUSTRE_CFG_RC_NO_ERR, num_global_cpts = 0;
+       int rc = LUSTRE_CFG_RC_NO_ERR;
        struct cfs_expr_list *global_cpts = NULL;
        struct cfs_expr_list *el, *el_tmp;
        struct lnet_ioctl_config_lnd_tunables tunables;
@@ -2653,13 +2657,12 @@ static int handle_yaml_config_ip2nets(struct cYAML *tree,
                }
        }
 
-       found = yaml_extract_tunables(tree, &tunables, &num_global_cpts,
-                                     &global_cpts,
+       found = yaml_extract_tunables(tree, &tunables, &global_cpts,
                                      LNET_NETTYP(ip2nets.ip2nets_net.nw_id));
 
        rc = lustre_lnet_config_ip2nets(&ip2nets,
                        (found) ? &tunables : NULL,
-                       (num_global_cpts > 0) ? global_cpts : NULL,
+                       global_cpts,
                        (seq_no) ? seq_no->cy_valueint : -1,
                        err_rc);