diff options
author | Florin Coras <fcoras@cisco.com> | 2019-10-28 13:14:17 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-01-30 18:44:13 +0000 |
commit | 9ace36d0f9b04e2d4db410607ee33a8e72ef00c5 (patch) | |
tree | 999536085643a801b0087332ebf4421d5322966c /src/vnet/session | |
parent | 960e58efde0f11d0c1b8783c104c29dee34ee088 (diff) |
vcl session: propagate cleanup notifications to apps
Type: feature
Change-Id: I7f8e3763d7f8364563a25d0fcc782976b906b325
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r-- | src/vnet/session/application_interface.h | 5 | ||||
-rw-r--r-- | src/vnet/session/session_api.c | 30 | ||||
-rw-r--r-- | src/vnet/session/session_types.h | 3 |
3 files changed, 38 insertions, 0 deletions
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h index a6641477f12..552fec1b6ef 100644 --- a/src/vnet/session/application_interface.h +++ b/src/vnet/session/application_interface.h @@ -510,6 +510,11 @@ typedef struct session_migrate_msg_ u32 vpp_thread_index; } __clib_packed session_migrated_msg_t; +typedef struct session_cleanup_msg_ +{ + session_handle_t handle; +} __clib_packed session_cleanup_msg_t; + typedef struct app_session_event_ { svm_msg_q_msg_t msg; diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index c6eeacfea18..a95faada9ae 100644 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -589,6 +589,35 @@ mq_send_del_segment_cb (u32 app_wrk_index, u64 segment_handle) return 0; } +static void +mq_send_session_cleanup_cb (session_t * s, session_cleanup_ntf_t ntf) +{ + svm_msg_q_msg_t _msg, *msg = &_msg; + session_cleanup_msg_t *mp; + svm_msg_q_t *app_mq; + session_event_t *evt; + app_worker_t *app_wrk; + + /* Only propagate session cleanup notification */ + if (ntf == SESSION_CLEANUP_TRANSPORT) + return; + + app_wrk = app_worker_get_if_valid (s->app_wrk_index); + if (!app_wrk) + return; + + app_mq = app_wrk->event_queue; + if (mq_try_lock_and_alloc_msg (app_mq, msg)) + return; + + evt = svm_msg_q_msg_data (app_mq, msg); + clib_memset (evt, 0, sizeof (*evt)); + evt->event_type = SESSION_CTRL_EVT_CLEANUP; + mp = (session_cleanup_msg_t *) evt->data; + mp->handle = session_handle (s); + svm_msg_q_add_and_unlock (app_mq, msg); +} + /* ### WILL BE DEPRECATED POST 20.01 ### */ static session_cb_vft_t session_mq_cb_vft_old = { .session_accept_callback = mq_send_session_accepted_cb, @@ -606,6 +635,7 @@ static session_cb_vft_t session_mq_cb_vft = { .session_connected_callback = mq_send_session_connected_cb, .session_reset_callback = mq_send_session_reset_cb, .session_migrate_callback = mq_send_session_migrate_cb, + .session_cleanup_callback = mq_send_session_cleanup_cb, .add_segment_callback = mq_send_add_segment_cb, .del_segment_callback = mq_send_del_segment_cb, }; diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h index 60d5e4d823c..be8ad9cdb83 100644 --- a/src/vnet/session/session_types.h +++ b/src/vnet/session/session_types.h @@ -337,6 +337,7 @@ typedef enum SESSION_CTRL_EVT_APP_ADD_SEGMENT, SESSION_CTRL_EVT_APP_DEL_SEGMENT, SESSION_CTRL_EVT_MIGRATED, + SESSION_CTRL_EVT_CLEANUP, } session_evt_type_t; #define foreach_session_ctrl_evt \ @@ -360,6 +361,8 @@ typedef enum _(APP_DETACH, app_detach) \ _(APP_ADD_SEGMENT, app_add_segment) \ _(APP_DEL_SEGMENT, app_del_segment) \ + _(MIGRATED, migrated) \ + _(CLEANUP, cleanup) \ /* Deprecated and will be removed. Use types above */ #define FIFO_EVENT_APP_RX SESSION_IO_EVT_RX |