aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2019-06-19 13:42:37 +0200
committerFlorin Coras <florin.coras@gmail.com>2019-06-27 17:24:10 +0000
commite971bc9bab2d1be9e129caa585448bb81dc6541f (patch)
tree5911a1dfb5905c6169d6798b2b1dca21e84c6862 /src/vnet
parent706079c92abe2c218da15c13d2c933914af18d18 (diff)
session: Add transport vft protocol options
Type: refactor Change-Id: I4e0afc206e4871596c2ed8a6ca00914a379f1526 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/sctp/sctp.c13
-rw-r--r--src/vnet/session/application_local.c8
-rw-r--r--src/vnet/session/session.c3
-rw-r--r--src/vnet/session/session_node.c10
-rw-r--r--src/vnet/session/transport.c6
-rw-r--r--src/vnet/session/transport.h9
-rw-r--r--src/vnet/tcp/tcp.c6
-rw-r--r--src/vnet/tls/tls.c8
-rw-r--r--src/vnet/udp/udp.c21
9 files changed, 53 insertions, 31 deletions
diff --git a/src/vnet/sctp/sctp.c b/src/vnet/sctp/sctp.c
index 08285e42ba5..e5d6cca0fd9 100644
--- a/src/vnet/sctp/sctp.c
+++ b/src/vnet/sctp/sctp.c
@@ -940,8 +940,8 @@ sctp_update_time (f64 now, u8 thread_index)
sctp_flush_frames_to_output (thread_index);
}
-/* *INDENT OFF* */
-const static transport_proto_vft_t sctp_proto = {
+/* *INDENT-OFF* */
+static const transport_proto_vft_t sctp_proto = {
.enable = sctp_enable_disable,
.start_listen = sctp_session_bind,
.stop_listen = sctp_session_unbind,
@@ -958,11 +958,12 @@ const static transport_proto_vft_t sctp_proto = {
.format_connection = format_sctp_session,
.format_listener = format_sctp_listener_session,
.format_half_open = format_sctp_half_open,
- .tx_type = TRANSPORT_TX_DEQUEUE,
- .service_type = TRANSPORT_SERVICE_VC,
+ .transport_options = {
+ .tx_type = TRANSPORT_TX_DEQUEUE,
+ .service_type = TRANSPORT_SERVICE_VC,
+ },
};
-
-/* *INDENT ON* */
+/* *INDENT-ON* */
clib_error_t *
sctp_init (vlib_main_t * vm)
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c
index 2fcf070767c..4a93d3a2ae5 100644
--- a/src/vnet/session/application_local.c
+++ b/src/vnet/session/application_local.c
@@ -540,7 +540,7 @@ format_ct_session (u8 * s, va_list * args)
}
/* *INDENT-OFF* */
-const static transport_proto_vft_t cut_thru_proto = {
+static const transport_proto_vft_t cut_thru_proto = {
.start_listen = ct_start_listen,
.stop_listen = ct_stop_listen,
.get_listener = ct_listener_get,
@@ -549,10 +549,12 @@ const static transport_proto_vft_t cut_thru_proto = {
.get_connection = ct_session_get,
.custom_tx = ct_custom_tx,
.app_rx_evt = ct_app_rx_evt,
- .tx_type = TRANSPORT_TX_INTERNAL,
- .service_type = TRANSPORT_SERVICE_APP,
.format_listener = format_ct_listener,
.format_connection = format_ct_session,
+ .transport_options = {
+ .tx_type = TRANSPORT_TX_INTERNAL,
+ .service_type = TRANSPORT_SERVICE_APP,
+ },
};
/* *INDENT-ON* */
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index ea52b75086d..0e5fb8edb1a 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1283,7 +1283,8 @@ session_register_transport (transport_proto_t transport_proto,
/* *INDENT-ON* */
smm->session_type_to_next[session_type] = next_index;
- smm->session_tx_fns[session_type] = session_tx_fns[vft->tx_type];
+ smm->session_tx_fns[session_type] =
+ session_tx_fns[vft->transport_options.tx_type];
}
transport_connection_t *
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index 067ab585e6f..8d01938ad85 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -395,7 +395,8 @@ session_tx_fifo_chain_tail (vlib_main_t * vm, session_tx_context_t * ctx,
}
else
{
- if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM)
+ if (ctx->transport_vft->transport_options.tx_type ==
+ TRANSPORT_TX_DGRAM)
{
svm_fifo_t *f = ctx->s->tx_fifo;
session_dgram_hdr_t *hdr = &ctx->hdr;
@@ -466,7 +467,7 @@ session_tx_fill_buffer (vlib_main_t * vm, session_tx_context_t * ctx,
}
else
{
- if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM)
+ if (ctx->transport_vft->transport_options.tx_type == TRANSPORT_TX_DGRAM)
{
session_dgram_hdr_t *hdr = &ctx->hdr;
svm_fifo_t *f = ctx->s->tx_fifo;
@@ -572,7 +573,7 @@ session_tx_set_dequeue_params (vlib_main_t * vm, session_tx_context_t * ctx,
}
else
{
- if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM)
+ if (ctx->transport_vft->transport_options.tx_type == TRANSPORT_TX_DGRAM)
{
if (ctx->max_dequeue <= sizeof (ctx->hdr))
{
@@ -782,7 +783,8 @@ session_tx_fifo_read_and_snd_i (vlib_main_t * vm, vlib_node_runtime_t * node,
if (svm_fifo_set_event (ctx->s->tx_fifo))
vec_add1 (wrk->pending_event_vector, *e);
- if (!peek_data && ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM)
+ if (!peek_data
+ && ctx->transport_vft->transport_options.tx_type == TRANSPORT_TX_DGRAM)
{
/* Fix dgram pre header */
if (ctx->max_len_to_snd < ctx->max_dequeue)
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index bbd9c3555f4..f971288f90c 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -291,13 +291,13 @@ transport_protocol_get_vft (transport_proto_t transport_proto)
transport_service_type_t
transport_protocol_service_type (transport_proto_t tp)
{
- return tp_vfts[tp].service_type;
+ return tp_vfts[tp].transport_options.service_type;
}
transport_tx_fn_type_t
transport_protocol_tx_fn_type (transport_proto_t tp)
{
- return tp_vfts[tp].tx_type;
+ return tp_vfts[tp].transport_options.tx_type;
}
void
@@ -334,7 +334,7 @@ transport_stop_listen (transport_proto_t tp, u32 conn_index)
u8
transport_protocol_is_cl (transport_proto_t tp)
{
- return (tp_vfts[tp].service_type == TRANSPORT_SERVICE_CL);
+ return (tp_vfts[tp].transport_options.service_type == TRANSPORT_SERVICE_CL);
}
always_inline void
diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h
index fadb02d6710..978e3f072b1 100644
--- a/src/vnet/session/transport.h
+++ b/src/vnet/session/transport.h
@@ -19,6 +19,12 @@
#include <vnet/vnet.h>
#include <vnet/session/transport_types.h>
+typedef struct _transport_options_t
+{
+ transport_tx_fn_type_t tx_type;
+ transport_service_type_t service_type;
+} transport_options_t;
+
/*
* Transport protocol virtual function table
*/
@@ -74,8 +80,7 @@ typedef struct _transport_proto_vft
/*
* Properties
*/
- transport_tx_fn_type_t tx_type;
- transport_service_type_t service_type;
+ transport_options_t transport_options;
} transport_proto_vft_t;
/* *INDENT-ON* */
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 03110e5c911..7b5b5537613 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -1227,8 +1227,10 @@ const static transport_proto_vft_t tcp_proto = {
.format_connection = format_tcp_session,
.format_listener = format_tcp_listener_session,
.format_half_open = format_tcp_half_open_session,
- .tx_type = TRANSPORT_TX_PEEK,
- .service_type = TRANSPORT_SERVICE_VC,
+ .transport_options = {
+ .tx_type = TRANSPORT_TX_PEEK,
+ .service_type = TRANSPORT_SERVICE_VC,
+ },
};
/* *INDENT-ON* */
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index e4e8d43e1a1..344fdf41254 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -757,7 +757,7 @@ tls_transport_listener_endpoint_get (u32 ctx_handle,
}
/* *INDENT-OFF* */
-const static transport_proto_vft_t tls_proto = {
+static const transport_proto_vft_t tls_proto = {
.connect = tls_connect,
.close = tls_disconnect,
.start_listen = tls_start_listen,
@@ -765,13 +765,15 @@ const static transport_proto_vft_t tls_proto = {
.get_connection = tls_connection_get,
.get_listener = tls_listener_get,
.custom_tx = tls_custom_tx_callback,
- .tx_type = TRANSPORT_TX_INTERNAL,
- .service_type = TRANSPORT_SERVICE_APP,
.format_connection = format_tls_connection,
.format_half_open = format_tls_half_open,
.format_listener = format_tls_listener,
.get_transport_endpoint = tls_transport_endpoint_get,
.get_transport_listener_endpoint = tls_transport_listener_endpoint_get,
+ .transport_options = {
+ .tx_type = TRANSPORT_TX_INTERNAL,
+ .service_type = TRANSPORT_SERVICE_APP,
+ },
};
/* *INDENT-ON* */
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index bf91c905eb6..d0c515a9d06 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -320,11 +320,13 @@ udp_session_get_half_open (u32 conn_index)
/* We don't poll main thread if we have workers */
thread_index = vlib_num_workers ()? 1 : 0;
uc = udp_connection_get (conn_index, thread_index);
+ if (!uc)
+ return 0;
return &uc->connection;
}
/* *INDENT-OFF* */
-const static transport_proto_vft_t udp_proto = {
+static const transport_proto_vft_t udp_proto = {
.start_listen = udp_session_bind,
.connect = udp_open_connection,
.stop_listen = udp_session_unbind,
@@ -339,8 +341,10 @@ const static transport_proto_vft_t udp_proto = {
.format_connection = format_udp_session,
.format_half_open = format_udp_half_open_session,
.format_listener = format_udp_listener_session,
- .tx_type = TRANSPORT_TX_DGRAM,
- .service_type = TRANSPORT_SERVICE_CL,
+ .transport_options = {
+ .tx_type = TRANSPORT_TX_DGRAM,
+ .service_type = TRANSPORT_SERVICE_CL,
+ },
};
/* *INDENT-ON* */
@@ -354,7 +358,8 @@ udpc_connection_open (transport_endpoint_cfg_t * rmt)
u32 uc_index;
uc_index = udp_open_connection (rmt);
uc = udp_connection_get (uc_index, thread_index);
- uc->is_connected = 1;
+ if (uc)
+ uc->is_connected = 1;
return uc_index;
}
@@ -370,7 +375,7 @@ udpc_connection_listen (u32 session_index, transport_endpoint_t * lcl)
}
/* *INDENT-OFF* */
-const static transport_proto_vft_t udpc_proto = {
+static const transport_proto_vft_t udpc_proto = {
.start_listen = udpc_connection_listen,
.stop_listen = udp_session_unbind,
.connect = udpc_connection_open,
@@ -385,8 +390,10 @@ const static transport_proto_vft_t udpc_proto = {
.format_connection = format_udp_session,
.format_half_open = format_udp_half_open_session,
.format_listener = format_udp_listener_session,
- .tx_type = TRANSPORT_TX_DGRAM,
- .service_type = TRANSPORT_SERVICE_CL,
+ .transport_options = {
+ .tx_type = TRANSPORT_TX_DGRAM,
+ .service_type = TRANSPORT_SERVICE_VC,
+ },
};
/* *INDENT-ON* */