aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schultz <andreas.schultz@travelping.com>2020-04-23 10:41:50 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-08-13 17:20:47 +0000
commitb7bbd6a1fe8e862df2510ba26216678509f9d582 (patch)
treea946c35d6c42333d1796dbf6b67c8db6dfc50c7b
parentb72e494f39c5338c71b77ac9b3496d810d6bfbbd (diff)
session: fix session_table_get_or_alloc
Extending the fib_index_to_table_index could leave entries uninitialized, pointing to the session tables at index 0. That session index exists by default, but it is a IPv4 session table. That would break all IPv6 on the unitilized fib indexes. Type: fix Change-Id: Ie3f0a87a7f829ceb39f75ec06658b0ad1d3813ae Signed-off-by: Andreas Schultz <andreas.schultz@travelping.com> (cherry picked from commit 30a28c187b0eb9216d5d7918712d98a4b7a5ba6a)
-rw-r--r--src/vnet/session/session_lookup.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c
index 604344a27cd..6c787fbe34b 100644
--- a/src/vnet/session/session_lookup.c
+++ b/src/vnet/session/session_lookup.c
@@ -156,25 +156,28 @@ make_v6_ss_kv_from_tc (session_kv6_t * kv, transport_connection_t * tc)
}
static session_table_t *
-session_table_get_or_alloc (u8 fib_proto, u8 fib_index)
+session_table_get_or_alloc (u8 fib_proto, u32 fib_index)
{
session_table_t *st;
u32 table_index;
- if (vec_len (fib_index_to_table_index[fib_proto]) <= fib_index)
+ ASSERT (fib_index != ~0);
+ if (vec_len (fib_index_to_table_index[fib_proto]) > fib_index &&
+ fib_index_to_table_index[fib_proto][fib_index] != ~0)
+ {
+ table_index = fib_index_to_table_index[fib_proto][fib_index];
+ return session_table_get (table_index);
+ }
+ else
{
st = session_table_alloc ();
table_index = session_table_index (st);
- vec_validate (fib_index_to_table_index[fib_proto], fib_index);
+ vec_validate_init_empty (fib_index_to_table_index[fib_proto], fib_index,
+ ~0);
fib_index_to_table_index[fib_proto][fib_index] = table_index;
st->active_fib_proto = fib_proto;
session_table_init (st, fib_proto);
return st;
}
- else
- {
- table_index = fib_index_to_table_index[fib_proto][fib_index];
- return session_table_get (table_index);
- }
}
static session_table_t *