summaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/session.c33
-rw-r--r--src/vnet/session/session.h6
-rw-r--r--src/vnet/session/session_node.c12
-rw-r--r--src/vnet/session/transport.c3
4 files changed, 53 insertions, 1 deletions
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 77259ad76d3..42f24d2fb21 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1768,6 +1768,39 @@ session_register_transport (transport_proto_t transport_proto,
session_tx_fns[vft->transport_options.tx_type];
}
+void
+session_register_update_time_fn (session_update_time_fn fn, u8 is_add)
+{
+ session_main_t *smm = &session_main;
+ session_update_time_fn *fi;
+ u32 fi_pos = ~0;
+ u8 found = 0;
+
+ vec_foreach (fi, smm->update_time_fns)
+ {
+ if (*fi == fn)
+ {
+ fi_pos = fi - smm->update_time_fns;
+ found = 1;
+ break;
+ }
+ }
+
+ if (is_add)
+ {
+ if (found)
+ {
+ clib_warning ("update time fn %p already registered", fn);
+ return;
+ }
+ vec_add1 (smm->update_time_fns, fn);
+ }
+ else
+ {
+ vec_del1 (smm->update_time_fns, fi_pos);
+ }
+}
+
transport_proto_t
session_add_transport_proto (void)
{
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 9d6c945bb4d..c2984198bf7 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -171,11 +171,16 @@ extern session_fifo_rx_fn session_tx_fifo_dequeue_internal;
u8 session_node_lookup_fifo_event (svm_fifo_t * f, session_event_t * e);
+typedef void (*session_update_time_fn) (f64 time_now, u8 thread_index);
+
typedef struct session_main_
{
/** Worker contexts */
session_worker_t *wrk;
+ /** Vector of transport update time functions */
+ session_update_time_fn *update_time_fns;
+
/** Event queues memfd segment */
fifo_segment_t wrk_mqs_segment;
@@ -528,6 +533,7 @@ void session_register_transport (transport_proto_t transport_proto,
const transport_proto_vft_t * vft, u8 is_ip4,
u32 output_node);
transport_proto_t session_add_transport_proto (void);
+void session_register_update_time_fn (session_update_time_fn fn, u8 is_add);
int session_tx_fifo_peek_bytes (transport_connection_t * tc, u8 * buffer,
u32 offset, u32 max_bytes);
u32 session_tx_fifo_dequeue_drop (transport_connection_t * tc, u32 max_bytes);
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index 403c28f28ce..162d54e7697 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -1642,6 +1642,16 @@ static const u32 session_evt_msg_sizes[] = {
/* *INDENT-ON* */
always_inline void
+session_update_time_subscribers (session_main_t *smm, clib_time_type_t now,
+ u32 thread_index)
+{
+ session_update_time_fn *fn;
+
+ vec_foreach (fn, smm->update_time_fns)
+ (*fn) (now, thread_index);
+}
+
+always_inline void
session_evt_add_to_list (session_worker_t * wrk, session_event_t * evt)
{
session_evt_elt_t *elt;
@@ -1755,7 +1765,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/*
* Update transport time
*/
- transport_update_time (wrk->last_vlib_time, thread_index);
+ session_update_time_subscribers (smm, wrk->last_vlib_time, thread_index);
n_tx_packets = vec_len (wrk->pending_tx_buffers);
SESSION_EVT (SESSION_EVT_DSP_CNTRS, UPDATE_TIME, wrk);
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 5d03a4f8453..92df3656a8c 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -830,6 +830,9 @@ transport_enable_disable (vlib_main_t * vm, u8 is_en)
{
if (vft->enable)
(vft->enable) (vm, is_en);
+
+ if (vft->update_time)
+ session_register_update_time_fn (vft->update_time, is_en);
}
}