Whamcloud - gitweb
LU-10124 lnet: Correctly add peer MR value while importing 38/31138/8
authorSonia Sharma <sonia.sharma@intel.com>
Thu, 1 Feb 2018 23:40:03 +0000 (15:40 -0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 21 Sep 2018 03:30:03 +0000 (03:30 +0000)
while adding peer using lnetctl import, the MR value of the
peer is not correctly imported.

Checks for MR value other than True/False in
handle_yaml_config_peer() -
1. No value provided - Use default as True
2. Value other than True/False - Error out

Change-Id: I02a21e35086f1c6f29081b464dd1a63aba692cbc
Test-Parameters: trivial
Signed-off-by: Sonia Sharma <sonia.sharma@intel.com>
Reviewed-on: https://review.whamcloud.com/31138
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c

index 7c5128e..ecc72e2 100644 (file)
@@ -4217,12 +4217,13 @@ static int handle_yaml_config_peer(struct cYAML *tree, struct cYAML **show_rc,
 {
        char **nids = NULL;
        int num, rc;
 {
        char **nids = NULL;
        int num, rc;
-       struct cYAML *seq_no, *prim_nid, *non_mr, *ip2nets, *peer_nis;
+       struct cYAML *seq_no, *prim_nid, *mr, *ip2nets, *peer_nis;
        char err_str[LNET_MAX_STR_LEN];
        char err_str[LNET_MAX_STR_LEN];
+       bool mr_value;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
        prim_nid = cYAML_get_object_item(tree, "primary nid");
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
        prim_nid = cYAML_get_object_item(tree, "primary nid");
-       non_mr = cYAML_get_object_item(tree, "non_mr");
+       mr = cYAML_get_object_item(tree, "Multi-Rail");
        ip2nets = cYAML_get_object_item(tree, "ip2nets");
        peer_nis = cYAML_get_object_item(tree, "peer ni");
 
        ip2nets = cYAML_get_object_item(tree, "ip2nets");
        peer_nis = cYAML_get_object_item(tree, "peer ni");
 
@@ -4236,6 +4237,22 @@ static int handle_yaml_config_peer(struct cYAML *tree, struct cYAML **show_rc,
                return rc;
        }
 
                return rc;
        }
 
+       if (!mr)
+               mr_value = true;
+       else {
+               if (!mr->cy_valuestring || !strcmp(mr->cy_valuestring, "True"))
+                       mr_value = true;
+               else if (!strcmp(mr->cy_valuestring, "False"))
+                       mr_value = false;
+               else {
+                       rc = LUSTRE_CFG_RC_BAD_PARAM;
+                       snprintf(err_str, sizeof(err_str), "Bad MR value");
+                       cYAML_build_error(rc, (seq_no) ? seq_no->cy_valueint : -1,
+                                         ADD_CMD, "peer", err_str, err_rc);
+                       return rc;
+               }
+       }
+
        num = yaml_copy_peer_nids((ip2nets) ? ip2nets : peer_nis, &nids,
                                  (prim_nid) ? prim_nid->cy_valuestring : NULL,
                                   false);
        num = yaml_copy_peer_nids((ip2nets) ? ip2nets : peer_nis, &nids,
                                  (prim_nid) ? prim_nid->cy_valuestring : NULL,
                                   false);
@@ -4249,8 +4266,7 @@ static int handle_yaml_config_peer(struct cYAML *tree, struct cYAML **show_rc,
        }
 
        rc = lustre_lnet_config_peer_nid((prim_nid) ? prim_nid->cy_valuestring : NULL,
        }
 
        rc = lustre_lnet_config_peer_nid((prim_nid) ? prim_nid->cy_valuestring : NULL,
-                                        nids, num,
-                                        (non_mr) ? false : true,
+                                        nids, num, mr_value,
                                         (ip2nets) ? true : false,
                                         (seq_no) ? seq_no->cy_valueint : -1,
                                         err_rc);
                                         (ip2nets) ? true : false,
                                         (seq_no) ? seq_no->cy_valueint : -1,
                                         err_rc);