Whamcloud - gitweb
LU-11380 llapi: add llapi_fid_parse() helper
[fs/lustre-release.git] / lnet / utils / lnetctl.c
index bce3e90..6bdce42 100644 (file)
@@ -48,15 +48,22 @@ static int jt_show_net(int argc, char **argv);
 static int jt_show_routing(int argc, char **argv);
 static int jt_show_stats(int argc, char **argv);
 static int jt_show_peer(int argc, char **argv);
+static int jt_show_recovery(int argc, char **argv);
 static int jt_show_global(int argc, char **argv);
 static int jt_set_tiny(int argc, char **argv);
 static int jt_set_small(int argc, char **argv);
 static int jt_set_large(int argc, char **argv);
 static int jt_set_numa(int argc, char **argv);
+static int jt_set_retry_count(int argc, char **argv);
+static int jt_set_transaction_to(int argc, char **argv);
+static int jt_set_recov_intrv(int argc, char **argv);
+static int jt_set_rtr_sensitivity(int argc, char **argv);
+static int jt_set_hsensitivity(int argc, char **argv);
 static int jt_add_peer_nid(int argc, char **argv);
 static int jt_del_peer_nid(int argc, char **argv);
 static int jt_set_max_intf(int argc, char **argv);
 static int jt_set_discovery(int argc, char **argv);
+static int jt_set_drop_asym_route(int argc, char **argv);
 static int jt_list_peer(int argc, char **argv);
 /*static int jt_show_peer(int argc, char **argv);*/
 static int lnetctl_list_commands(int argc, char **argv);
@@ -69,10 +76,12 @@ static int jt_route(int argc, char **argv);
 static int jt_net(int argc, char **argv);
 static int jt_routing(int argc, char **argv);
 static int jt_set(int argc, char **argv);
+static int jt_debug(int argc, char **argv);
 static int jt_stats(int argc, char **argv);
 static int jt_global(int argc, char **argv);
 static int jt_peers(int argc, char **argv);
-
+static int jt_set_ni_value(int argc, char **argv);
+static int jt_set_peer_ni_value(int argc, char **argv);
 
 command_t cmd_list[] = {
        {"lnet", jt_lnet, 0, "lnet {configure | unconfigure} [--all]"},
@@ -85,6 +94,7 @@ command_t cmd_list[] = {
        {"import", jt_import, 0, "import FILE.yaml"},
        {"export", jt_export, 0, "export FILE.yaml"},
        {"stats", jt_stats, 0, "stats {show | help}"},
+       {"debug", jt_debug, 0, "debug recovery {local | peer}"},
        {"global", jt_global, 0, "global {show | help}"},
        {"peer", jt_peers, 0, "peer {add | del | show | help}"},
        {"ping", jt_ping, 0, "ping nid,[nid,...]"},
@@ -108,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--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"},
@@ -117,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--health_sensitivity: gateway health sensitivity (>= 1)\n"
         "\t--verbose: display detailed output per route\n"},
        { 0, 0, 0, NULL }
 };
@@ -138,6 +150,10 @@ command_t net_cmds[] = {
         "\t--net: net name (e.g. tcp0) to filter on\n"
         "\t--verbose: display detailed output per network."
                       " Optional argument of '2' outputs more stats\n"},
+       {"set", jt_set_ni_value, 0, "set local NI specific parameter\n"
+        "\t--nid: NI NID to set the\n"
+        "\t--health: specify health value to set\n"
+        "\t--all: set all NIs value to the one specified\n"},
        { 0, 0, 0, NULL }
 };
 
@@ -151,6 +167,13 @@ command_t stats_cmds[] = {
        { 0, 0, 0, NULL }
 };
 
+command_t debug_cmds[] = {
+       {"recovery", jt_show_recovery, 0, "list recovery queues\n"
+               "\t--local : list local recovery queue\n"
+               "\t--peer : list peer recovery queue\n"},
+       { 0, 0, 0, NULL }
+};
+
 command_t global_cmds[] = {
        {"show", jt_show_global, 0, "show global variables\n"},
        { 0, 0, 0, NULL }
@@ -174,6 +197,23 @@ command_t set_cmds[] = {
        {"discovery", jt_set_discovery, 0, "enable/disable peer discovery\n"
         "\t0 - disable peer discovery\n"
         "\t1 - enable peer discovery (default)\n"},
+       {"drop_asym_route", jt_set_drop_asym_route, 0,
+        "drop/accept asymmetrical route messages\n"
+        "\t0 - accept asymmetrical route messages (default)\n"
+        "\t1 - drop asymmetrical route messages\n"},
+       {"retry_count", jt_set_retry_count, 0, "number of retries\n"
+        "\t0 - turn of retries\n"
+        "\t>0 - number of retries\n"},
+       {"transaction_timeout", jt_set_transaction_to, 0, "Message/Response timeout\n"
+        "\t>0 - timeout in seconds\n"},
+       {"health_sensitivity", jt_set_hsensitivity, 0, "sensitivity to failure\n"
+        "\t0 - turn off health evaluation\n"
+        "\t>0 - sensitivity value not more than 1000\n"},
+       {"recovery_interval", jt_set_recov_intrv, 0, "interval to ping in seconds (at least 1)\n"
+        "\t>0 - time in seconds between pings\n"},
+       {"router_sensitivity", jt_set_rtr_sensitivity, 0, "router sensitivity %\n"
+        "\t100 - router interfaces need to be fully healthy to be used\n"
+        "\t<100 - router interfaces can be used even if not healthy\n"},
        { 0, 0, 0, NULL }
 };
 
@@ -183,16 +223,22 @@ command_t peer_cmds[] = {
         "\t            NID in the list becomes the Primary NID of a newly created\n"
         "\t            peer. \n"
         "\t--nid: one or more peer NIDs\n"
-        "\t--non_mr: create this peer as not Multi-Rail capable\n"},
+        "\t--non_mr: create this peer as not Multi-Rail capable\n"
+        "\t--ip2nets: specify a range of nids per peer"},
        {"del", jt_del_peer_nid, 0, "delete a peer NID\n"
         "\t--prim_nid: Primary NID of the peer.\n"
         "\t--nid: list of NIDs to remove. If none provided,\n"
-        "\t       peer is deleted\n"},
+        "\t       peer is deleted\n"
+        "\t--ip2nets: specify a range of nids per peer"},
        {"show", jt_show_peer, 0, "show peer information\n"
         "\t--nid: NID of peer to filter on.\n"
         "\t--verbose: display detailed output per peer."
                       " Optional argument of '2' outputs more stats\n"},
        {"list", jt_list_peer, 0, "list all peers\n"},
+       {"set", jt_set_peer_ni_value, 0, "set peer ni specific parameter\n"
+        "\t--nid: Peer NI NID to set the\n"
+        "\t--health: specify health value to set\n"
+        "\t--all: set all peer_nis values to the one specified\n"},
        { 0, 0, 0, NULL }
 };
 
@@ -326,6 +372,146 @@ static int jt_set_numa(int argc, char **argv)
        return rc;
 }
 
+static int jt_set_recov_intrv(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "recovery_interval", 2, argc, argv);
+       if (rc)
+               return rc;
+
+       rc = parse_long(argv[1], &value);
+       if (rc != 0) {
+               cYAML_build_error(-1, -1, "parser", "set",
+                                 "cannot parse recovery interval value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_recov_intrv(value, -1, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+
+       cYAML_free_tree(err_rc);
+
+       return rc;
+}
+
+static int jt_set_rtr_sensitivity(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "router_sensitivity", 2, argc, argv);
+       if (rc)
+               return rc;
+
+       rc = parse_long(argv[1], &value);
+       if (rc != 0) {
+               cYAML_build_error(-1, -1, "parser", "set",
+                                 "cannot parse router sensitivity value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_rtr_sensitivity(value, -1, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+
+       cYAML_free_tree(err_rc);
+
+       return rc;
+}
+
+static int jt_set_hsensitivity(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "health_sensitivity", 2, argc, argv);
+       if (rc)
+               return rc;
+
+       rc = parse_long(argv[1], &value);
+       if (rc != 0) {
+               cYAML_build_error(-1, -1, "parser", "set",
+                                 "cannot parse health sensitivity value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_hsensitivity(value, -1, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+
+       cYAML_free_tree(err_rc);
+
+       return rc;
+}
+
+static int jt_set_transaction_to(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "transaction_timeout", 2, argc, argv);
+       if (rc)
+               return rc;
+
+       rc = parse_long(argv[1], &value);
+       if (rc != 0) {
+               cYAML_build_error(-1, -1, "parser", "set",
+                                 "cannot parse transaction timeout value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_transaction_to(value, -1, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+
+       cYAML_free_tree(err_rc);
+
+       return rc;
+}
+
+static int jt_set_retry_count(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "retry_count", 2, argc, argv);
+       if (rc)
+               return rc;
+
+       rc = parse_long(argv[1], &value);
+       if (rc != 0) {
+               cYAML_build_error(-1, -1, "parser", "set",
+                                 "cannot parse retry_count value", &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_retry_count(value, -1, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+
+       cYAML_free_tree(err_rc);
+
+       return rc;
+}
+
 static int jt_set_discovery(int argc, char **argv)
 {
        long int value;
@@ -354,6 +540,35 @@ static int jt_set_discovery(int argc, char **argv)
        return rc;
 }
 
+static int jt_set_drop_asym_route(int argc, char **argv)
+{
+       long int value;
+       int rc;
+       struct cYAML *err_rc = NULL;
+
+       rc = check_cmd(set_cmds, "set", "drop_asym_route", 2, argc, argv);
+       if (rc)
+               return rc;
+
+       rc = parse_long(argv[1], &value);
+       if (rc != 0) {
+               cYAML_build_error(-1, -1, "parser", "set",
+                                 "cannot parse drop_asym_route value",
+                                 &err_rc);
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               return -1;
+       }
+
+       rc = lustre_lnet_config_drop_asym_route(value, -1, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+
+       cYAML_free_tree(err_rc);
+
+       return rc;
+}
+
 static int jt_set_tiny(int argc, char **argv)
 {
        long int value;
@@ -528,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;
-       long int hop = -1, prio = -1;
+       long int hop = -1, prio = -1, sen = -1;
        struct cYAML *err_rc = NULL;
        int rc, opt;
 
@@ -538,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 = "health_sensitivity",  .has_arg = required_argument, .val = 's' },
        { .name = NULL } };
 
        rc = check_cmd(route_cmds, "route", "add", 0, argc, argv);
@@ -569,12 +785,24 @@ static int jt_add_route(int argc, char **argv)
                                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:
                        return 0;
                }
        }
 
-       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);
@@ -670,6 +898,8 @@ static int jt_add_ni(int argc, char **argv)
                                                     strlen(optarg), 0,
                                                     UINT_MAX, &global_cpts);
                        break;
+               case '?':
+                       print_help(net_cmds, "net", "add");
                default:
                        return 0;
                }
@@ -725,6 +955,8 @@ static int jt_del_route(int argc, char **argv)
                case 'g':
                        gateway = optarg;
                        break;
+               case '?':
+                       print_help(route_cmds, "route", "del");
                default:
                        return 0;
                }
@@ -773,6 +1005,8 @@ static int jt_del_ni(int argc, char **argv)
                                goto out;
                        }
                        break;
+               case '?':
+                       print_help(net_cmds, "net", "del");
                default:
                        return 0;
                }
@@ -837,6 +1071,8 @@ static int jt_show_route(int argc, char **argv)
                case 'v':
                        detail = 1;
                        break;
+               case '?':
+                       print_help(route_cmds, "route", "show");
                default:
                        return 0;
                }
@@ -856,6 +1092,104 @@ static int jt_show_route(int argc, char **argv)
        return rc;
 }
 
+static int set_value_helper(int argc, char **argv,
+                           int (*cb)(int, bool, char*, int, struct cYAML**))
+{
+       char *nid = NULL;
+       long int healthv = -1;
+       bool all = false;
+       int rc, opt;
+       struct cYAML *err_rc = NULL;
+
+       const char *const short_options = "t:n:a";
+       static const struct option long_options[] = {
+               { .name = "nid", .has_arg = required_argument, .val = 'n' },
+               { .name = "health", .has_arg = required_argument, .val = 't' },
+               { .name = "all", .has_arg = no_argument, .val = 'a' },
+               { .name = NULL } };
+
+       rc = check_cmd(net_cmds, "net", "set", 0, argc, argv);
+       if (rc)
+               return rc;
+
+       while ((opt = getopt_long(argc, argv, short_options,
+                                  long_options, NULL)) != -1) {
+               switch (opt) {
+               case 'n':
+                       nid = optarg;
+                       break;
+               case 't':
+                       if (parse_long(optarg, &healthv) != 0)
+                               healthv = -1;
+                       break;
+               case 'a':
+                       all = true;
+                       break;
+               default:
+                       return 0;
+               }
+       }
+
+       rc = cb(healthv, all, nid, -1, &err_rc);
+
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+
+       cYAML_free_tree(err_rc);
+
+       return rc;
+}
+
+static int jt_set_ni_value(int argc, char **argv)
+{
+       return set_value_helper(argc, argv, lustre_lnet_config_ni_healthv);
+}
+
+static int jt_set_peer_ni_value(int argc, char **argv)
+{
+       return set_value_helper(argc, argv, lustre_lnet_config_peer_ni_healthv);
+}
+
+static int jt_show_recovery(int argc, char **argv)
+{
+       int rc, opt;
+       struct cYAML *err_rc = NULL, *show_rc = NULL;
+
+       const char *const short_options = "lp";
+       static const struct option long_options[] = {
+               { .name = "local", .has_arg = no_argument, .val = 'l' },
+               { .name = "peer", .has_arg = no_argument, .val = 'p' },
+               { .name = NULL } };
+
+       rc = check_cmd(debug_cmds, "recovery", NULL, 0, argc, argv);
+       if (rc)
+               return rc;
+
+       while ((opt = getopt_long(argc, argv, short_options,
+                                  long_options, NULL)) != -1) {
+               switch (opt) {
+               case 'l':
+                       rc = lustre_lnet_show_local_ni_recovq(-1, &show_rc, &err_rc);
+                       break;
+               case 'p':
+                       rc = lustre_lnet_show_peer_ni_recovq(-1, &show_rc, &err_rc);
+                       break;
+               default:
+                       return 0;
+               }
+       }
+
+       if (rc != LUSTRE_CFG_RC_NO_ERR)
+               cYAML_print_tree2file(stderr, err_rc);
+       else if (show_rc)
+               cYAML_print_tree(show_rc);
+
+       cYAML_free_tree(err_rc);
+       cYAML_free_tree(show_rc);
+
+       return rc;
+}
+
 static int jt_show_net(int argc, char **argv)
 {
        char *network = NULL;
@@ -888,6 +1222,8 @@ static int jt_show_net(int argc, char **argv)
                                detail = 1;
                        }
                        break;
+               case '?':
+                       print_help(net_cmds, "net", "show");
                default:
                        return 0;
                }
@@ -978,6 +1314,42 @@ static int jt_show_global(int argc, char **argv)
                goto out;
        }
 
+       rc = lustre_lnet_show_drop_asym_route(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
+       rc = lustre_lnet_show_retry_count(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
+       rc = lustre_lnet_show_transaction_to(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
+       rc = lustre_lnet_show_hsensitivity(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
+       rc = lustre_lnet_show_recov_intrv(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
+       rc = lustre_lnet_show_rtr_sensitivity(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               goto out;
+       }
+
        if (show_rc)
                cYAML_print_tree(show_rc);
 
@@ -1043,6 +1415,17 @@ static int jt_stats(int argc, char **argv)
        return Parser_execarg(argc - 1, &argv[1], stats_cmds);
 }
 
+static int jt_debug(int argc, char **argv)
+{
+       int rc;
+
+       rc = check_cmd(debug_cmds, "recovery", NULL, 2, argc, argv);
+       if (rc)
+               return rc;
+
+       return Parser_execarg(argc - 1, &argv[1], debug_cmds);
+}
+
 static int jt_global(int argc, char **argv)
 {
        int rc;
@@ -1184,6 +1567,7 @@ static int jt_export(int argc, char **argv)
                case 'h':
                default:
                        printf("export > FILE.yaml : export configuration\n"
+                              "\t--backup: export only what's necessary for reconfig\n"
                               "\t--help: display this help\n");
                        return 0;
                }
@@ -1252,6 +1636,13 @@ static int jt_export(int argc, char **argv)
                err_rc = NULL;
        }
 
+       rc = lustre_lnet_show_drop_asym_route(-1, &show_rc, &err_rc);
+       if (rc != LUSTRE_CFG_RC_NO_ERR) {
+               cYAML_print_tree2file(stderr, err_rc);
+               cYAML_free_tree(err_rc);
+               err_rc = NULL;
+       }
+
        if (show_rc != NULL) {
                cYAML_print_tree2file(f, show_rc);
                cYAML_free_tree(show_rc);
@@ -1271,12 +1662,14 @@ static int jt_add_peer_nid(int argc, char **argv)
        struct cYAML *err_rc = NULL;
        int rc = LUSTRE_CFG_RC_NO_ERR, opt, i;
        bool non_mr = false;
+       bool ip2nets = false, nid_list = false, prim_nid_present = false;
 
        const char *const short_opts = "k:mn:";
        const struct option long_opts[] = {
        { .name = "prim_nid",   .has_arg = required_argument,   .val = 'k' },
        { .name = "non_mr",     .has_arg = no_argument,         .val = 'm' },
        { .name = "nid",        .has_arg = required_argument,   .val = 'n' },
+       { .name = "ip2nets",    .has_arg = required_argument,   .val = 'i' },
        { .name = NULL } };
 
        rc = check_cmd(peer_cmds, "peer", "add", 2, argc, argv);
@@ -1287,9 +1680,32 @@ static int jt_add_peer_nid(int argc, char **argv)
                                  long_opts, NULL)) != -1) {
                switch (opt) {
                case 'k':
+                       prim_nid_present = true;
+                       if (ip2nets) {
+                               cYAML_build_error(-1, -1, "peer", "add",
+                                               "ip2nets can not be specified"
+                                               " along side prim_nid parameter.",
+                                               &err_rc);
+                               goto failed;
+                       }
                        prim_nid = optarg;
                        break;
+               case 'i':
                case 'n':
+                       if (opt == 'i')
+                               ip2nets = true;
+
+                       if (opt == 'n')
+                               nid_list = true;
+
+                       if (ip2nets && (nid_list || prim_nid_present)) {
+                               cYAML_build_error(-1, -1, "peer", "add",
+                                               "ip2nets can not be specified"
+                                               " along side nid or prim_nid"
+                                               " parameters", &err_rc);
+                               goto failed;
+                       }
+
                        size = lustre_lnet_parse_nids(optarg, nids, size,
                                                      &nids2);
                        if (nids2 == NULL)
@@ -1300,13 +1716,23 @@ static int jt_add_peer_nid(int argc, char **argv)
                case 'm':
                        non_mr = true;
                        break;
+               case '?':
+                       print_help(peer_cmds, "peer", "add");
                default:
                        return 0;
                }
        }
 
+       for (; optind < argc; optind++) {
+               size = lustre_lnet_parse_nids(argv[optind], nids, size,
+                                               &nids2);
+               if (nids2 == NULL)
+                       goto failed;
+               nids = nids2;
+       }
+
        rc = lustre_lnet_config_peer_nid(prim_nid, nids, size,
-                                        !non_mr, -1, &err_rc);
+                                        !non_mr, ip2nets, -1, &err_rc);
 
 failed:
        if (nids) {
@@ -1330,11 +1756,13 @@ static int jt_del_peer_nid(int argc, char **argv)
        char **nids = NULL, **nids2 = NULL;
        struct cYAML *err_rc = NULL;
        int rc = LUSTRE_CFG_RC_NO_ERR, opt, i, size = 0;
+       bool ip2nets = false, nid_list = false, prim_nid_present = false;
 
        const char *const short_opts = "k:n:";
        const struct option long_opts[] = {
        { .name = "prim_nid",   .has_arg = required_argument,   .val = 'k' },
        { .name = "nid",        .has_arg = required_argument,   .val = 'n' },
+       { .name = "ip2nets",    .has_arg = required_argument,   .val = 'i' },
        { .name = NULL } };
 
        rc = check_cmd(peer_cmds, "peer", "del", 2, argc, argv);
@@ -1345,9 +1773,31 @@ static int jt_del_peer_nid(int argc, char **argv)
                                  long_opts, NULL)) != -1) {
                switch (opt) {
                case 'k':
+                       prim_nid_present = true;
+                       if (ip2nets) {
+                               cYAML_build_error(-1, -1, "peer", "add",
+                                               "ip2nets can not be specified"
+                                               " along side prim_nid parameter.",
+                                               &err_rc);
+                               goto failed;
+                       }
                        prim_nid = optarg;
                        break;
+               case 'i':
                case 'n':
+                       if (opt == 'i')
+                               ip2nets = true;
+
+                       if (opt == 'n')
+                               nid_list = true;
+
+                       if (ip2nets && (nid_list || prim_nid_present)) {
+                               cYAML_build_error(-1, -1, "peer", "add",
+                                               "ip2nets can not be specified"
+                                               " along side nid or prim_nid"
+                                               " parameters", &err_rc);
+                               goto failed;
+                       }
                        size = lustre_lnet_parse_nids(optarg, nids, size,
                                                      &nids2);
                        if (nids2 == NULL)
@@ -1355,12 +1805,22 @@ static int jt_del_peer_nid(int argc, char **argv)
                        nids = nids2;
                        rc = LUSTRE_CFG_RC_OUT_OF_MEM;
                        break;
+               case '?':
+                       print_help(peer_cmds, "peer", "del");
                default:
                        return 0;
                }
        }
 
-       rc = lustre_lnet_del_peer_nid(prim_nid, nids, size, -1, &err_rc);
+       for (; optind < argc; optind++) {
+               size = lustre_lnet_parse_nids(argv[optind], nids, size,
+                                               &nids2);
+               if (nids2 == NULL)
+                       goto failed;
+               nids = nids2;
+       }
+
+       rc = lustre_lnet_del_peer_nid(prim_nid, nids, size, ip2nets, -1, &err_rc);
 
 failed:
        if (nids) {
@@ -1410,6 +1870,8 @@ static int jt_show_peer(int argc, char **argv)
                                detail = 1;
                        }
                        break;
+               case '?':
+                       print_help(peer_cmds, "peer", "show");
                default:
                        return 0;
                }