summaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-03-07 10:06:24 -0800
committerDave Barach <dave@barachs.net>2017-03-13 13:24:39 -0400
commite69f4954a9de40a47f0bc27cdab0ba44e6985dac (patch)
treeb9191f75a4a0eded948efc55ffd2f9dac0360182 /src/vnet/session
parentdfde53ae553f9d4c54882fb55a832cb0614834ea (diff)
VPP-659 Improve tcp/session debugging and testing
- event-logging support for tcp and session layer - improvements to uri test code - builtin_server on port 1234 - use the CLOSEWAIT timer when we rx FIN in FIN_WAIT_2 state Change-Id: Ibc445f164b2086b20323bf89c77cffd3059f570f Signed-off-by: Florin Coras <fcoras@cisco.com> Signed-off-by: Dave Barach <dbarach@cisco.com> Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/node.c18
-rw-r--r--src/vnet/session/session.c24
-rw-r--r--src/vnet/session/session.h3
-rw-r--r--src/vnet/session/session_debug.h86
-rw-r--r--src/vnet/session/transport.h12
5 files changed, 108 insertions, 35 deletions
diff --git a/src/vnet/session/node.c b/src/vnet/session/node.c
index 7fd7e0b7499..822afebde0c 100644
--- a/src/vnet/session/node.c
+++ b/src/vnet/session/node.c
@@ -26,8 +26,8 @@
#include <vlibmemory/unix_shared_memory_queue.h>
#include <vnet/udp/udp_packet.h>
-#include <vnet/lisp-cp/packets.h>
#include <math.h>
+#include <vnet/session/session_debug.h>
vlib_node_registration_t session_queue_node;
@@ -198,22 +198,12 @@ session_tx_fifo_read_and_snd_i (vlib_main_t * vm, vlib_node_runtime_t * node,
len_to_deq0 = (left_to_snd0 < snd_mss0) ? left_to_snd0 : snd_mss0;
/* *INDENT-OFF* */
- if (1)
- {
- ELOG_TYPE_DECLARE (e) = {
- .format = "evt-deq: id %d len %d rd %d wnd %d",
- .format_args = "i4i4i4i4",
- };
- struct
- {
- u32 data[4];
- } *ed;
- ed = ELOG_DATA (&vm->elog_main, e);
+ SESSION_EVT_DBG(s0, SESSION_EVT_DEQ, ({
ed->data[0] = e0->event_id;
ed->data[1] = e0->enqueue_length;
ed->data[2] = len_to_deq0;
ed->data[3] = left_to_snd0;
- }
+ }));
/* *INDENT-ON* */
/* Make room for headers */
@@ -392,7 +382,7 @@ skip_dequeue:
case FIFO_EVENT_SERVER_TX:
/* Spray packets in per session type frames, since they go to
* different nodes */
- rv = (smm->session_rx_fns[s0->session_type]) (vm, node, smm, e0, s0,
+ rv = (smm->session_tx_fns[s0->session_type]) (vm, node, smm, e0, s0,
my_thread_index,
&n_tx_packets);
if (rv < 0)
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 8867e794eeb..06e2a09af31 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -23,6 +23,7 @@
#include <vnet/fib/ip4_fib.h>
#include <vnet/session/application.h>
#include <vnet/tcp/tcp.h>
+#include <vnet/session/session_debug.h>
/**
* Per-type vector of transport protocol virtual function tables
@@ -823,19 +824,12 @@ stream_session_enqueue_notify (stream_session_t * s, u8 block)
else
return -1;
- if (1)
- {
- ELOG_TYPE_DECLARE (e) =
- {
- .format = "evt-enqueue: id %d length %d",.format_args = "i4i4",};
- struct
- {
- u32 data[2];
- } *ed;
- ed = ELOG_DATA (&vlib_global_main.elog_main, e);
+ /* *INDENT-OFF* */
+ SESSION_EVT_DBG(s, SESSION_EVT_ENQ, ({
ed->data[0] = evt.event_id;
ed->data[1] = evt.enqueue_length;
- }
+ }));
+ /* *INDENT-ON* */
return 0;
}
@@ -908,8 +902,7 @@ stream_session_start_listen (u32 server_index, ip46_address_t * ip, u16 port)
s->app_index = srv->index;
/* Transport bind/listen */
- tci = tp_vfts[srv->session_type].bind (smm->vlib_main, s->session_index, ip,
- port);
+ tci = tp_vfts[srv->session_type].bind (s->session_index, ip, port);
/* Attach transport to session */
s->connection_index = tci;
@@ -938,8 +931,7 @@ stream_session_stop_listen (u32 server_index)
tc = tp_vfts[srv->session_type].get_listener (listener->connection_index);
stream_session_table_del_for_tc (smm, listener->session_type, tc);
- tp_vfts[srv->session_type].unbind (smm->vlib_main,
- listener->connection_index);
+ tp_vfts[srv->session_type].unbind (listener->connection_index);
pool_put (smm->listen_sessions[srv->session_type], listener);
}
@@ -1235,7 +1227,7 @@ session_register_transport (u8 type, const transport_proto_vft_t * vft)
tp_vfts[type] = *vft;
/* If an offset function is provided, then peek instead of dequeue */
- smm->session_rx_fns[type] =
+ smm->session_tx_fns[type] =
(vft->tx_fifo_offset) ? session_tx_fifo_peek_and_snd :
session_tx_fifo_dequeue_and_snd;
}
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 1b712e2e59e..96c00d87766 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -211,7 +211,7 @@ struct _session_manager_main
session_manager_t *session_managers;
/** Per transport rx function that can either dequeue or peek */
- session_fifo_rx_fn *session_rx_fns[SESSION_N_TYPES];
+ session_fifo_rx_fn *session_tx_fns[SESSION_N_TYPES];
u8 is_enabled;
@@ -358,6 +358,7 @@ u32 stream_session_dequeue_drop (transport_connection_t * tc, u32 max_bytes);
void
stream_session_connect_notify (transport_connection_t * tc, u8 sst,
u8 is_fail);
+
void stream_session_accept_notify (transport_connection_t * tc);
void stream_session_disconnect_notify (transport_connection_t * tc);
void stream_session_delete_notify (transport_connection_t * tc);
diff --git a/src/vnet/session/session_debug.h b/src/vnet/session/session_debug.h
new file mode 100644
index 00000000000..858f12e0287
--- /dev/null
+++ b/src/vnet/session/session_debug.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef SRC_VNET_SESSION_SESSION_DEBUG_H_
+#define SRC_VNET_SESSION_SESSION_DEBUG_H_
+
+#include <vnet/session/transport.h>
+#include <vnet/session/session.h>
+#include <vlib/vlib.h>
+
+#define foreach_session_dbg_evt \
+ _(ENQ, "enqueue") \
+ _(DEQ, "dequeue")
+
+typedef enum _session_evt_dbg
+{
+#define _(sym, str) SESSION_EVT_##sym,
+ foreach_session_dbg_evt
+#undef _
+} session_evt_dbg_e;
+
+#if TRANSPORT_DEBUG
+
+#define DEC_SESSION_ETD(_s, _e, _size) \
+ struct \
+ { \
+ u32 data[_size]; \
+ } * ed; \
+ transport_proto_vft_t *vft = \
+ session_get_transport_vft (_s->session_type); \
+ transport_connection_t *_tc = \
+ vft->get_connection (_s->connection_index, _s->thread_index); \
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, \
+ _e, _tc->elog_track)
+
+
+#define SESSION_EVT_DEQ_HANDLER(_s, _body) \
+{ \
+ ELOG_TYPE_DECLARE (_e) = \
+ { \
+ .format = "deq: id %d len %d rd %d wnd %d", \
+ .format_args = "i4i4i4i4", \
+ }; \
+ DEC_SESSION_ETD(_s, _e, 4); \
+ do { _body; } while (0); \
+}
+
+#define SESSION_EVT_ENQ_HANDLER(_s, _body) \
+{ \
+ ELOG_TYPE_DECLARE (_e) = \
+ { \
+ .format = "enq: id %d length %d", \
+ .format_args = "i4i4", \
+ }; \
+ DEC_SESSION_ETD(_s, _e, 2); \
+ do { _body; } while (0); \
+}
+
+#define CONCAT_HELPER(_a, _b) _a##_b
+#define CC(_a, _b) CONCAT_HELPER(_a, _b)
+
+#define SESSION_EVT_DBG(_s, _evt, _body) CC(_evt, _HANDLER)(_s, _body)
+
+#else
+#define SESSION_EVT_DBG(_s, _evt, _body)
+#endif
+
+#endif /* SRC_VNET_SESSION_SESSION_DEBUG_H_ */
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h
index 0da30261bef..421121d2fa6 100644
--- a/src/vnet/session/transport.h
+++ b/src/vnet/session/transport.h
@@ -20,7 +20,7 @@
#include <vnet/ip/ip.h>
#include <vppinfra/bihash_16_8.h>
#include <vppinfra/bihash_48_8.h>
-
+#include <vnet/tcp/tcp_debug.h>
/*
* Protocol independent transport properties associated to a session
*/
@@ -37,6 +37,10 @@ typedef struct _transport_connection
u8 is_ip4; /**< Flag if IP4 connection */
u32 thread_index; /**< Worker-thread index */
+#if TRANSPORT_DEBUG
+ elog_track_t elog_track; /**< Debug purposes */
+#endif
+
/** Macros for 'derived classes' where base is named "connection" */
#define c_lcl_ip connection.lcl_ip
#define c_rmt_ip connection.rmt_ip
@@ -52,6 +56,7 @@ typedef struct _transport_connection
#define c_c_index connection.c_index
#define c_is_ip4 connection.is_ip4
#define c_thread_index connection.thread_index
+#define c_elog_track connection.elog_track
} transport_connection_t;
/*
@@ -62,8 +67,8 @@ typedef struct _transport_proto_vft
/*
* Setup
*/
- u32 (*bind) (vlib_main_t *, u32, ip46_address_t *, u16);
- u32 (*unbind) (vlib_main_t *, u32);
+ u32 (*bind) (u32, ip46_address_t *, u16);
+ u32 (*unbind) (u32);
int (*open) (ip46_address_t * addr, u16 port_host_byte_order);
void (*close) (u32 conn_index, u32 thread_index);
void (*cleanup) (u32 conn_index, u32 thread_index);
@@ -89,7 +94,6 @@ typedef struct _transport_proto_vft
u8 *(*format_connection) (u8 * s, va_list * args);
u8 *(*format_listener) (u8 * s, va_list * args);
u8 *(*format_half_open) (u8 * s, va_list * args);
-
} transport_proto_vft_t;
/* *INDENT-OFF* */