Whamcloud - gitweb
LU-11297 lnet: set gw sensitivity from lnetctl 35/33635/31
authorAmir Shehata <ashehata@whamcloud.com>
Fri, 9 Nov 2018 19:24:20 +0000 (11:24 -0800)
committerAmir Shehata <ashehata@whamcloud.com>
Fri, 7 Jun 2019 18:20:36 +0000 (18:20 +0000)
Allow an optional parameter from the:
lnetctl route add
command to set the health sensitivity of the gateway
lnetctl route add --net <net> --gateway <gw> --sensitivity <value>

Test-Parameters: forbuildonly
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Change-Id: Iee120c78a41b79da6ab6bdf1560f558df89233e2
Reviewed-on: https://review.whamcloud.com/33635
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Tested-by: Jenkins
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetconfig/liblnetconfig.h
lnet/utils/lnetctl.c

index b9bc07d..e9d7463 100644 (file)
@@ -979,7 +979,7 @@ out:
 }
 
 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
 }
 
 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
-                            int seq_no, struct cYAML **err_rc)
+                            int sen, int seq_no, struct cYAML **err_rc)
 {
        struct lnet_ioctl_config_data data;
        lnet_nid_t gateway_nid;
 {
        struct lnet_ioctl_config_data data;
        lnet_nid_t gateway_nid;
@@ -1040,6 +1040,17 @@ int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
                goto out;
        }
 
                goto out;
        }
 
+       if (sen == -1) {
+               sen = 1;
+       } else if (sen < 1) {
+               snprintf(err_str,
+                        sizeof(err_str),
+                       "\"invalid health sensitivity %d, must be 1 or greater\"",
+                       sen );
+               rc = LUSTRE_CFG_RC_OUT_OF_RANGE_PARAM;
+               goto out;
+       }
+
        rc = lnet_expr2ips(gw, ip_list,
                           &ip2nets, &net, err_str);
        if (rc == LUSTRE_CFG_RC_LAST_ELEM)
        rc = lnet_expr2ips(gw, ip_list,
                           &ip2nets, &net, err_str);
        if (rc == LUSTRE_CFG_RC_LAST_ELEM)
@@ -1053,6 +1064,7 @@ int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
        data.cfg_net = rnet;
        data.cfg_config_u.cfg_route.rtr_hop = hops;
        data.cfg_config_u.cfg_route.rtr_priority = prio;
        data.cfg_net = rnet;
        data.cfg_config_u.cfg_route.rtr_hop = hops;
        data.cfg_config_u.cfg_route.rtr_priority = prio;
+       data.cfg_config_u.cfg_route.rtr_sensitivity = sen;
 
        for (i = MAX_NUM_IPS - 1; i > ip_idx; i--) {
                gateway_nid = LNET_MKNID(net, ip_list[i]);
 
        for (i = MAX_NUM_IPS - 1; i > ip_idx; i--) {
                gateway_nid = LNET_MKNID(net, ip_list[i]);
@@ -1283,6 +1295,11 @@ int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
                                                cfg_route.rtr_priority) == NULL)
                                goto out;
 
                                                cfg_route.rtr_priority) == NULL)
                                goto out;
 
+                       if (cYAML_create_number(item, "health_sensitivity",
+                                               data.cfg_config_u.
+                                               cfg_route.rtr_sensitivity) == NULL)
+                               goto out;
+
                        if (!backup &&
                            cYAML_create_string(item, "state",
                                                data.cfg_config_u.cfg_route.
                        if (!backup &&
                            cYAML_create_string(item, "state",
                                                data.cfg_config_u.cfg_route.
@@ -3930,18 +3947,20 @@ typedef int (*cmd_handler_t)(struct cYAML *tree,
 static int handle_yaml_config_route(struct cYAML *tree, struct cYAML **show_rc,
                                    struct cYAML **err_rc)
 {
 static int handle_yaml_config_route(struct cYAML *tree, struct cYAML **show_rc,
                                    struct cYAML **err_rc)
 {
-       struct cYAML *net, *gw, *hop, *prio, *seq_no;
+       struct cYAML *net, *gw, *hop, *prio, *sen, *seq_no;
 
        net = cYAML_get_object_item(tree, "net");
        gw = cYAML_get_object_item(tree, "gateway");
        hop = cYAML_get_object_item(tree, "hop");
        prio = cYAML_get_object_item(tree, "priority");
 
        net = cYAML_get_object_item(tree, "net");
        gw = cYAML_get_object_item(tree, "gateway");
        hop = cYAML_get_object_item(tree, "hop");
        prio = cYAML_get_object_item(tree, "priority");
+       sen = cYAML_get_object_item(tree, "health_sensitivity");
        seq_no = cYAML_get_object_item(tree, "seq_no");
 
        return lustre_lnet_config_route((net) ? net->cy_valuestring : NULL,
                                        (gw) ? gw->cy_valuestring : NULL,
                                        (hop) ? hop->cy_valueint : -1,
                                        (prio) ? prio->cy_valueint : -1,
        seq_no = cYAML_get_object_item(tree, "seq_no");
 
        return lustre_lnet_config_route((net) ? net->cy_valuestring : NULL,
                                        (gw) ? gw->cy_valuestring : NULL,
                                        (hop) ? hop->cy_valueint : -1,
                                        (prio) ? prio->cy_valueint : -1,
+                                       (sen) ? sen->cy_valueint : -1,
                                        (seq_no) ? seq_no->cy_valueint : -1,
                                        err_rc);
 }
                                        (seq_no) ? seq_no->cy_valueint : -1,
                                        err_rc);
 }
index a564694..a5cecda 100644 (file)
@@ -92,11 +92,12 @@ int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
  *   gw - gateway
  *   hops - number of hops passed down by the user
  *   prio - priority of the route
  *   gw - gateway
  *   hops - number of hops passed down by the user
  *   prio - priority of the route
+ *   sen - health sensitivity value for the gateway
  *   seq_no - sequence number of the request
  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
  */
 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
  *   seq_no - sequence number of the request
  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
  */
 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
-                            int seq_no, struct cYAML **err_rc);
+                            int sen, int seq_no, struct cYAML **err_rc);
 
 /*
  * lustre_lnet_del_route
 
 /*
  * lustre_lnet_del_route
index 00b3bc9..6bdce42 100644 (file)
@@ -118,7 +118,8 @@ command_t route_cmds[] = {
         "\t--net: net name (e.g. tcp0)\n"
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp)\n"
         "\t--hop: number to final destination (1 < hops < 255)\n"
         "\t--net: net name (e.g. tcp0)\n"
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp)\n"
         "\t--hop: number to final destination (1 < hops < 255)\n"
-        "\t--priority: priority of route (0 - highest prio\n"},
+        "\t--priority: priority of route (0 - highest prio\n"
+        "\t--health_sensitivity: gateway health sensitivity (>= 1)\n"},
        {"del", jt_del_route, 0, "delete a route\n"
         "\t--net: net name (e.g. tcp0)\n"
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp)\n"},
        {"del", jt_del_route, 0, "delete a route\n"
         "\t--net: net name (e.g. tcp0)\n"
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp)\n"},
@@ -127,6 +128,7 @@ command_t route_cmds[] = {
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp) to filter on\n"
         "\t--hop: number to final destination (1 < hops < 255) to filter on\n"
         "\t--priority: priority of route (0 - highest prio to filter on\n"
         "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp) to filter on\n"
         "\t--hop: number to final destination (1 < hops < 255) to filter on\n"
         "\t--priority: priority of route (0 - highest prio to filter on\n"
+        "\t--health_sensitivity: gateway health sensitivity (>= 1)\n"
         "\t--verbose: display detailed output per route\n"},
        { 0, 0, 0, NULL }
 };
         "\t--verbose: display detailed output per route\n"},
        { 0, 0, 0, NULL }
 };
@@ -741,7 +743,7 @@ static int jt_unconfig_lnet(int argc, char **argv)
 static int jt_add_route(int argc, char **argv)
 {
        char *network = NULL, *gateway = NULL;
 static int jt_add_route(int argc, char **argv)
 {
        char *network = NULL, *gateway = NULL;
-       long int hop = -1, prio = -1;
+       long int hop = -1, prio = -1, sen = -1;
        struct cYAML *err_rc = NULL;
        int rc, opt;
 
        struct cYAML *err_rc = NULL;
        int rc, opt;
 
@@ -751,6 +753,7 @@ static int jt_add_route(int argc, char **argv)
        { .name = "gateway",   .has_arg = required_argument, .val = 'g' },
        { .name = "hop-count", .has_arg = required_argument, .val = 'c' },
        { .name = "priority",  .has_arg = required_argument, .val = 'p' },
        { .name = "gateway",   .has_arg = required_argument, .val = 'g' },
        { .name = "hop-count", .has_arg = required_argument, .val = 'c' },
        { .name = "priority",  .has_arg = required_argument, .val = 'p' },
+       { .name = "health_sensitivity",  .has_arg = required_argument, .val = 's' },
        { .name = NULL } };
 
        rc = check_cmd(route_cmds, "route", "add", 0, argc, argv);
        { .name = NULL } };
 
        rc = check_cmd(route_cmds, "route", "add", 0, argc, argv);
@@ -782,6 +785,15 @@ static int jt_add_route(int argc, char **argv)
                                continue;
                        }
                        break;
                                continue;
                        }
                        break;
+               case 's':
+                       rc = parse_long(optarg, &sen);
+                       if (rc != 0) {
+                               /* ingore option */
+                               sen = -1;
+                               continue;
+                       }
+                       break;
+
                case '?':
                        print_help(route_cmds, "route", "add");
                default:
                case '?':
                        print_help(route_cmds, "route", "add");
                default:
@@ -789,7 +801,8 @@ static int jt_add_route(int argc, char **argv)
                }
        }
 
                }
        }
 
-       rc = lustre_lnet_config_route(network, gateway, hop, prio, -1, &err_rc);
+       rc = lustre_lnet_config_route(network, gateway, hop, prio, sen, -1,
+                                     &err_rc);
 
        if (rc != LUSTRE_CFG_RC_NO_ERR)
                cYAML_print_tree2file(stderr, err_rc);
 
        if (rc != LUSTRE_CFG_RC_NO_ERR)
                cYAML_print_tree2file(stderr, err_rc);