Add CLI for lcp-auto-subint
In preparation of another feature 'netlink-auto-subint', rename lcp_main's field to "lcp_auto_subint". Add CLI .short_help = "lcp lcp-auto-subint [on|enable|off|disable]" Show status of the field on "lcp show" output.
This commit is contained in:
8
lcpng.c
8
lcpng.c
@ -70,19 +70,19 @@ int lcp_set_default_ns(u8 *ns) {
|
||||
}
|
||||
|
||||
void
|
||||
lcp_set_auto_subint (u8 is_auto)
|
||||
lcp_set_lcp_auto_subint (u8 is_auto)
|
||||
{
|
||||
lcp_main_t *lcpm = &lcp_main;
|
||||
|
||||
lcpm->auto_subint = (is_auto != 0);
|
||||
lcpm->lcp_auto_subint = (is_auto != 0);
|
||||
}
|
||||
|
||||
int
|
||||
lcp_auto_subint (void)
|
||||
lcp_lcp_auto_subint (void)
|
||||
{
|
||||
lcp_main_t *lcpm = &lcp_main;
|
||||
|
||||
return lcpm->auto_subint;
|
||||
return lcpm->lcp_auto_subint;
|
||||
}
|
||||
|
||||
/*
|
||||
|
2
lcpng.h
2
lcpng.h
@ -24,7 +24,7 @@ typedef struct lcp_main_s
|
||||
u16 msg_id_base; /* API message ID base */
|
||||
u8 default_namespace[LCP_NS_LEN]; /* default namespace if set */
|
||||
int default_ns_fd;
|
||||
u8 auto_subint; /* Automatically create/delete LCP sub-interfaces */
|
||||
u8 lcp_auto_subint; /* Automatically create/delete LCP sub-interfaces */
|
||||
/* Set when Unit testing */
|
||||
u8 test_mode;
|
||||
} lcp_main_t;
|
||||
|
@ -111,6 +111,37 @@ VLIB_CLI_COMMAND(lcp_itf_pair_create_command, static) = {
|
||||
.function = lcp_itf_pair_create_command_fn,
|
||||
};
|
||||
|
||||
static clib_error_t *
|
||||
lcp_lcp_auto_subint_command_fn (vlib_main_t *vm, unformat_input_t *input,
|
||||
vlib_cli_command_t *cmd)
|
||||
{
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
|
||||
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (line_input, "on") || unformat (line_input, "enable"))
|
||||
lcp_set_lcp_auto_subint (1);
|
||||
else if (unformat (line_input, "off") ||
|
||||
unformat (line_input, "disable"))
|
||||
lcp_set_lcp_auto_subint (0);
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
}
|
||||
|
||||
unformat_free (line_input);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VLIB_CLI_COMMAND (lcp_lcp_auto_subint_command, static) = {
|
||||
.path = "lcp lcp-auto-subint",
|
||||
.short_help = "lcp lcp-auto-subint [on|enable|off|disable]",
|
||||
.function = lcp_lcp_auto_subint_command_fn,
|
||||
};
|
||||
|
||||
static clib_error_t *lcp_default_netns_command_fn(vlib_main_t *vm,
|
||||
unformat_input_t *input,
|
||||
vlib_cli_command_t *cmd) {
|
||||
|
@ -455,12 +455,12 @@ lcp_itf_interface_add_del (vnet_main_t *vnm, u32 sw_if_index, u32 is_create)
|
||||
uword is_sub;
|
||||
|
||||
is_sub = vnet_sw_interface_is_sub (vnm, sw_if_index);
|
||||
LCP_ITF_PAIR_DBG ("interface_%s: [%u] sw %U is_sub %u auto-subint %u",
|
||||
LCP_ITF_PAIR_DBG ("interface_%s: [%u] sw %U is_sub %u lcp-auto-subint %u",
|
||||
is_create ? "add" : "del", sw_if_index,
|
||||
format_vnet_sw_if_index_name, vnet_get_main (),
|
||||
sw_if_index, is_sub, lcp_auto_subint ());
|
||||
sw_if_index, is_sub, lcp_lcp_auto_subint ());
|
||||
|
||||
if (!lcp_auto_subint ())
|
||||
if (!lcp_lcp_auto_subint ())
|
||||
return NULL;
|
||||
|
||||
sw = vnet_get_sw_interface_or_null (vnm, sw_if_index);
|
||||
|
@ -129,7 +129,9 @@ lcp_itf_pair_show (u32 phy_sw_if_index)
|
||||
|
||||
vm = vlib_get_main ();
|
||||
ns = lcp_get_default_ns();
|
||||
vlib_cli_output (vm, "lcp netns %s\n", ns ? (char *) ns : "<unset>");
|
||||
vlib_cli_output (vm, "lcp default netns %s\n", ns ? (char *) ns : "<unset>");
|
||||
vlib_cli_output (vm, "lcp lcp-auto-subint %s\n",
|
||||
lcp_lcp_auto_subint () ? "on" : "off");
|
||||
|
||||
if (phy_sw_if_index == ~0)
|
||||
{
|
||||
@ -565,7 +567,7 @@ lcp_itf_pair_config (vlib_main_t *vm, unformat_input_t *input)
|
||||
}
|
||||
}
|
||||
else if (unformat (input, "lcp-auto-subint"))
|
||||
lcp_set_auto_subint (1 /* is_auto */);
|
||||
lcp_set_lcp_auto_subint (1 /* is_auto */);
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
|
@ -167,8 +167,8 @@ lcp_itf_pair_find_by_host (u32 host_sw_if_index)
|
||||
/**
|
||||
* sub-interface auto creation/deletion for LCP
|
||||
*/
|
||||
void lcp_set_auto_subint (u8 is_auto);
|
||||
int lcp_auto_subint (void);
|
||||
void lcp_set_lcp_auto_subint (u8 is_auto);
|
||||
int lcp_lcp_auto_subint (void);
|
||||
|
||||
typedef void (*lcp_itf_pair_add_cb_t) (lcp_itf_pair_t *);
|
||||
typedef void (*lcp_itf_pair_del_cb_t) (lcp_itf_pair_t *);
|
||||
|
Reference in New Issue
Block a user