nat: nat44 cli bug fix
[vpp.git] / src / plugins / nat / nat44-ei / nat44_ei_cli.c
index 36d98a4..2fe01b0 100644 (file)
@@ -859,8 +859,7 @@ nat44_ei_feature_command_fn (vlib_main_t *vm, unformat_input_t *input,
   u32 *inside_sw_if_indices = 0;
   u32 *outside_sw_if_indices = 0;
   u8 is_output_feature = 0;
-  int is_del = 0;
-  int i;
+  int i, rv, is_del = 0;
 
   sw_if_index = ~0;
 
@@ -894,7 +893,15 @@ nat44_ei_feature_command_fn (vlib_main_t *vm, unformat_input_t *input,
          sw_if_index = inside_sw_if_indices[i];
          if (is_output_feature)
            {
-             if (nat44_ei_add_del_output_interface (sw_if_index, is_del))
+             if (is_del)
+               {
+                 rv = nat44_ei_del_output_interface (sw_if_index);
+               }
+             else
+               {
+                 rv = nat44_ei_add_output_interface (sw_if_index);
+               }
+             if (rv)
                {
                  error = clib_error_return (
                    0, "%s %U failed", is_del ? "del" : "add",
@@ -904,7 +911,15 @@ nat44_ei_feature_command_fn (vlib_main_t *vm, unformat_input_t *input,
            }
          else
            {
-             if (nat44_ei_add_del_interface (sw_if_index, 1, is_del))
+             if (is_del)
+               {
+                 rv = nat44_ei_del_interface (sw_if_index, 1);
+               }
+             else
+               {
+                 rv = nat44_ei_add_interface (sw_if_index, 1);
+               }
+             if (rv)
                {
                  error = clib_error_return (
                    0, "%s %U failed", is_del ? "del" : "add",
@@ -922,7 +937,15 @@ nat44_ei_feature_command_fn (vlib_main_t *vm, unformat_input_t *input,
          sw_if_index = outside_sw_if_indices[i];
          if (is_output_feature)
            {
-             if (nat44_ei_add_del_output_interface (sw_if_index, is_del))
+             if (is_del)
+               {
+                 rv = nat44_ei_del_output_interface (sw_if_index);
+               }
+             else
+               {
+                 rv = nat44_ei_add_output_interface (sw_if_index);
+               }
+             if (rv)
                {
                  error = clib_error_return (
                    0, "%s %U failed", is_del ? "del" : "add",
@@ -932,7 +955,15 @@ nat44_ei_feature_command_fn (vlib_main_t *vm, unformat_input_t *input,
            }
          else
            {
-             if (nat44_ei_add_del_interface (sw_if_index, 0, is_del))
+             if (is_del)
+               {
+                 rv = nat44_ei_del_interface (sw_if_index, 0);
+               }
+             else
+               {
+                 rv = nat44_ei_add_interface (sw_if_index, 0);
+               }
+             if (rv)
                {
                  error = clib_error_return (
                    0, "%s %U failed", is_del ? "del" : "add",
@@ -1061,6 +1092,11 @@ add_static_mapping_command_fn (vlib_main_t *vm, unformat_input_t *input,
       e_port = clib_host_to_net_u16 (e_port);
     }
 
+  if (sw_if_index != ~0)
+    {
+      flags |= NAT44_EI_SM_FLAG_SWITCH_ADDRESS;
+    }
+
   if (is_add)
     {
       rv =
@@ -1155,6 +1191,11 @@ add_identity_mapping_command_fn (vlib_main_t *vm, unformat_input_t *input,
       port = clib_host_to_net_u16 (port);
     }
 
+  if (sw_if_index != ~0)
+    {
+      flags |= NAT44_EI_SM_FLAG_SWITCH_ADDRESS;
+    }
+
   if (is_add)
     {
 
@@ -1548,23 +1589,23 @@ nat_show_timeouts_command_fn (vlib_main_t *vm, unformat_input_t *input,
  * @cliexstart{nat44 ei}
  * Enable nat44 ei plugin
  * To enable nat44-ei, use:
- *  vpp# nat44 ei enable
+ *  vpp# nat44 ei plugin enable
  * To disable nat44-ei, use:
- *  vpp# nat44 ei disable
+ *  vpp# nat44 ei plugin disable
  * To enable nat44 ei static mapping only, use:
- *  vpp# nat44 ei enable static-mapping
+ *  vpp# nat44 ei plugin enable static-mapping
  * To enable nat44 ei static mapping with connection tracking, use:
- *  vpp# nat44 ei enable static-mapping connection-tracking
+ *  vpp# nat44 ei plugin enable static-mapping connection-tracking
  * To enable nat44 ei out2in dpo, use:
- *  vpp# nat44 ei enable out2in-dpo
+ *  vpp# nat44 ei plugin enable out2in-dpo
  * To set inside-vrf outside-vrf, use:
- *  vpp# nat44 ei enable inside-vrf <id> outside-vrf <id>
+ *  vpp# nat44 ei plugin enable inside-vrf <id> outside-vrf <id>
  * @cliexend
 ?*/
 VLIB_CLI_COMMAND (nat44_ei_enable_disable_command, static) = {
-  .path = "nat44 ei",
+  .path = "nat44 ei plugin",
   .short_help =
-    "nat44 ei <enable [sessions <max-number>] [users <max-number>] "
+    "nat44 ei plugin <enable [sessions <max-number>] [users <max-number>] "
     "[static-mappig-only [connection-tracking]|out2in-dpo] [inside-vrf "
     "<vrf-id>] [outside-vrf <vrf-id>] [user-sessions <max-number>]>|disable",
   .function = nat44_ei_enable_disable_command_fn,