summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-12-30 21:53:19 -0800
committerDave Barach <openvpp@barachs.net>2020-01-02 16:34:33 +0000
commit95cd864382965292df9c2ffbd61285c5d45cfb50 (patch)
tree7fe915ab069ad430ba49d6de485a9541137a7a6f
parent4ed2598562b1fe65efe69ae53397dfe9f1f07be8 (diff)
session: fix listener global endpoint lookup
Type: fix Ensure listeners for app transport protocols are added to lookup tables using their session endpoints instead of their transport connections, which can override the network connection id in the transport connection. Change-Id: I56fa3666bb1422c0799fc7143cd099751ff6e2e6 Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--src/plugins/quic/quic.c2
-rw-r--r--src/vnet/session/application.c16
-rw-r--r--src/vnet/session/application_local.c2
-rw-r--r--src/vnet/session/session_lookup.c2
-rw-r--r--src/vnet/tls/tls.c2
-rw-r--r--src/vnet/udp/udp.c3
6 files changed, 19 insertions, 8 deletions
diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c
index 89df9ba89ec..dc3b1d4038e 100644
--- a/src/plugins/quic/quic.c
+++ b/src/plugins/quic/quic.c
@@ -1375,11 +1375,11 @@ quic_start_listen (u32 quic_listen_session_index, transport_endpoint_t * tep)
app = application_get (app_wrk->app_index);
QUIC_DBG (2, "Called quic_start_listen for app %d", app_wrk->app_index);
- sep->transport_proto = TRANSPORT_PROTO_UDPC;
clib_memset (args, 0, sizeof (*args));
args->app_index = qm->app_index;
args->sep_ext = *sep;
args->sep_ext.ns_index = app->ns_index;
+ args->sep_ext.transport_proto = TRANSPORT_PROTO_UDPC;
if ((rv = vnet_listen (args)))
return rv;
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 8d8e17c8943..646d6b6de2c 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -115,7 +115,7 @@ app_listener_lookup (application_t * app, session_endpoint_cfg_t * sep_ext)
}
fib_proto = session_endpoint_fib_proto (sep);
- table_index = application_session_table (app, fib_proto);
+ table_index = session_lookup_get_index_for_fib (fib_proto, sep->fib_index);
handle = session_lookup_endpoint_listener (table_index, sep, 1);
if (handle != SESSION_INVALID_HANDLE)
{
@@ -133,10 +133,10 @@ app_listener_alloc_and_init (application_t * app,
{
app_listener_t *app_listener;
transport_connection_t *tc;
+ u32 al_index, table_index;
session_handle_t lh;
session_type_t st;
session_t *ls = 0;
- u32 al_index;
int rv;
app_listener = app_listener_alloc (app);
@@ -151,7 +151,6 @@ app_listener_alloc_and_init (application_t * app,
&& session_endpoint_is_local ((session_endpoint_t *) sep))
{
session_type_t local_st;
- u32 table_index;
local_st = session_type_from_proto_and_ip (TRANSPORT_PROTO_NONE,
sep->is_ip4);
@@ -213,7 +212,16 @@ app_listener_alloc_and_init (application_t * app,
* connections */
tc = session_get_transport (ls);
if (!(tc->flags & TRANSPORT_CONNECTION_F_NO_LOOKUP))
- session_lookup_add_connection (tc, lh);
+ {
+ fib_protocol_t fib_proto;
+ fib_proto = session_endpoint_fib_proto ((session_endpoint_t *) sep);
+ table_index = session_lookup_get_index_for_fib (fib_proto,
+ sep->fib_index);
+ ASSERT (table_index != SESSION_TABLE_INVALID_INDEX);
+ session_lookup_add_session_endpoint (table_index,
+ (session_endpoint_t *) sep,
+ lh);
+ }
}
if (!ls)
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c
index 97cda12b7da..25fb39e094b 100644
--- a/src/vnet/session/application_local.c
+++ b/src/vnet/session/application_local.c
@@ -398,7 +398,7 @@ global_scope:
return VNET_API_ERROR_APP_CONNECT_SCOPE;
fib_proto = session_endpoint_fib_proto (sep);
- table_index = application_session_table (app, fib_proto);
+ table_index = session_lookup_get_index_for_fib (fib_proto, sep->fib_index);
ll = session_lookup_listener_wildcard (table_index, sep);
if (ll)
diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c
index b1c8fbbef8e..abaad5019fa 100644
--- a/src/vnet/session/session_lookup.c
+++ b/src/vnet/session/session_lookup.c
@@ -1317,7 +1317,7 @@ session_lookup_set_tables_appns (app_namespace_t * app_ns)
for (fp = 0; fp < ARRAY_LEN (fib_index_to_table_index); fp++)
{
fib_index = app_namespace_get_fib_index (app_ns, fp);
- st = session_table_get_for_fib_index (fp, fib_index);
+ st = session_table_get_or_alloc (fp, fib_index);
if (st)
st->appns_index = app_namespace_index (app_ns);
}
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index cfe2c3a3eae..6a4f99ee08d 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -615,11 +615,11 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
return -1;
}
- sep->transport_proto = TRANSPORT_PROTO_TCP;
clib_memset (args, 0, sizeof (*args));
args->app_index = tm->app_index;
args->sep_ext = *sep;
args->sep_ext.ns_index = app->ns_index;
+ args->sep_ext.transport_proto = TRANSPORT_PROTO_TCP;
if (vnet_listen (args))
return -1;
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index fbd9e980181..c2d6830bd7f 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -394,6 +394,9 @@ udpc_connection_listen (u32 session_index, transport_endpoint_t * lcl)
return -1;
listener = udp_listener_get (li_index);
listener->flags |= UDP_CONN_F_CONNECTED;
+ /* Fake udp listener, i.e., make sure session layer adds a udp instead of
+ * udpc listener to the lookup table */
+ ((session_endpoint_cfg_t *) lcl)->transport_proto = TRANSPORT_PROTO_UDP;
return li_index;
}