session: Use parent_handle instead of transport_opts
Type: feature
This is mostly used for quic in the case of a stream
creation (i.e. connect on an already established QUIC
session). We want do default parent_handle to INVALID
to be able to distinguish it from parent_handle = 0
Change-Id: Id5ac0b0155a3c44e51334231b711e4fd87a96a10
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c
index bcf4176..1d036b6 100644
--- a/src/plugins/hs_apps/echo_client.c
+++ b/src/plugins/hs_apps/echo_client.c
@@ -376,8 +376,7 @@
vec_validate (a, 1);
a->uri = (char *) ecm->connect_uri;
parse_uri (a->uri, &sep);
- sep.transport_opts = session_handle (s);
- sep.port = 0; /* QUIC: create a stream flag */
+ sep.parent_handle = session_handle (s);
for (stream_n = 0; stream_n < ecm->quic_streams; stream_n++)
{
diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c
index 39e460e..1575f2b 100644
--- a/src/plugins/quic/quic.c
+++ b/src/plugins/quic/quic.c
@@ -1334,10 +1334,10 @@
*****************************************************************************/
static int
-quic_connect_new_stream (session_endpoint_cfg_t * sep)
+quic_connect_new_stream (session_t * quic_session, u32 opaque)
{
uint64_t quic_session_handle;
- session_t *quic_session, *stream_session;
+ session_t *stream_session;
quic_stream_data_t *stream_data;
quicly_stream_t *stream;
quicly_conn_t *conn;
@@ -1347,12 +1347,11 @@
int rv;
/* Find base session to which the user want to attach a stream */
- quic_session_handle = sep->transport_opts;
- QUIC_DBG (2, "Opening new stream (qsession %u)", sep->transport_opts);
- quic_session = session_get_from_handle (quic_session_handle);
+ quic_session_handle = session_handle (quic_session);
+ QUIC_DBG (2, "Opening new stream (qsession %u)", quic_session_handle);
- if (quic_session->session_type !=
- session_type_from_proto_and_ip (TRANSPORT_PROTO_QUIC, sep->is_ip4))
+ if (session_type_transport_proto (quic_session->session_type) !=
+ TRANSPORT_PROTO_QUIC)
{
QUIC_DBG (1, "received incompatible session");
return -1;
@@ -1415,7 +1414,7 @@
quicly_reset_stream (stream, QUIC_APP_ALLOCATION_ERROR);
session_free_w_fifos (stream_session);
quic_ctx_free (sctx);
- return app_worker_connect_notify (app_wrk, NULL, sep->opaque);
+ return app_worker_connect_notify (app_wrk, NULL, opaque);
}
svm_fifo_add_want_deq_ntf (stream_session->rx_fifo,
@@ -1423,7 +1422,7 @@
SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY);
stream_session->session_state = SESSION_STATE_READY;
- if (app_worker_connect_notify (app_wrk, stream_session, sep->opaque))
+ if (app_worker_connect_notify (app_wrk, stream_session, opaque))
{
QUIC_DBG (1, "failed to notify app");
quicly_reset_stream (stream, QUIC_APP_CONNECT_NOTIFY_ERROR);
@@ -1494,9 +1493,12 @@
{
QUIC_DBG (2, "Called quic_connect");
session_endpoint_cfg_t *sep = (session_endpoint_cfg_t *) tep;
+ session_t *quic_session;
sep = (session_endpoint_cfg_t *) tep;
- if (sep->port == 0) /* TODO add mask on transport_opts */
- return quic_connect_new_stream (sep);
+
+ quic_session = session_get_from_handle_if_valid (sep->parent_handle);
+ if (quic_session)
+ return quic_connect_new_stream (quic_session, sep->opaque);
else
return quic_connect_new_connection (sep);
}
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index 7abb45b..2bfc7c7 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -517,7 +517,7 @@
cmp->context = session->session_index;
cmp->wrk_index = wrk->vpp_wrk_index;
cmp->is_ip4 = session->transport.is_ip4;
- cmp->transport_opts = session->transport_opts;
+ cmp->parent_handle = session->parent_handle;
clib_memcpy_fast (cmp->ip, &session->transport.rmt_ip, sizeof (cmp->ip));
cmp->port = session->transport.rmt_port;
cmp->proto = session->session_type;
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h
index d46208c..552fdd8 100644
--- a/src/vcl/vcl_private.h
+++ b/src/vcl/vcl_private.h
@@ -173,7 +173,7 @@
int n_accepted_sessions;
u8 has_rx_evt;
u32 attr;
- u64 transport_opts;
+ u64 parent_handle;
vppcom_epoll_t vep;
int libc_epfd;
svm_msg_q_t *our_evt_q;
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 3205a81..69d9285 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -1491,7 +1491,7 @@
clib_memcpy_fast (&session->transport.rmt_ip.ip6, server_ep->ip,
sizeof (ip6_address_t));
session->transport.rmt_port = server_ep->port;
- session->transport_opts = VCL_INVALID_SESSION_HANDLE;
+ session->parent_handle = VCL_INVALID_SESSION_HANDLE;
VDBG (0, "session handle %u: connecting to server %s %U "
"port %d proto %s", session_handle,
@@ -1556,7 +1556,7 @@
session->transport.is_ip4 = parent_session->transport.is_ip4;
session->transport.rmt_ip.ip4.as_u32 = (uint32_t) 1;
session->transport.rmt_port = 0;
- session->transport_opts = parent_session->vpp_handle;
+ session->parent_handle = parent_session->vpp_handle;
VDBG (0, "session handle %u: connecting to session %u [0x%llx]",
session_handle, parent_session_handle, parent_session->vpp_handle);
diff --git a/src/vcl/vppcom.h b/src/vcl/vppcom.h
index b05eae7..90bec31 100644
--- a/src/vcl/vppcom.h
+++ b/src/vcl/vppcom.h
@@ -105,7 +105,7 @@
uint8_t is_ip4;
uint8_t *ip;
uint16_t port;
- uint64_t transport_opts;
+ uint64_t parent_handle;
} vppcom_endpt_t;
typedef uint32_t vcl_session_handle_t;
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c
index ab011bd..a6d1a02 100644
--- a/src/vnet/session/application_interface.c
+++ b/src/vnet/session/application_interface.c
@@ -79,10 +79,9 @@
return 1;
}
else if (unformat (input, "%U://session/%lu", unformat_transport_proto,
- &transport_proto, &sep->transport_opts))
+ &transport_proto, &sep->parent_handle))
{
sep->transport_proto = transport_proto;
- sep->is_ip4 = 1;
sep->ip.ip4.as_u32 = 1; /* ip need to be non zero in vnet */
return 1;
}
diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api
index 53d05df..533f65e 100644
--- a/src/vnet/session/session.api
+++ b/src/vnet/session/session.api
@@ -250,7 +250,7 @@
@param hostname-len - length of hostname
@param hostname - destination's hostname. If present, used by protocols
like tls.
- @param transport_opts - transport option (e.g. session id for quic).
+ @param parent_handle - handle of parent session (e.g. for opening quic streams).
*/
autoreply define connect_sock {
u32 client_index;
@@ -265,7 +265,7 @@
u8 proto;
u8 hostname_len;
u8 hostname[hostname_len];
- u64 transport_opts;
+ u64 parent_handle;
};
/** \brief ask app to add a new cut-through registration
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index e8550d6..479c5d1 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -889,7 +889,7 @@
a->sep.transport_proto = mp->proto;
a->sep.peer.fib_index = mp->vrf;
a->sep.peer.sw_if_index = ENDPOINT_INVALID_INDEX;
- a->sep_ext.transport_opts = mp->transport_opts;
+ a->sep_ext.parent_handle = mp->parent_handle;
if (mp->hostname_len)
{
vec_validate (a->sep_ext.hostname, mp->hostname_len - 1);
diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h
index 1c03aa2..682094c 100644
--- a/src/vnet/session/session_types.h
+++ b/src/vnet/session/session_types.h
@@ -43,7 +43,7 @@
u32 ns_index;
u8 original_tp;
u8 *hostname;
- u64 transport_opts;
+ u64 parent_handle;
} session_endpoint_cfg_t;
#define SESSION_IP46_ZERO \
@@ -83,6 +83,7 @@
.app_wrk_index = ENDPOINT_INVALID_INDEX, \
.opaque = ENDPOINT_INVALID_INDEX, \
.hostname = 0, \
+ .parent_handle = SESSION_INVALID_HANDLE \
}
#define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep)