diff options
author | Filip Varga <fivarga@cisco.com> | 2020-08-30 21:19:55 +0200 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2020-09-02 16:42:41 +0000 |
commit | 6484f4b9cbaf19062444cfe09b39ce1514dd146f (patch) | |
tree | ad70ca1ed7815b0899ba24e962de02a0501908f1 /src/plugins/nat/nat44_cli.c | |
parent | 42845dd56e0694a88a6318f5974724adee8312fe (diff) |
nat: twice-nat static mapping pool address
Let twice-nat static mapping pick specific
address from the twice-nat pool.
Type: improvement
Change-Id: Iadaa036af2fa3b0e6e9a68ff6e68b4bbe1650eb1
Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat44_cli.c')
-rw-r--r-- | src/plugins/nat/nat44_cli.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/plugins/nat/nat44_cli.c b/src/plugins/nat/nat44_cli.c index 65f40753a3f..f61ce2c2ab7 100644 --- a/src/plugins/nat/nat44_cli.c +++ b/src/plugins/nat/nat44_cli.c @@ -980,13 +980,11 @@ add_static_mapping_command_fn (vlib_main_t * vm, { unformat_input_t _line_input, *line_input = &_line_input; clib_error_t *error = 0; - ip4_address_t l_addr, e_addr; + ip4_address_t l_addr, e_addr, exact_addr; u32 l_port = 0, e_port = 0, vrf_id = ~0; - int is_add = 1; - int addr_only = 1; + int is_add = 1, addr_only = 1, rv, exact = 0; u32 sw_if_index = ~0; vnet_main_t *vnm = vnet_get_main (); - int rv; nat_protocol_t proto = NAT_PROTOCOL_OTHER; u8 proto_set = 0; twice_nat_type_t twice_nat = TWICE_NAT_DISABLED; @@ -1014,10 +1012,12 @@ add_static_mapping_command_fn (vlib_main_t * vm, unformat_vnet_sw_interface, vnm, &sw_if_index, &e_port)) addr_only = 0; - else if (unformat (line_input, "external %U", unformat_vnet_sw_interface, vnm, &sw_if_index)) ; + else if (unformat (line_input, "exact %U", unformat_ip4_address, + &exact_addr)) + exact = 1; else if (unformat (line_input, "vrf %u", &vrf_id)) ; else if (unformat (line_input, "%U", unformat_nat_protocol, &proto)) @@ -1063,7 +1063,8 @@ add_static_mapping_command_fn (vlib_main_t * vm, rv = snat_add_static_mapping (l_addr, e_addr, clib_host_to_net_u16 (l_port), clib_host_to_net_u16 (e_port), vrf_id, addr_only, sw_if_index, proto, is_add, - twice_nat, out2in_only, 0, 0); + twice_nat, out2in_only, 0, 0, exact_addr, + exact); switch (rv) { @@ -1104,7 +1105,7 @@ add_identity_mapping_command_fn (vlib_main_t * vm, { unformat_input_t _line_input, *line_input = &_line_input; clib_error_t *error = 0; - ip4_address_t addr; + ip4_address_t addr, pool_addr = { 0 }; u32 port = 0, vrf_id = ~0; int is_add = 1; int addr_only = 1; @@ -1144,7 +1145,8 @@ add_identity_mapping_command_fn (vlib_main_t * vm, rv = snat_add_static_mapping (addr, addr, clib_host_to_net_u16 (port), clib_host_to_net_u16 (port), vrf_id, addr_only, - sw_if_index, proto, is_add, 0, 0, 0, 1); + sw_if_index, proto, is_add, 0, 0, 0, 1, + pool_addr, 0); switch (rv) { @@ -2254,6 +2256,8 @@ VLIB_CLI_COMMAND (nat44_show_interfaces_command, static) = { * To create ICMP static mapping between local and external with ICMP echo * identifier 10 use: * vpp# nat44 add static mapping icmp local 10.0.0.3 10 external 4.4.4.4 10 + * To force use of specific pool address, vrf independent + * vpp# nat44 add static mapping local 10.0.0.2 1234 external 10.0.2.2 1234 twice-nat exact 10.0.1.2 * @cliexend ?*/ VLIB_CLI_COMMAND (add_static_mapping_command, static) = { @@ -2262,7 +2266,7 @@ VLIB_CLI_COMMAND (add_static_mapping_command, static) = { .short_help = "nat44 add static mapping tcp|udp|icmp local <addr> [<port|icmp-echo-id>] " "external <addr> [<port|icmp-echo-id>] [vrf <table-id>] [twice-nat|self-twice-nat] " - "[out2in-only] [del]", + "[out2in-only] [exact <pool-addr>] [del]", }; /*? |