#include <limits.h>
#include <libcfs/util/ioctl.h>
#include <libcfs/util/parser.h>
-#include <lnet/lnetctl.h>
-#include <lnet/nidstr.h>
#include <cyaml.h>
#include "lnetconfig/liblnetconfig.h"
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_numa(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_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_list_peer(int argc, char **argv);
/*static int jt_show_peer(int argc, char **argv);*/
static int lnetctl_list_commands(int argc, char **argv);
"\t--if: physical interface (e.g. eth0)\n"},
{"show", jt_show_net, 0, "show networks\n"
"\t--net: net name (e.g. tcp0) to filter on\n"
- "\t--verbose: display detailed output per network\n"},
+ "\t--verbose: display detailed output per network."
+ "optional argument of 2 outputs more stats\n"},
{ 0, 0, 0, NULL }
};
{ 0, 0, 0, NULL }
};
-command_t numa_cmds[] = {
- {"show", jt_show_numa, 0, "show NUMA range\n"},
+command_t global_cmds[] = {
+ {"show", jt_show_global, 0, "show global variables\n"},
{ 0, 0, 0, NULL }
};
"\t1 - enable routing\n"},
{"numa_range", jt_set_numa, 0, "set NUMA range for NI selection\n"
"\tVALUE must be at least 0\n"},
+ {"max_interfaces", jt_set_max_intf, 0, "set the default value for "
+ "max interfaces\n"
+ "\tValue must be greater than 16\n"},
+ {"discovery", jt_set_discovery, 0, "enable/disable peer discovery\n"
+ "\t0 - disable peer discovery\n"
+ "\t1 - enable peer discovery (default)\n"},
{ 0, 0, 0, NULL }
};
"\t peer is deleted\n"},
{"show", jt_show_peer, 0, "show peer information\n"
"\t--nid: NID of peer to filter on.\n"
- "\t--verbose: Include extended statistics\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"},
{ 0, 0, 0, NULL }
};
return rc;
}
+static int jt_set_max_intf(int argc, char **argv)
+{
+ long int value;
+ int rc;
+ struct cYAML *err_rc = NULL;
+
+ if (handle_help(set_cmds, "set", "max_interfaces", argc, argv) == 0)
+ return 0;
+
+ rc = parse_long(argv[1], &value);
+ if (rc != 0) {
+ cYAML_build_error(-1, -1, "parser", "set",
+ "cannot parse max_interfaces value", &err_rc);
+ cYAML_print_tree2file(stderr, err_rc);
+ cYAML_free_tree(err_rc);
+ return -1;
+ }
+
+ rc = lustre_lnet_config_max_intf(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_numa(int argc, char **argv)
{
long int value;
return rc;
}
+static int jt_set_discovery(int argc, char **argv)
+{
+ long int value;
+ int rc;
+ struct cYAML *err_rc = NULL;
+
+ if (handle_help(set_cmds, "set", "discovery", argc, argv) == 0)
+ return 0;
+
+ rc = parse_long(argv[1], &value);
+ if (rc != 0) {
+ cYAML_build_error(-1, -1, "parser", "set",
+ "cannot parse discovery value", &err_rc);
+ cYAML_print_tree2file(stderr, err_rc);
+ cYAML_free_tree(err_rc);
+ return -1;
+ }
+
+ rc = lustre_lnet_config_discovery(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;
static int jt_show_net(int argc, char **argv)
{
char *network = NULL;
- int detail = 0, rc, opt;
+ int rc, opt;
struct cYAML *err_rc = NULL, *show_rc = NULL;
+ long int detail = 0;
const char *const short_options = "n:vh";
static const struct option long_options[] = {
{ .name = "net", .has_arg = required_argument, .val = 'n' },
- { .name = "verbose", .has_arg = no_argument, .val = 'v' },
+ { .name = "verbose", .has_arg = optional_argument, .val = 'v' },
{ .name = "help", .has_arg = no_argument, .val = 'h' },
{ .name = NULL } };
network = optarg;
break;
case 'v':
- detail = 1;
+ if ((!optarg) && (argv[optind] != NULL) &&
+ (argv[optind][0] != '-')) {
+ if (parse_long(argv[optind++], &detail) != 0)
+ detail = 1;
+ } else {
+ detail = 1;
+ }
break;
case 'h':
print_help(net_cmds, "net", "show");
}
}
- rc = lustre_lnet_show_net(network, detail, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_net(network, (int) detail, -1, &show_rc, &err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
return rc;
}
-static int jt_show_numa(int argc, char **argv)
+static int jt_show_global(int argc, char **argv)
{
int rc;
struct cYAML *show_rc = NULL, *err_rc = NULL;
- if (handle_help(numa_cmds, "numa", "show", argc, argv) == 0)
+ if (handle_help(global_cmds, "global", "show", argc, argv) == 0)
return 0;
rc = lustre_lnet_show_numa_range(-1, &show_rc, &err_rc);
+ if (rc != LUSTRE_CFG_RC_NO_ERR) {
+ cYAML_print_tree2file(stderr, err_rc);
+ goto out;
+ }
- if (rc != LUSTRE_CFG_RC_NO_ERR)
+ rc = lustre_lnet_show_max_intf(-1, &show_rc, &err_rc);
+ if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
- else if (show_rc)
+ goto out;
+ }
+
+ rc = lustre_lnet_show_discovery(-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);
+out:
cYAML_free_tree(err_rc);
cYAML_free_tree(show_rc);
return Parser_execarg(argc - 1, &argv[1], stats_cmds);
}
-static inline int jt_numa(int argc, char **argv)
+static inline int jt_global(int argc, char **argv)
{
if (argc < 2)
return CMD_HELP;
if (argc == 2 &&
- handle_help(numa_cmds, "numa", NULL, argc, argv) == 0)
+ handle_help(global_cmds, "global", NULL, argc, argv) == 0)
return 0;
- return Parser_execarg(argc - 1, &argv[1], numa_cmds);
+ return Parser_execarg(argc - 1, &argv[1], global_cmds);
}
static inline int jt_peers(int argc, char **argv)
char *file = NULL;
struct cYAML *err_rc = NULL;
struct cYAML *show_rc = NULL;
- int rc = 0, opt, opt_found = 0;
+ int rc = 0, return_rc = 0, opt, opt_found = 0;
char cmd = 'a';
const char *const short_options = "adsh";
{ .name = "add", .has_arg = no_argument, .val = 'a' },
{ .name = "del", .has_arg = no_argument, .val = 'd' },
{ .name = "show", .has_arg = no_argument, .val = 's' },
+ { .name = "exec", .has_arg = no_argument, .val = 'e' },
{ .name = "help", .has_arg = no_argument, .val = 'h' },
{ .name = NULL } };
opt_found = 1;
switch (opt) {
case 'a':
+ cmd = opt;
+ break;
case 'd':
case 's':
cmd = opt;
break;
+ case 'e':
+ cmd = opt;
+ break;
case 'h':
printf("import FILE\n"
"import < FILE : import a file\n"
"\t--add: add configuration\n"
"\t--del: delete configuration\n"
"\t--show: show configuration\n"
+ "\t--exec: execute command\n"
"\t--help: display this help\n"
"If no command option is given then --add"
" is assumed by default\n");
switch (cmd) {
case 'a':
rc = lustre_yaml_config(file, &err_rc);
+ return_rc = lustre_yaml_exec(file, &show_rc, &err_rc);
+ cYAML_print_tree(show_rc);
+ cYAML_free_tree(show_rc);
break;
case 'd':
rc = lustre_yaml_del(file, &err_rc);
cYAML_print_tree(show_rc);
cYAML_free_tree(show_rc);
break;
+ case 'e':
+ rc = lustre_yaml_exec(file, &show_rc, &err_rc);
+ cYAML_print_tree(show_rc);
+ cYAML_free_tree(show_rc);
+ break;
}
- cYAML_print_tree2file(stderr, err_rc);
-
- cYAML_free_tree(err_rc);
+ if (rc || return_rc) {
+ cYAML_print_tree2file(stderr, err_rc);
+ cYAML_free_tree(err_rc);
+ }
return rc;
}
} else
f = stdout;
- rc = lustre_lnet_show_net(NULL, 1, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_net(NULL, 2, -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;
}
rc = lustre_lnet_show_route(NULL, NULL, -1, -1, 1, -1, &show_rc,
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
+ err_rc = NULL;
}
rc = lustre_lnet_show_routing(-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;
}
- rc = lustre_lnet_show_peer(NULL, 1, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_peer(NULL, 2, -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;
}
rc = lustre_lnet_show_numa_range(-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;
+ }
+
+ rc = lustre_lnet_show_max_intf(-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;
+ }
+
+ rc = lustre_lnet_show_discovery(-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) {
rc = LUSTRE_CFG_RC_OUT_OF_MEM;
break;
case 'h':
- print_help(peer_cmds, "peer", "del");
+ print_help(peer_cmds, "peer", "show");
return 0;
default:
return 0;
char *nid = NULL;
int rc, opt;
struct cYAML *err_rc = NULL, *show_rc = NULL;
- int detail = 0;
+ long int detail = 0;
- const char *const short_options = "n:vh";
+ const char *const short_options = "n:v::h";
const struct option long_options[] = {
{ "nid", 1, NULL, 'n' },
- { "verbose", 0, NULL, 'v' },
+ { "verbose", 2, NULL, 'v' },
{ "help", 0, NULL, 'h' },
{ NULL, 0, NULL, 0 },
};
nid = optarg;
break;
case 'v':
- detail = 1;
+ if ((!optarg) && (argv[optind] != NULL) &&
+ (argv[optind][0] != '-')) {
+ if (parse_long(argv[optind++], &detail) != 0)
+ detail = 1;
+ } else {
+ detail = 1;
+ }
break;
case 'h':
print_help(peer_cmds, "peer", "show");
}
}
- rc = lustre_lnet_show_peer(nid, detail, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_peer(nid, (int) detail, -1, &show_rc, &err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
return rc;
}
+static int jt_list_peer(int argc, char **argv)
+{
+ int rc, opt;
+ struct cYAML *err_rc = NULL, *list_rc = NULL;
+
+ const char *const short_options = "h";
+ const struct option long_options[] = {
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+
+ while ((opt = getopt_long(argc, argv, short_options,
+ long_options, NULL)) != -1) {
+ switch (opt) {
+ case 'h':
+ print_help(peer_cmds, "peer", "list");
+ return 0;
+ default:
+ return 0;
+ }
+ }
+
+ rc = lustre_lnet_list_peer(-1, &list_rc, &err_rc);
+
+ if (rc != LUSTRE_CFG_RC_NO_ERR)
+ cYAML_print_tree2file(stderr, err_rc);
+ else if (list_rc)
+ cYAML_print_tree(list_rc);
+
+ cYAML_free_tree(err_rc);
+ cYAML_free_tree(list_rc);
+
+ return rc;
+}
+
+static int jt_ping(int argc, char **argv)
+{
+ struct cYAML *err_rc = NULL;
+ struct cYAML *show_rc = NULL;
+ int timeout = 1000;
+ int rc = 0, opt;
+
+ const char *const short_options = "t:h";
+ const struct option long_options[] = {
+ { "timeout", 1, NULL, 't' },
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+
+ while ((opt = getopt_long(argc, argv, short_options,
+ long_options, NULL)) != -1) {
+ switch (opt) {
+ case 't':
+ timeout = 1000 * atol(optarg);
+ break;
+ case 'h':
+ printf("ping: <nid1> <nid2> .. <nidN> (e.g. 10.2.2.2@tcp)\n"
+ "\t--timeout: timeout(secs)\n"
+ "\t--help: display this help\n");
+ return 0;
+ default:
+ return 0;
+ }
+ }
+
+ if (argc < 2)
+ return CMD_HELP;
+
+ for (; optind < argc; optind++)
+ rc = lustre_lnet_ping_nid(argv[optind], timeout, -1, &show_rc, &err_rc);
+
+ if (show_rc)
+ cYAML_print_tree(show_rc);
+
+ if (err_rc)
+ cYAML_print_tree2file(stderr, err_rc);
+
+ cYAML_free_tree(err_rc);
+ cYAML_free_tree(show_rc);
+
+ return rc;
+}
+
+static int jt_discover(int argc, char **argv)
+{
+ struct cYAML *err_rc = NULL;
+ struct cYAML *show_rc = NULL;
+ int force = 0;
+ int rc = 0, opt;
+
+ const char *const short_options = "fh";
+ const struct option long_options[] = {
+ { "force", 0, NULL, 'f' },
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+
+ while ((opt = getopt_long(argc, argv, short_options,
+ long_options, NULL)) != -1) {
+ switch (opt) {
+ case 'f':
+ force = 1;
+ break;
+ case 'h':
+ printf("discover: nid1 nid2 .. nidN (e.g. 10.2.2.2@tcp)\n"
+ "\t--force\n"
+ "\t--help: display this help\n");
+ return 0;
+ default:
+ return 0;
+ }
+ }
+
+ if (argc < 2)
+ return CMD_HELP;
+
+ for (; optind < argc; optind++)
+ rc = lustre_lnet_discover_nid(argv[optind], force, -1, &show_rc,
+ &err_rc);
+
+ if (show_rc)
+ cYAML_print_tree(show_rc);
+
+ if (err_rc)
+ cYAML_print_tree2file(stderr, err_rc);
+
+ cYAML_free_tree(err_rc);
+ cYAML_free_tree(show_rc);
+
+ return rc;
+}
+
command_t list[] = {
{"lnet", jt_lnet, 0, "lnet {configure | unconfigure} [--all]"},
{"route", jt_route, 0, "route {add | del | show | help}"},
{"net", jt_net, 0, "net {add | del | show | help}"},
{"routing", jt_routing, 0, "routing {show | help}"},
{"set", jt_set, 0, "set {tiny_buffers | small_buffers | large_buffers"
- " | routing}"},
+ " | routing | numa_range | max_interfaces"
+ " | discovery}"},
{"import", jt_import, 0, "import {--add | --del | --show | "
- "--help} FILE.yaml"},
+ "--exec | --help} FILE.yaml"},
{"export", jt_export, 0, "export {--help} FILE.yaml"},
{"stats", jt_stats, 0, "stats {show | help}"},
- {"numa", jt_numa, 0, "numa {show | help}"},
+ {"global", jt_global, 0, "global {show | help}"},
{"peer", jt_peers, 0, "peer {add | del | show | help}"},
+ {"ping", jt_ping, 0, "ping {--help}"},
+ {"discover", jt_discover, 0, "discover {--help}"},
{"help", Parser_help, 0, "help"},
{"exit", Parser_quit, 0, "quit"},
{"quit", Parser_quit, 0, "quit"},