From 1e5c07d379a092f4829e7081aa962d013b31fdfc Mon Sep 17 00:00:00 2001 From: Juraj Sloboda Date: Tue, 10 Apr 2018 13:51:54 +0200 Subject: Add special Twice-NAT feature (VPP-1221) When enabled then Twice-NAT is applied only when source IP equals destination IP after DNAT Change-Id: I58a9d1d222b2a10c83eafffb2107f32c1b4aa3a8 Signed-off-by: Juraj Sloboda --- src/plugins/nat/nat44_cli.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/plugins/nat/nat44_cli.c') diff --git a/src/plugins/nat/nat44_cli.c b/src/plugins/nat/nat44_cli.c index da97a801b7f..2f1e9a019ac 100644 --- a/src/plugins/nat/nat44_cli.c +++ b/src/plugins/nat/nat44_cli.c @@ -501,7 +501,7 @@ add_static_mapping_command_fn (vlib_main_t * vm, int rv; snat_protocol_t proto = ~0; u8 proto_set = 0; - u8 twice_nat = 0; + twice_nat_type_t twice_nat = TWICE_NAT_DISABLED; u8 out2in_only = 0; if (sm->deterministic) @@ -538,7 +538,9 @@ add_static_mapping_command_fn (vlib_main_t * vm, else if (unformat (line_input, "%U", unformat_snat_protocol, &proto)) proto_set = 1; else if (unformat (line_input, "twice-nat")) - twice_nat = 1; + twice_nat = TWICE_NAT; + else if (unformat (line_input, "self-twice-nat")) + twice_nat = TWICE_NAT_SELF; else if (unformat (line_input, "out2in-only")) out2in_only = 1; else if (unformat (line_input, "del")) @@ -688,7 +690,7 @@ add_lb_static_mapping_command_fn (vlib_main_t * vm, snat_protocol_t proto; u8 proto_set = 0; nat44_lb_addr_port_t *locals = 0, local; - u8 twice_nat = 0; + twice_nat_type_t twice_nat = TWICE_NAT_DISABLED; u8 out2in_only = 0; if (sm->deterministic) @@ -718,7 +720,9 @@ add_lb_static_mapping_command_fn (vlib_main_t * vm, &proto)) proto_set = 1; else if (unformat (line_input, "twice-nat")) - twice_nat = 1; + twice_nat = TWICE_NAT; + else if (unformat (line_input, "self-twice-nat")) + twice_nat = TWICE_NAT_SELF; else if (unformat (line_input, "out2in-only")) out2in_only = 1; else if (unformat (line_input, "del")) @@ -1584,7 +1588,8 @@ VLIB_CLI_COMMAND (add_static_mapping_command, static) = { .function = add_static_mapping_command_fn, .short_help = "nat44 add static mapping tcp|udp|icmp local [] " - "external [] [vrf ] [twice-nat] [out2in-only] [del]", + "external [] [vrf ] [twice-nat|self-twice-nat] " + "[out2in-only] [del]", }; /*? @@ -1622,8 +1627,8 @@ VLIB_CLI_COMMAND (add_lb_static_mapping_command, static) = { .function = add_lb_static_mapping_command_fn, .short_help = "nat44 add load-balancing static mapping protocol tcp|udp " - "external : local : probability [twice-nat] " - "[vrf ] [out2in-only] [del]", + "external : local : probability " + "[twice-nat|self-twice-nat] [vrf ] [out2in-only] [del]", }; /*? -- cgit 1.2.3-korg