Make tcp active open data structures thread safe
- Cleanup half-open connections and timers on the right thread
- Ensure half-open connection and transport endpoint pools are thread safe
- Enqueue TX events to the correct vpp thread in the builtin client
- Use transport proto in transport connections instead of session type
Change-Id: Id13239a206afbff6f34a38afa510fe014e4b2049
Signed-off-by: Florin Coras <fcoras@cisco.com>
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c
index b3862ee..1ce22f8 100644
--- a/src/vnet/session/session_lookup.c
+++ b/src/vnet/session/session_lookup.c
@@ -107,7 +107,7 @@
make_v4_ss_kv_from_tc (session_kv4_t * kv, transport_connection_t * t)
{
return make_v4_ss_kv (kv, &t->lcl_ip.ip4, &t->rmt_ip.ip4, t->lcl_port,
- t->rmt_port, t->proto);
+ t->rmt_port, t->transport_proto);
}
always_inline void
@@ -150,7 +150,7 @@
make_v6_ss_kv_from_tc (session_kv6_t * kv, transport_connection_t * t)
{
make_v6_ss_kv (kv, &t->lcl_ip.ip6, &t->rmt_ip.ip6, t->lcl_port,
- t->rmt_port, t->proto);
+ t->rmt_port, t->transport_proto);
}
/*
@@ -164,23 +164,17 @@
session_kv4_t kv4;
session_kv6_t kv6;
- switch (tc->proto)
+ if (tc->is_ip4)
{
- case SESSION_TYPE_IP4_UDP:
- case SESSION_TYPE_IP4_TCP:
make_v4_ss_kv_from_tc (&kv4, tc);
kv4.value = value;
clib_bihash_add_del_16_8 (&sl->v4_session_hash, &kv4, 1 /* is_add */ );
- break;
- case SESSION_TYPE_IP6_UDP:
- case SESSION_TYPE_IP6_TCP:
+ }
+ else
+ {
make_v6_ss_kv_from_tc (&kv6, tc);
kv6.value = value;
clib_bihash_add_del_48_8 (&sl->v6_session_hash, &kv6, 1 /* is_add */ );
- break;
- default:
- clib_warning ("Session type not supported");
- ASSERT (0);
}
}
@@ -195,59 +189,24 @@
stream_session_table_add_for_tc (tc, value);
}
-void
-stream_session_half_open_table_add (session_type_t sst,
- transport_connection_t * tc, u64 value)
-{
- session_lookup_t *sl = &session_lookup;
- session_kv4_t kv4;
- session_kv6_t kv6;
-
- switch (sst)
- {
- case SESSION_TYPE_IP4_UDP:
- case SESSION_TYPE_IP4_TCP:
- make_v4_ss_kv_from_tc (&kv4, tc);
- kv4.value = value;
- clib_bihash_add_del_16_8 (&sl->v4_half_open_hash, &kv4,
- 1 /* is_add */ );
- break;
- case SESSION_TYPE_IP6_UDP:
- case SESSION_TYPE_IP6_TCP:
- make_v6_ss_kv_from_tc (&kv6, tc);
- kv6.value = value;
- clib_bihash_add_del_48_8 (&sl->v6_half_open_hash, &kv6,
- 1 /* is_add */ );
- break;
- default:
- clib_warning ("Session type not supported");
- ASSERT (0);
- }
-}
-
int
stream_session_table_del_for_tc (transport_connection_t * tc)
{
session_lookup_t *sl = &session_lookup;
session_kv4_t kv4;
session_kv6_t kv6;
- switch (tc->proto)
+
+ if (tc->is_ip4)
{
- case SESSION_TYPE_IP4_UDP:
- case SESSION_TYPE_IP4_TCP:
make_v4_ss_kv_from_tc (&kv4, tc);
return clib_bihash_add_del_16_8 (&sl->v4_session_hash, &kv4,
0 /* is_add */ );
- break;
- case SESSION_TYPE_IP6_UDP:
- case SESSION_TYPE_IP6_TCP:
+ }
+ else
+ {
make_v6_ss_kv_from_tc (&kv6, tc);
return clib_bihash_add_del_48_8 (&sl->v6_session_hash, &kv6,
0 /* is_add */ );
- break;
- default:
- clib_warning ("Session type not supported");
- ASSERT (0);
}
return 0;
@@ -262,30 +221,48 @@
return stream_session_table_del_for_tc (ts);
}
+
void
-stream_session_half_open_table_del (u8 sst, transport_connection_t * tc)
+stream_session_half_open_table_add (transport_connection_t * tc, u64 value)
{
session_lookup_t *sl = &session_lookup;
session_kv4_t kv4;
session_kv6_t kv6;
- switch (sst)
+ if (tc->is_ip4)
{
- case SESSION_TYPE_IP4_UDP:
- case SESSION_TYPE_IP4_TCP:
+ make_v4_ss_kv_from_tc (&kv4, tc);
+ kv4.value = value;
+ clib_bihash_add_del_16_8 (&sl->v4_half_open_hash, &kv4,
+ 1 /* is_add */ );
+ }
+ else
+ {
+ make_v6_ss_kv_from_tc (&kv6, tc);
+ kv6.value = value;
+ clib_bihash_add_del_48_8 (&sl->v6_half_open_hash, &kv6,
+ 1 /* is_add */ );
+ }
+}
+
+void
+stream_session_half_open_table_del (transport_connection_t * tc)
+{
+ session_lookup_t *sl = &session_lookup;
+ session_kv4_t kv4;
+ session_kv6_t kv6;
+
+ if (tc->is_ip4)
+ {
make_v4_ss_kv_from_tc (&kv4, tc);
clib_bihash_add_del_16_8 (&sl->v4_half_open_hash, &kv4,
0 /* is_add */ );
- break;
- case SESSION_TYPE_IP6_UDP:
- case SESSION_TYPE_IP6_TCP:
+ }
+ else
+ {
make_v6_ss_kv_from_tc (&kv6, tc);
clib_bihash_add_del_48_8 (&sl->v6_half_open_hash, &kv6,
0 /* is_add */ );
- break;
- default:
- clib_warning ("Session type not supported");
- ASSERT (0);
}
}