aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/pg/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/pg/cli.c')
-rw-r--r--src/vnet/pg/cli.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c
index 3f2de2604b2..6cd9cbd3be5 100644
--- a/src/vnet/pg/cli.c
+++ b/src/vnet/pg/cli.c
@@ -672,7 +672,7 @@ create_pg_if_cmd_fn (vlib_main_t * vm,
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "interface pg%u", &if_id))
+ if (unformat (line_input, "pg%u", &if_id))
;
else if (unformat (line_input, "coalesce-enabled"))
coalesce_enabled = 1;
@@ -709,13 +709,60 @@ done:
}
VLIB_CLI_COMMAND (create_pg_if_cmd, static) = {
- .path = "create packet-generator",
+ .path = "create packet-generator interface",
.short_help = "create packet-generator interface <interface name>"
" [gso-enabled gso-size <size> [coalesce-enabled]]"
" [mode <ethernet | ip4 | ip6>]",
.function = create_pg_if_cmd_fn,
};
+static clib_error_t *
+delete_pg_if_cmd_fn (vlib_main_t *vm, unformat_input_t *input,
+ vlib_cli_command_t *cmd)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ unformat_input_t _line_input, *line_input = &_line_input;
+ u32 sw_if_index = ~0;
+ int rv = 0;
+
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "Missing <interface>");
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "sw_if_index %d", &sw_if_index))
+ ;
+ else if (unformat (line_input, "%U", unformat_vnet_sw_interface, vnm,
+ &sw_if_index))
+ ;
+ else
+ {
+ return clib_error_create ("unknown input `%U'",
+ format_unformat_error, input);
+ }
+ }
+ unformat_free (line_input);
+
+ if (sw_if_index == ~0)
+ return clib_error_return (0,
+ "please specify interface name or sw_if_index");
+
+ rv = pg_interface_delete (sw_if_index);
+ if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
+ return clib_error_return (0, "not a pg interface");
+ else if (rv != 0)
+ return clib_error_return (0, "error on deleting pg interface");
+
+ return 0;
+}
+
+VLIB_CLI_COMMAND (delete_pg_if_cmd, static) = {
+ .path = "delete packet-generator interface",
+ .short_help = "delete packet-generator interface {<interface name> | "
+ "sw_if_index <sw_idx>}",
+ .function = delete_pg_if_cmd_fn,
+};
+
/* Dummy init function so that we can be linked in. */
static clib_error_t *
pg_cli_init (vlib_main_t * vm)