From 4496243cc9c9f5a64483923e1f158cab74aca18a Mon Sep 17 00:00:00 2001 From: Filip Varga Date: Wed, 3 Jun 2020 15:26:41 +0200 Subject: nat: fixed input validation Ticket: VPP-1887 Type: fix Change-Id: I341ac7b455926a106d736f4de6771aae655db82e Signed-off-by: Filip Varga --- src/plugins/nat/nat44_cli.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 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 9e9751d5bc9..68ed0cb7207 100644 --- a/src/plugins/nat/nat44_cli.c +++ b/src/plugins/nat/nat44_cli.c @@ -643,7 +643,6 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input, if (sm->deterministic || !sm->endpoint_dependent) return clib_error_return (0, UNSUPPORTED_IN_DET_OR_NON_ED_MODE_STR); - // print session configuration values vlib_cli_output (vm, "max translations: %u", sm->max_translations); vlib_cli_output (vm, "max translations per user: %u", sm->max_translations_per_user); @@ -1056,9 +1055,19 @@ add_static_mapping_command_fn (vlib_main_t * vm, goto done; } - if (!addr_only && !proto_set) + if (addr_only) { - error = clib_error_return (0, "missing protocol"); + if (proto_set) + { + error = + clib_error_return (0, + "address only mapping doesn't support protocol"); + goto done; + } + } + else if (!proto_set) + { + error = clib_error_return (0, "protocol is required"); goto done; } @@ -2540,16 +2549,19 @@ VLIB_CLI_COMMAND (nat44_show_interfaces_command, static) = { * vpp# nat44 add static mapping tcp local 10.0.0.3 6303 external 4.4.4.4 3606 * If not runnig "static mapping only" NAT plugin mode use before: * vpp# nat44 add address 4.4.4.4 - * To create static mapping between local and external address use: + * To create address only static mapping between local and external address use: * vpp# nat44 add static mapping local 10.0.0.3 external 4.4.4.4 + * 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 * @cliexend ?*/ VLIB_CLI_COMMAND (add_static_mapping_command, static) = { .path = "nat44 add static mapping", .function = add_static_mapping_command_fn, .short_help = - "nat44 add static mapping tcp|udp|icmp local [] " - "external [] [vrf ] [twice-nat|self-twice-nat] " + "nat44 add static mapping tcp|udp|icmp local [] " + "external [] [vrf ] [twice-nat|self-twice-nat] " "[out2in-only] [del]", }; -- cgit 1.2.3-korg