aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-04-24 11:10:02 -0700
committerDamjan Marion <dmarion@me.com>2019-04-25 14:46:26 +0000
commit09d18c2fee0eb96c486f9d112e39dcd34e430b0e (patch)
tree1154321a8d937427c5e1b600b36e94fbbfe73ef4 /src
parente8915fc707a03260c05624425f9548d796c089fb (diff)
session: use teps in accept/connect notifications
Change-Id: I58e713661a38cecbfdebd4609292d9d12e880cd2 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/quic/quic.c19
-rw-r--r--src/tests/vnet/session/quic_echo.c8
-rw-r--r--src/tests/vnet/session/tcp_echo.c8
-rw-r--r--src/tests/vnet/session/udp_echo.c12
-rw-r--r--src/vcl/vppcom.c18
-rw-r--r--src/vnet/session/application_interface.h8
-rw-r--r--src/vnet/session/session.c10
-rw-r--r--src/vnet/session/session.h4
-rwxr-xr-xsrc/vnet/session/session_api.c14
-rw-r--r--src/vnet/session/transport.c33
-rw-r--r--src/vnet/session/transport.h19
11 files changed, 72 insertions, 81 deletions
diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c
index c066b0d955e..5ff962d8102 100644
--- a/src/plugins/quic/quic.c
+++ b/src/plugins/quic/quic.c
@@ -1621,38 +1621,37 @@ quic_app_rx_callback (session_t * udp_session)
}
always_inline void
-quic_common_get_transport_endpoint (quic_ctx_t * ctx, ip46_address_t * ip,
- u16 * port, u8 * is_ip4, u8 is_lcl)
+quic_common_get_transport_endpoint (quic_ctx_t * ctx,
+ transport_endpoint_t * tep, u8 is_lcl)
{
session_t *udp_session;
QUIC_DBG (2, "Called quic_get_transport_endpoint");
if (ctx->c_quic_ctx_id.is_stream)
- *is_ip4 = 255; /* well this is ugly */
+ tep->is_ip4 = 255; /* well this is ugly */
else
{
udp_session =
session_get_from_handle (ctx->c_quic_ctx_id.udp_session_handle);
- session_get_endpoint (udp_session, ip, port, is_ip4, is_lcl);
+ session_get_endpoint (udp_session, tep, is_lcl);
}
}
static void
-quic_get_transport_listener_endpoint (u32 listener_index, ip46_address_t * ip,
- u16 * port, u8 * is_ip4, u8 is_lcl)
+quic_get_transport_listener_endpoint (u32 listener_index,
+ transport_endpoint_t * tep, u8 is_lcl)
{
quic_ctx_t *ctx;
ctx = quic_ctx_get (listener_index);
- quic_common_get_transport_endpoint (ctx, ip, port, is_ip4, is_lcl);
+ quic_common_get_transport_endpoint (ctx, tep, is_lcl);
}
static void
quic_get_transport_endpoint (u32 ctx_index, u32 thread_index,
- ip46_address_t * ip, u16 * port, u8 * is_ip4,
- u8 is_lcl)
+ transport_endpoint_t * tep, u8 is_lcl)
{
quic_ctx_t *ctx;
ctx = quic_ctx_get_w_thread (ctx_index, thread_index);
- quic_common_get_transport_endpoint (ctx, ip, port, is_ip4, is_lcl);
+ quic_common_get_transport_endpoint (ctx, tep, is_lcl);
}
/*****************************************************************************
diff --git a/src/tests/vnet/session/quic_echo.c b/src/tests/vnet/session/quic_echo.c
index 41ea5aae19f..4d1288f66d5 100644
--- a/src/tests/vnet/session/quic_echo.c
+++ b/src/tests/vnet/session/quic_echo.c
@@ -655,9 +655,9 @@ session_accepted_handler (session_accepted_msg_t * mp)
if (start_time == 0.0)
start_time = clib_time_now (&em->clib_time);
- ip_str = format (0, "%U", format_ip46_address, &mp->ip, mp->is_ip4);
+ ip_str = format (0, "%U", format_ip46_address, &mp->rmt.ip, mp->rmt.is_ip4);
clib_warning ("Accepted session from: %s:%d", ip_str,
- clib_net_to_host_u16 (mp->port));
+ clib_net_to_host_u16 (mp->rmt.port));
/* Allocate local session and set it up */
pool_get (em->sessions, session);
@@ -755,8 +755,8 @@ session_connected_handler (session_connected_msg_t * mp)
em->n_clients_connected += 1;
clib_warning ("session %u (0x%llx) connected with local ip %U port %d",
- session_index, mp->handle, format_ip46_address, mp->lcl_ip,
- mp->is_ip4, clib_net_to_host_u16 (mp->lcl_port));
+ session_index, mp->handle, format_ip46_address, &mp->lcl.ip,
+ mp->lcl.is_ip4, clib_net_to_host_u16 (mp->lcl.port));
}
static void
diff --git a/src/tests/vnet/session/tcp_echo.c b/src/tests/vnet/session/tcp_echo.c
index 99b6765cdf5..3fcc285dc11 100644
--- a/src/tests/vnet/session/tcp_echo.c
+++ b/src/tests/vnet/session/tcp_echo.c
@@ -655,9 +655,9 @@ session_accepted_handler (session_accepted_msg_t * mp)
if (start_time == 0.0)
start_time = clib_time_now (&em->clib_time);
- ip_str = format (0, "%U", format_ip46_address, &mp->ip, mp->is_ip4);
+ ip_str = format (0, "%U", format_ip46_address, &mp->rmt.ip, mp->rmt.is_ip4);
clib_warning ("Accepted session from: %s:%d", ip_str,
- clib_net_to_host_u16 (mp->port));
+ clib_net_to_host_u16 (mp->rmt.port));
/* Allocate local session and set it up */
pool_get (em->sessions, session);
@@ -755,8 +755,8 @@ session_connected_handler (session_connected_msg_t * mp)
em->n_clients_connected += 1;
clib_warning ("session %u (0x%llx) connected with local ip %U port %d",
- session_index, mp->handle, format_ip46_address, mp->lcl_ip,
- mp->is_ip4, clib_net_to_host_u16 (mp->lcl_port));
+ session_index, mp->handle, format_ip46_address, &mp->lcl.ip,
+ mp->lcl.is_ip4, clib_net_to_host_u16 (mp->lcl.port));
}
static void
diff --git a/src/tests/vnet/session/udp_echo.c b/src/tests/vnet/session/udp_echo.c
index 91d5dccedcc..c949d4cbf6d 100644
--- a/src/tests/vnet/session/udp_echo.c
+++ b/src/tests/vnet/session/udp_echo.c
@@ -514,10 +514,10 @@ session_accepted_handler (session_accepted_msg_t * mp)
tx_fifo->client_session_index = session_index;
session->rx_fifo = rx_fifo;
session->tx_fifo = tx_fifo;
- clib_memcpy_fast (&session->transport.rmt_ip, mp->ip,
+ clib_memcpy_fast (&session->transport.rmt_ip, &mp->rmt.ip,
sizeof (ip46_address_t));
- session->transport.is_ip4 = mp->is_ip4;
- session->transport.rmt_port = mp->port;
+ session->transport.is_ip4 = mp->rmt.is_ip4;
+ session->transport.rmt_port = mp->rmt.port;
hash_set (utm->session_index_by_vpp_handles, mp->handle, session_index);
if (pool_elts (utm->sessions) && (pool_elts (utm->sessions) % 20000) == 0)
@@ -618,10 +618,10 @@ session_connected_handler (session_connected_msg_t * mp)
session->rx_fifo->client_session_index = session->session_index;
session->tx_fifo->client_session_index = session->session_index;
- clib_memcpy_fast (&session->transport.lcl_ip, mp->lcl_ip,
+ clib_memcpy_fast (&session->transport.lcl_ip, &mp->lcl.ip,
sizeof (ip46_address_t));
- session->transport.is_ip4 = mp->is_ip4;
- session->transport.lcl_port = mp->lcl_port;
+ session->transport.is_ip4 = mp->lcl.is_ip4;
+ session->transport.lcl_port = mp->lcl.port;
unformat_init_vector (input, utm->connect_uri);
if (!unformat (input, "%U", unformat_uri, sep))
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index e70aa001772..6668d465fca 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -309,9 +309,9 @@ vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp)
session->tx_fifo = tx_fifo;
session->session_state = STATE_ACCEPT;
- session->transport.rmt_port = mp->port;
- session->transport.is_ip4 = mp->is_ip4;
- clib_memcpy_fast (&session->transport.rmt_ip, mp->ip,
+ session->transport.rmt_port = mp->rmt.port;
+ session->transport.is_ip4 = mp->rmt.is_ip4;
+ clib_memcpy_fast (&session->transport.rmt_ip, &mp->rmt.ip,
sizeof (ip46_address_t));
vcl_session_table_add_vpp_handle (wrk, mp->handle, session->session_index);
@@ -322,9 +322,9 @@ vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp)
VDBG (1, "session %u [0x%llx]: client accept request from %s address %U"
" port %d queue %p!", session->session_index, mp->handle,
- mp->is_ip4 ? "IPv4" : "IPv6", format_ip46_address, &mp->ip,
- mp->is_ip4 ? IP46_TYPE_IP4 : IP46_TYPE_IP6,
- clib_net_to_host_u16 (mp->port), session->vpp_evt_q);
+ mp->rmt.is_ip4 ? "IPv4" : "IPv6", format_ip46_address, &mp->rmt.ip,
+ mp->rmt.is_ip4 ? IP46_TYPE_IP4 : IP46_TYPE_IP6,
+ clib_net_to_host_u16 (mp->rmt.port), session->vpp_evt_q);
vcl_evt (VCL_EVT_ACCEPT, session, listen_session, session_index);
return session->session_index;
@@ -393,10 +393,10 @@ vcl_session_connected_handler (vcl_worker_t * wrk,
session->tx_fifo = tx_fifo;
session->vpp_handle = mp->handle;
session->vpp_thread_index = rx_fifo->master_thread_index;
- session->transport.is_ip4 = mp->is_ip4;
- clib_memcpy_fast (&session->transport.lcl_ip, mp->lcl_ip,
+ session->transport.is_ip4 = mp->lcl.is_ip4;
+ clib_memcpy_fast (&session->transport.lcl_ip, &mp->lcl.ip,
sizeof (session->transport.lcl_ip));
- session->transport.lcl_port = mp->lcl_port;
+ session->transport.lcl_port = mp->lcl.port;
session->session_state = STATE_CONNECT;
/* Add it to lookup table */
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index f6091c51698..3e6abdbec86 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -284,9 +284,7 @@ typedef struct session_accepted_msg_
uword server_tx_fifo;
u64 segment_handle;
uword vpp_event_queue_address;
- u16 port;
- u8 is_ip4;
- u8 ip[16];
+ transport_endpoint_t rmt;
} __clib_packed session_accepted_msg_t;
typedef struct session_accepted_reply_msg_
@@ -315,9 +313,7 @@ typedef struct session_connected_msg_
u32 segment_size;
u8 segment_name_length;
u8 segment_name[64];
- u8 lcl_ip[16];
- u8 is_ip4;
- u16 lcl_port;
+ transport_endpoint_t lcl;
} __clib_packed session_connected_msg_t;
typedef struct session_disconnected_msg_
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index c1d02ab8f09..aaf252be257 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1292,17 +1292,15 @@ session_get_transport (session_t * s)
}
void
-session_get_endpoint (session_t * s, ip46_address_t * ip, u16 * port,
- u8 * is_ip4, u8 is_lcl)
+session_get_endpoint (session_t * s, transport_endpoint_t * tep, u8 is_lcl)
{
if (s->session_state != SESSION_STATE_LISTENING)
return transport_get_endpoint (session_get_transport_proto (s),
- s->connection_index, s->thread_index, ip,
- port, is_ip4, is_lcl);
+ s->connection_index, s->thread_index, tep,
+ is_lcl);
else
return transport_get_listener_endpoint (session_get_transport_proto (s),
- s->connection_index, ip, port,
- is_ip4, is_lcl);
+ s->connection_index, tep, is_lcl);
}
transport_connection_t *
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 375b47a60cd..4e63d42de83 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -338,8 +338,8 @@ void session_send_rpc_evt_to_thread (u32 thread_index, void *fp,
void session_send_rpc_evt_to_thread_force (u32 thread_index, void *fp,
void *rpc_args);
transport_connection_t *session_get_transport (session_t * s);
-void session_get_endpoint (session_t * s, ip46_address_t * ip, u16 * port,
- u8 * is_ip4, u8 is_lcl);
+void session_get_endpoint (session_t * s, transport_endpoint_t * tep,
+ u8 is_lcl);
u8 *format_session (u8 * s, va_list * args);
uword unformat_session (unformat_input_t * input, va_list * args);
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index d0af0fac279..0a7781f2876 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -212,8 +212,7 @@ mq_send_session_accepted_cb (session_t * s)
mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
mp->handle = session_handle (s);
- session_get_endpoint (s, (ip46_address_t *) mp->ip, &mp->port,
- &mp->is_ip4, 0 /* is_lcl */ );
+ session_get_endpoint (s, &mp->rmt, 0 /* is_lcl */ );
}
else
{
@@ -223,9 +222,9 @@ mq_send_session_accepted_cb (session_t * s)
listener = listen_session_get (s->listener_index);
al = app_listener_get (app, listener->al_index);
mp->listener_handle = app_listener_handle (al);
- mp->is_ip4 = session_type_is_ip4 (listener->session_type);
+ mp->rmt.is_ip4 = session_type_is_ip4 (listener->session_type);
+ mp->rmt.port = ct->c_rmt_port;
mp->handle = session_handle (s);
- mp->port = ct->c_rmt_port;
vpp_queue = session_main_get_vpp_event_queue (0);
mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
}
@@ -348,8 +347,7 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
mp->handle = session_handle (s);
mp->vpp_event_queue_address = pointer_to_uword (vpp_mq);
- session_get_endpoint (s, (ip46_address_t *) mp->lcl_ip, &mp->lcl_port,
- &mp->is_ip4, 1 /* is_lcl */ );
+ session_get_endpoint (s, &mp->lcl, 1 /* is_lcl */ );
mp->server_rx_fifo = pointer_to_uword (s->rx_fifo);
mp->server_tx_fifo = pointer_to_uword (s->tx_fifo);
@@ -362,8 +360,8 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
cct = (ct_connection_t *) session_get_transport (s);
mp->handle = session_handle (s);
- mp->lcl_port = cct->c_lcl_port;
- mp->is_ip4 = cct->c_is_ip4;
+ mp->lcl.port = cct->c_lcl_port;
+ mp->lcl.is_ip4 = cct->c_is_ip4;
vpp_mq = session_main_get_vpp_event_queue (0);
mp->vpp_event_queue_address = pointer_to_uword (vpp_mq);
mp->server_rx_fifo = pointer_to_uword (s->rx_fifo);
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 9efe0e17307..0679eaa1079 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -321,52 +321,49 @@ transport_protocol_is_cl (transport_proto_t tp)
always_inline void
default_get_transport_endpoint (transport_connection_t * tc,
- ip46_address_t * ip, u16 * port, u8 * is_ip4,
- u8 is_lcl)
+ transport_endpoint_t * tep, u8 is_lcl)
{
if (is_lcl)
{
- *port = tc->lcl_port;
- *is_ip4 = tc->is_ip4;
- clib_memcpy_fast (ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
+ tep->port = tc->lcl_port;
+ tep->is_ip4 = tc->is_ip4;
+ clib_memcpy_fast (&tep->ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
}
else
{
- *port = tc->rmt_port;
- *is_ip4 = tc->is_ip4;
- clib_memcpy_fast (ip, &tc->rmt_ip, sizeof (tc->rmt_ip));
+ tep->port = tc->rmt_port;
+ tep->is_ip4 = tc->is_ip4;
+ clib_memcpy_fast (&tep->ip, &tc->rmt_ip, sizeof (tc->rmt_ip));
}
}
void
transport_get_endpoint (transport_proto_t tp, u32 conn_index,
- u32 thread_index, ip46_address_t * ip, u16 * port,
- u8 * is_ip4, u8 is_lcl)
+ u32 thread_index, transport_endpoint_t * tep,
+ u8 is_lcl)
{
if (tp_vfts[tp].get_transport_endpoint)
- tp_vfts[tp].get_transport_endpoint (conn_index, thread_index, ip, port,
- is_ip4, is_lcl);
+ tp_vfts[tp].get_transport_endpoint (conn_index, thread_index, tep,
+ is_lcl);
else
{
transport_connection_t *tc;
tc = transport_get_connection (tp, conn_index, thread_index);
- default_get_transport_endpoint (tc, ip, port, is_ip4, is_lcl);
+ default_get_transport_endpoint (tc, tep, is_lcl);
}
}
void
transport_get_listener_endpoint (transport_proto_t tp, u32 conn_index,
- ip46_address_t * ip, u16 * port, u8 * is_ip4,
- u8 is_lcl)
+ transport_endpoint_t * tep, u8 is_lcl)
{
if (tp_vfts[tp].get_transport_listener_endpoint)
- tp_vfts[tp].get_transport_listener_endpoint (conn_index, ip, port, is_ip4,
- is_lcl);
+ tp_vfts[tp].get_transport_listener_endpoint (conn_index, tep, is_lcl);
else
{
transport_connection_t *tc;
tc = transport_get_listener (tp, conn_index);
- default_get_transport_endpoint (tc, ip, port, is_ip4, is_lcl);
+ default_get_transport_endpoint (tc, tep, is_lcl);
}
}
diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h
index 73d7fba3c49..0aaaf7482d3 100644
--- a/src/vnet/session/transport.h
+++ b/src/vnet/session/transport.h
@@ -62,10 +62,14 @@ typedef struct _transport_proto_vft
u8 *(*format_listener) (u8 * s, va_list * args);
u8 *(*format_half_open) (u8 * s, va_list * args);
- /* External API response */
-
- void (*get_transport_endpoint) (u32 conn_index, u32 thread_index, ip46_address_t * ip, u16 * port, u8 * is_ip4, u8 is_lcl);
- void (*get_transport_listener_endpoint) (u32 conn_index, ip46_address_t * ip, u16 * port, u8 * is_ip4, u8 is_lcl);
+ /*
+ * Properties retrieval
+ */
+ void (*get_transport_endpoint) (u32 conn_index, u32 thread_index,
+ transport_endpoint_t *tep, u8 is_lcl);
+ void (*get_transport_listener_endpoint) (u32 conn_index,
+ transport_endpoint_t *tep,
+ u8 is_lcl);
/*
* Properties
@@ -92,11 +96,10 @@ u32 transport_stop_listen (transport_proto_t tp, u32 conn_index);
void transport_cleanup (transport_proto_t tp, u32 conn_index,
u8 thread_index);
void transport_get_endpoint (transport_proto_t tp, u32 conn_index,
- u32 thread_index, ip46_address_t * ip,
- u16 * port, u8 * is_ip4, u8 is_lcl);
+ u32 thread_index, transport_endpoint_t * tep,
+ u8 is_lcl);
void transport_get_listener_endpoint (transport_proto_t tp, u32 conn_index,
- ip46_address_t * ip, u16 * port,
- u8 * is_ip4, u8 is_lcl);
+ transport_endpoint_t * tep, u8 is_lcl);
static inline transport_connection_t *
transport_get_connection (transport_proto_t tp, u32 conn_index,