summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@yandex-team.ru>2022-09-05 10:32:46 +0500
committerOle Tr�an <otroan@employees.org>2023-09-13 16:56:19 +0000
commit5b3e04c74f188dbe6c4edab57e555ee3a01fb8f7 (patch)
tree5ea9b2e8252c760c316cb061535d4ae7ab5a51d4 /src
parente8a1dbf8da086da24f6bb8ce647e2e898c20df55 (diff)
nat: fix nat44_ed set_session_limit crash
Setting session limit should return error for unknown fib. Optimize max_translations_per_fib expanding and drop unnecessary trailing fib entry. Type: fix Change-Id: Ie7d2b363ade48f53598faa617a49cce7b2db6400 Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.c b/src/plugins/nat/nat44-ed/nat44_ed.c
index 5eee893f2fd..08e577747c3 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed.c
@@ -3240,16 +3240,12 @@ nat44_set_session_limit (u32 session_limit, u32 vrf_id)
{
snat_main_t *sm = &snat_main;
u32 fib_index = fib_table_find (FIB_PROTOCOL_IP4, vrf_id);
- u32 len = vec_len (sm->max_translations_per_fib);
- if (len <= fib_index)
- {
- vec_validate (sm->max_translations_per_fib, fib_index + 1);
-
- for (; len < vec_len (sm->max_translations_per_fib); len++)
- sm->max_translations_per_fib[len] = sm->max_translations_per_thread;
- }
+ if (~0 == fib_index)
+ return -1;
+ vec_validate_init_empty (sm->max_translations_per_fib, fib_index,
+ sm->max_translations_per_thread);
sm->max_translations_per_fib[fib_index] = session_limit;
return 0;
}