diff options
author | JĂșlius Milan <julius.milan@pantheon.tech> | 2021-09-10 09:43:31 +0200 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2021-09-28 13:38:36 +0000 |
commit | 11c7cdd590a06a9681c43bde53055183c9d0058b (patch) | |
tree | ed41596f529ed55c30d72e654c721b1bf651cc3b /src/plugins/nat/nat44-ei | |
parent | 2430bad8951a321e0fcb50eafb562ecbdbecbb5b (diff) |
nat: NAT44 ED & EI session filtering CLI
Improving session filtering capabilities of
show nat44 sessions CLI command for EI and ED NAT
plugins. Adding filtering options: saddr, sport,
daddr, dport, proto for both i2o and o2i flows.
Type: improvement
Change-Id: I70bc94a2e922cddf9451eb7dcbf4a7be21ebf0df
Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat44-ei')
-rw-r--r-- | src/plugins/nat/nat44-ei/nat44_ei_cli.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/nat/nat44-ei/nat44_ei_cli.c b/src/plugins/nat/nat44-ei/nat44_ei_cli.c index a009f0292d3..9ee117e97c1 100644 --- a/src/plugins/nat/nat44-ei/nat44_ei_cli.c +++ b/src/plugins/nat/nat44-ei/nat44_ei_cli.c @@ -1252,6 +1252,8 @@ nat44_ei_show_sessions_command_fn (vlib_main_t *vm, unformat_input_t *input, { unformat_input_t _line_input, *line_input = &_line_input; clib_error_t *error = 0; + ip4_address_t saddr; + u8 filter_saddr = 0; nat44_ei_main_per_thread_data_t *tnm; nat44_ei_main_t *nm = &nat44_ei_main; @@ -1266,6 +1268,9 @@ nat44_ei_show_sessions_command_fn (vlib_main_t *vm, unformat_input_t *input, { if (unformat (line_input, "detail")) detail = 1; + else if (unformat (line_input, "filter saddr %U", unformat_ip4_address, + &saddr)) + filter_saddr = 1; else { error = clib_error_return (0, "unknown input '%U'", @@ -1288,6 +1293,8 @@ print: nat44_ei_user_t *u; pool_foreach (u, tnm->users) { + if (filter_saddr && saddr.as_u32 != u->addr.as_u32) + continue; vlib_cli_output (vm, " %U", format_nat44_ei_user, tnm, u, detail); } } @@ -1930,7 +1937,7 @@ VLIB_CLI_COMMAND (nat44_ei_show_interface_address_command, static) = { ?*/ VLIB_CLI_COMMAND (nat44_ei_show_sessions_command, static) = { .path = "show nat44 ei sessions", - .short_help = "show nat44 ei sessions [detail]", + .short_help = "show nat44 ei sessions [detail] [filter saddr <ip>]", .function = nat44_ei_show_sessions_command_fn, }; |