summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44-ed/nat44_ed_cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/nat/nat44-ed/nat44_ed_cli.c')
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed_cli.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_cli.c b/src/plugins/nat/nat44-ed/nat44_ed_cli.c
index bddd635272c..cde3d733484 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed_cli.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed_cli.c
@@ -108,7 +108,6 @@ set_workers_command_fn (vlib_main_t * vm,
int rv = 0;
clib_error_t *error = 0;
- /* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return clib_error_return (0, NAT44_ED_EXPECTED_ARGUMENT);
@@ -184,7 +183,6 @@ snat_set_log_level_command_fn (vlib_main_t * vm,
u8 log_level = NAT_LOG_NONE;
clib_error_t *error = 0;
- /* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return clib_error_return (0, NAT44_ED_EXPECTED_ARGUMENT);
@@ -299,7 +297,6 @@ nat_set_mss_clamping_command_fn (vlib_main_t * vm, unformat_input_t * input,
clib_error_t *error = 0;
u32 mss;
- /* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return clib_error_return (0, NAT44_ED_EXPECTED_ARGUMENT);
@@ -351,7 +348,6 @@ add_address_command_fn (vlib_main_t * vm,
clib_error_t *error = 0;
u8 twice_nat = 0;
- /* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return clib_error_return (0, NAT44_ED_EXPECTED_ARGUMENT);
@@ -662,7 +658,6 @@ snat_feature_command_fn (vlib_main_t * vm,
sw_if_index = ~0;
- /* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return clib_error_return (0, NAT44_ED_EXPECTED_ARGUMENT);
@@ -1172,7 +1167,6 @@ add_lb_backend_command_fn (vlib_main_t * vm,
ip_protocol_t proto;
u8 proto_set = 0;
- /* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return clib_error_return (0, NAT44_ED_EXPECTED_ARGUMENT);
@@ -1267,19 +1261,21 @@ snat_add_interface_address_command_fn (vlib_main_t * vm,
vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
- snat_main_t *sm = &snat_main;
+ vnet_main_t *vnm = vnet_get_main ();
clib_error_t *error = 0;
int rv, is_del = 0;
u8 twice_nat = 0;
u32 sw_if_index;
+ sw_if_index = ~0;
+
if (!unformat_user (input, unformat_line_input, line_input))
return clib_error_return (0, NAT44_ED_EXPECTED_ARGUMENT);
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "%U", unformat_vnet_sw_interface,
- sm->vnet_main, &sw_if_index))
+ if (unformat (line_input, "%U", unformat_vnet_sw_interface, vnm,
+ &sw_if_index))
;
else if (unformat (line_input, "twice-nat"))
{
@@ -1297,21 +1293,21 @@ snat_add_interface_address_command_fn (vlib_main_t * vm,
}
}
- if (!is_del)
+ if (is_del)
{
- rv = nat44_ed_add_interface_address (sw_if_index, twice_nat);
- if (rv)
- {
- error = clib_error_return (0, "add address returned %d", rv);
- }
+ rv = nat44_ed_del_interface_address (sw_if_index, twice_nat);
}
else
{
- rv = nat44_ed_del_interface_address (sw_if_index, twice_nat);
- if (rv)
- {
- error = clib_error_return (0, "del address returned %d", rv);
- }
+ rv = nat44_ed_add_interface_address (sw_if_index, twice_nat);
+ }
+
+ if (0 != rv)
+ {
+ error =
+ clib_error_return (0, "%s %U address failed", is_del ? "del" : "add",
+ format_vnet_sw_if_index_name, vnm, sw_if_index);
+ goto done;
}
done:
@@ -1847,18 +1843,19 @@ done:
* @cliexstart{nat44}
* Enable nat44 plugin
* To enable nat44-ed, use:
- * vpp# nat44 enable
+ * vpp# nat44 plugin enable
* To disable nat44-ed, use:
- * vpp# nat44 disable
+ * vpp# nat44 plugin disable
* To set inside-vrf outside-vrf, use:
- * vpp# nat44 enable inside-vrf <id> outside-vrf <id>
+ * vpp# nat44 plugin enable inside-vrf <id> outside-vrf <id>
* @cliexend
?*/
VLIB_CLI_COMMAND (nat44_ed_enable_disable_command, static) = {
- .path = "nat44",
- .short_help = "nat44 <enable [sessions <max-number>] [inside-vrf <vrf-id>] "
- "[outside-vrf <vrf-id>]>|disable",
+ .path = "nat44 plugin",
.function = nat44_ed_enable_disable_command_fn,
+ .short_help =
+ "nat44 plugin <enable [sessions <max-number>] [inside-vrf <vrf-id>] "
+ "[outside-vrf <vrf-id>]>|disable",
};
/*?
@@ -2215,9 +2212,9 @@ VLIB_CLI_COMMAND (nat44_show_static_mappings_command, static) = {
* @cliexend
?*/
VLIB_CLI_COMMAND (snat_add_interface_address_command, static) = {
- .path = "nat44 add interface address",
- .short_help = "nat44 add interface address <interface> [twice-nat] [del]",
- .function = snat_add_interface_address_command_fn,
+ .path = "nat44 add interface address",
+ .function = snat_add_interface_address_command_fn,
+ .short_help = "nat44 add interface address <interface> [twice-nat] [del]",
};
/*?