diff options
author | Klement Sekera <ksekera@cisco.com> | 2021-03-01 20:26:00 +0100 |
---|---|---|
committer | Klement Sekera <ksekera@cisco.com> | 2021-03-01 20:26:00 +0100 |
commit | 2c0b6b462b86d4010cf551b545083c3509839cac (patch) | |
tree | f348d4bada415a5109ab0f519b3270055629ca5d /src/plugins/nat/nat44-ed/nat44_ed_cli.c | |
parent | dc243ee2bcc4926ec23e71a687bb62b5c52c2fbb (diff) |
nat: avoid crash if plugin not enabled
Avoid crash if nat pool not allocated when issuing "show nat44 summary".
Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I55661cf699bab04f4673e9d471fe12486e972067
Diffstat (limited to 'src/plugins/nat/nat44-ed/nat44_ed_cli.c')
-rw-r--r-- | src/plugins/nat/nat44-ed/nat44_ed_cli.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_cli.c b/src/plugins/nat/nat44-ed/nat44_ed_cli.c index 714b410bbd3..bff941f409a 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed_cli.c +++ b/src/plugins/nat/nat44-ed/nat44_ed_cli.c @@ -448,26 +448,29 @@ nat44_show_lru_summary (vlib_main_t * vm, snat_main_per_thread_data_t * tsm, snat_session_t *s; u32 oldest_index; -#define _(n, d) \ - oldest_index = \ - clib_dlist_remove_head (tsm->lru_pool, tsm->n##_lru_head_index); \ - if (~0 != oldest_index) \ - { \ - oldest_elt = pool_elt_at_index (tsm->lru_pool, oldest_index); \ - s = pool_elt_at_index (tsm->sessions, oldest_elt->value); \ - sess_timeout_time = \ - s->last_heard + (f64)nat44_session_get_timeout (sm, s); \ - vlib_cli_output (vm, d " LRU min session timeout %llu (now %llu)", \ - sess_timeout_time, now); \ - clib_dlist_addhead (tsm->lru_pool, tsm->n##_lru_head_index, \ - oldest_index); \ + if (tsm->lru_pool) + { +#define _(n, d) \ + oldest_index = \ + clib_dlist_remove_head (tsm->lru_pool, tsm->n##_lru_head_index); \ + if (~0 != oldest_index) \ + { \ + oldest_elt = pool_elt_at_index (tsm->lru_pool, oldest_index); \ + s = pool_elt_at_index (tsm->sessions, oldest_elt->value); \ + sess_timeout_time = \ + s->last_heard + (f64) nat44_session_get_timeout (sm, s); \ + vlib_cli_output (vm, d " LRU min session timeout %llu (now %llu)", \ + sess_timeout_time, now); \ + clib_dlist_addhead (tsm->lru_pool, tsm->n##_lru_head_index, \ + oldest_index); \ } - _(tcp_estab, "established tcp"); - _(tcp_trans, "transitory tcp"); - _(udp, "udp"); - _(unk_proto, "unknown protocol"); - _(icmp, "icmp"); + _ (tcp_estab, "established tcp"); + _ (tcp_trans, "transitory tcp"); + _ (udp, "udp"); + _ (unk_proto, "unknown protocol"); + _ (icmp, "icmp"); #undef _ + } } static clib_error_t * |