Whamcloud - gitweb
LU-10124 lnet: Correctly add peer MR value while importing 55/32255/3
authorSonia Sharma <sonia.sharma@intel.com>
Thu, 1 Feb 2018 23:40:03 +0000 (15:40 -0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 2 Mar 2019 01:30:40 +0000 (01: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/32255
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c

index 57d8c56..5a87b19 100644 (file)
@@ -3046,12 +3046,13 @@ static int handle_yaml_config_peer(struct cYAML *tree, struct cYAML **show_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];
+       bool mr_value;
 
        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");
 
@@ -3065,6 +3066,22 @@ static int handle_yaml_config_peer(struct cYAML *tree, struct cYAML **show_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);
@@ -3078,8 +3095,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,
-                                        nids, num,
-                                        (non_mr) ? false : true,
+                                        nids, num, mr_value,
                                         (ip2nets) ? true : false,
                                         (seq_no) ? seq_no->cy_valueint : -1,
                                         err_rc);