*
* Copyright (c) 2013, 2017, Intel Corporation.
*
- * This file is part of Lustre, https://wiki.hpdd.intel.com/
+ * This file is part of Lustre, https://wiki.whamcloud.com/
*
* Portals is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
int
jt_ptl_list_nids(int argc, char **argv)
{
- struct libcfs_ioctl_data data;
- int all = 0, return_nid = 0;
- int count;
- int rc;
+ struct libcfs_ioctl_data data;
+ int all = 0, return_nid = 0;
+ int count;
+ int rc;
- all = (argc == 2) && (strcmp(argv[1], "all") == 0);
- /* Hack to pass back value */
- return_nid = (argc == 2) && (argv[1][0] == 1);
+ all = (argc == 2) && (strcmp(argv[1], "all") == 0);
+ /* Hack to pass back value */
+ return_nid = (argc == 2) && (argv[1][0] == 1);
- if ((argc > 2) && !(all || return_nid)) {
- fprintf(stderr, "usage: %s [all]\n", argv[0]);
- return 0;
- }
+ if ((argc > 2) && !(all || return_nid)) {
+ fprintf(stderr, "usage: %s [all]\n", argv[0]);
+ return 0;
+ }
- for (count = 0;; count++) {
- LIBCFS_IOC_INIT (data);
- data.ioc_count = count;
- rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_NI, &data);
-
- if (rc < 0) {
- if ((count > 0) && (errno == ENOENT))
- /* We found them all */
- break;
- fprintf(stderr,"IOC_LIBCFS_GET_NI error %d: %s\n",
- errno, strerror(errno));
- return -1;
- }
+ for (count = 0;; count++) {
+ LIBCFS_IOC_INIT(data);
+ data.ioc_count = count;
+ rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_NI, &data);
+
+ if (rc < 0) {
+ if ((count > 0) && (errno == ENOENT))
+ /* We found them all */
+ break;
+ fprintf(stderr, "IOC_LIBCFS_GET_NI error %d: %s\n",
+ errno, strerror(errno));
+ return -1;
+ }
- if (all || (LNET_NETTYP(LNET_NIDNET(data.ioc_nid)) != LOLND)) {
- printf("%s\n", libcfs_nid2str(data.ioc_nid));
- if (return_nid) {
- *(__u64 *)(argv[1]) = data.ioc_nid;
- return_nid--;
- }
- }
- }
+ if (all || (data.ioc_nid != LNET_NID_LO_0)) {
+ printf("%s\n", libcfs_nid2str(data.ioc_nid));
+ if (return_nid) {
+ *(__u64 *)(argv[1]) = data.ioc_nid;
+ return_nid--;
+ }
+ }
+ }
- return 0;
+ return 0;
}
int
{ .name = "portal", .has_arg = required_argument, .val = 'p' },
{ .name = "message", .has_arg = required_argument, .val = 'm' },
{ .name = "health_error", .has_arg = required_argument, .val = 'e' },
+ { .name = "local_nid", .has_arg = required_argument, .val = 'o' },
+ { .name = "drop_all", .has_arg = no_argument, .val = 'x' },
{ .name = NULL } };
if (argc == 1) {
return -1;
}
- optstr = opc == LNET_CTL_DROP_ADD ? "s:d:r:i:p:m:e:n" : "s:d:r:l:p:m:";
+ optstr = opc == LNET_CTL_DROP_ADD ? "s:d:o:r:i:p:m:e:nx" : "s:d:o:r:l:p:m:";
memset(&attr, 0, sizeof(attr));
while (1) {
char c = getopt_long(argc, argv, optstr, opts, NULL);
break;
switch (c) {
+ case 'o':
+ rc = fault_attr_nid_parse(optarg, &attr.fa_local_nid);
+ if (rc != 0)
+ goto getopt_failed;
+ break;
case 's': /* source NID/NET */
rc = fault_attr_nid_parse(optarg, &attr.fa_src);
if (rc != 0)
}
break;
+ case 'x':
+ if (opc == LNET_CTL_DROP_ADD)
+ attr.u.drop.da_drop_all = true;
+ break;
+
case 'n':
if (opc == LNET_CTL_DROP_ADD)
attr.u.drop.da_random = true;
return -1;
}
+ if (attr.fa_local_nid == 0)
+ attr.fa_local_nid = LNET_NID_ANY;
+
data.ioc_flags = opc;
data.ioc_inllen1 = sizeof(attr);
data.ioc_inlbuf1 = (char *)&attr;