Allow sessions to be allocated in app's RX callbacks
This enables applications to create sessions in their RX callbacks, which can
invalidate the session pointer. This is required for the QUIC protocol
implementation.
Change-Id: I6072c1c368fd9d17a960ec086a788089dd6f54b4
Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 31539df..90248b6 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -492,6 +492,11 @@
session_enqueue_notify_inline (session_t * s)
{
app_worker_t *app_wrk;
+ u32 session_index;
+ u8 n_subscribers;
+
+ session_index = s->session_index;
+ n_subscribers = svm_fifo_n_subscribers (s->rx_fifo);
app_wrk = app_worker_get_if_valid (s->app_wrk_index);
if (PREDICT_FALSE (!app_wrk))
@@ -512,9 +517,12 @@
SESSION_IO_EVT_RX)))
return -1;
- if (PREDICT_FALSE (svm_fifo_n_subscribers (s->rx_fifo)))
- return session_notify_subscribers (app_wrk->app_index, s,
- s->rx_fifo, SESSION_IO_EVT_RX);
+ if (PREDICT_FALSE (n_subscribers))
+ {
+ s = session_get (session_index, vlib_get_thread_index ());
+ return session_notify_subscribers (app_wrk->app_index, s,
+ s->rx_fifo, SESSION_IO_EVT_RX);
+ }
return 0;
}