show_rc, err_rc);
}
+static int handle_yaml_del_udsp(struct cYAML *tree, struct cYAML **show_rc,
+ struct cYAML **err_rc)
+{
+ struct cYAML *seq_no, *idx;
+
+ seq_no = cYAML_get_object_item(tree, "seq_no");
+ idx = cYAML_get_object_item(tree, "idx");
+
+ return lustre_lnet_del_udsp(idx ? idx->cy_valueint : -1,
+ seq_no ? seq_no->cy_valueint : -1,
+ err_rc);
+}
+
static int handle_yaml_config_udsp(struct cYAML *tree, struct cYAML **show_rc,
struct cYAML **err_rc)
{
{ .name = "numa", .cb = handle_yaml_del_numa },
{ .name = "ping", .cb = handle_yaml_no_op },
{ .name = "discover", .cb = handle_yaml_no_op },
+ { .name = "udsp", .cb = handle_yaml_del_udsp },
{ .name = NULL } };
static struct lookup_cmd_hdlr_tbl lookup_show_tbl[] = {
cYAML_build_error(rc, seq_no, ADD_CMD, "udsp", err_str, err_rc);
return rc;
}
+
+int lustre_lnet_del_udsp(unsigned int idx, int seq_no, struct cYAML **err_rc)
+{
+ int rc;
+ char err_str[LNET_MAX_STR_LEN];
+ struct lnet_ioctl_udsp udsp_bulk;
+
+ snprintf(err_str, sizeof(err_str), "\"success\"");
+
+ LIBCFS_IOC_INIT_V2(udsp_bulk, iou_hdr);
+ udsp_bulk.iou_idx = idx;
+
+ rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_DEL_UDSP, &udsp_bulk);
+ if (rc < 0) {
+ rc = -errno;
+ snprintf(err_str, sizeof(err_str),
+ "\"cannot del udsp: %s\"", strerror(rc));
+ }
+
+ cYAML_build_error(rc, seq_no, ADD_CMD, "udsp", err_str, err_rc);
+ return rc;
+}
static int jt_set_drop_asym_route(int argc, char **argv);
static int jt_list_peer(int argc, char **argv);
static int jt_add_udsp(int argc, char **argv);
+static int jt_del_udsp(int argc, char **argv);
/*static int jt_show_peer(int argc, char **argv);*/
static int lnetctl_list_commands(int argc, char **argv);
static int jt_import(int argc, char **argv);
{"ping", jt_ping, 0, "ping nid,[nid,...]"},
{"discover", jt_discover, 0, "discover nid[,nid,...]"},
{"service-id", jt_calc_service_id, 0, "Calculate IB Lustre service ID\n"},
- {"udsp", jt_udsp, 0, "udsp {add | help}"},
+ {"udsp", jt_udsp, 0, "udsp {add | del | help}"},
{"help", Parser_help, 0, "help"},
{"exit", Parser_quit, 0, "quit"},
{"quit", Parser_quit, 0, "quit"},
"\t--priority: priority value (0 - highest priority)\n"
"\t--idx: index of where to insert the rule.\n"
"\t By default, appends to the end of the rule list.\n"},
+ {"del", jt_del_udsp, 0, "delete a udsp\n"
+ "\t--idx: index of the Policy.\n"},
{ 0, 0, 0, NULL }
};
return rc;
}
+static int jt_del_udsp(int argc, char **argv)
+{
+ struct cYAML *err_rc = NULL;
+ long int idx = 0;
+ int opt, rc = 0;
+
+ const char *const short_options = "i:";
+ static const struct option long_options[] = {
+ { .name = "idx", .has_arg = required_argument, .val = 'i' },
+ { .name = NULL } };
+
+ rc = check_cmd(udsp_cmds, "udsp", "del", 0, argc, argv);
+ if (rc)
+ return rc;
+
+ while ((opt = getopt_long(argc, argv, short_options,
+ long_options, NULL)) != -1) {
+ switch (opt) {
+ case 'i':
+ rc = parse_long(optarg, &idx);
+ if (rc != 0)
+ idx = 0;
+ break;
+ case '?':
+ print_help(udsp_cmds, "udsp", "add");
+ default:
+ return 0;
+ }
+ }
+
+ rc = lustre_lnet_del_udsp(idx, -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 lnetctl_list_commands(int argc, char **argv)
{
char buffer[81] = ""; /* 80 printable chars + terminating NUL */