From 20c242316cbbfa353d4f338ebee7ac715956b6aa Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Mon, 22 Nov 2021 21:19:01 -0800 Subject: session: app mq congestion detection Detect mq congestion and handle it by queueing messages in a fifo and postponing handling via rpcs. App workers with congested mqs cannot accept nor connect additional sessions. Type: feature Signed-off-by: Florin Coras Change-Id: I401d971a1a53896758b88fc60f158cbc31e0c7cb --- src/vnet/session/application.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/vnet/session/application.h') diff --git a/src/vnet/session/application.h b/src/vnet/session/application.h index b3201b9833e..54a616a99b1 100644 --- a/src/vnet/session/application.h +++ b/src/vnet/session/application.h @@ -29,6 +29,16 @@ #define APP_DBG(_fmt, _args...) #endif +typedef struct app_wrk_postponed_msg_ +{ + u32 len; + u8 event_type; + u8 ring; + u8 is_sapi; + int fd; + u8 data[SESSION_CTRL_MSG_MAX_SIZE]; +} app_wrk_postponed_msg_t; + typedef struct app_worker_ { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); @@ -59,6 +69,9 @@ typedef struct app_worker_ /** API index for the worker. Needed for multi-process apps */ u32 api_client_index; + /** Set if mq is congested */ + u8 mq_congested; + u8 app_is_builtin; /** Pool of half-open session handles. Tracked in case worker detaches */ @@ -69,6 +82,12 @@ typedef struct app_worker_ /** Vector of detached listener segment managers */ u32 *detached_seg_managers; + + /** Fifo of messages postponed because of mq congestion */ + app_wrk_postponed_msg_t *postponed_mq_msgs; + + /** Lock to add/sub message from ref @postponed_mq_msgs */ + clib_spinlock_t postponed_mq_msgs_lock; } app_worker_t; typedef struct app_worker_map_ @@ -339,6 +358,10 @@ int app_worker_del_segment_notify (app_worker_t * app_wrk, u32 app_worker_n_listeners (app_worker_t * app); session_t *app_worker_first_listener (app_worker_t * app, u8 fib_proto, u8 transport_proto); +void app_wrk_send_ctrl_evt_fd (app_worker_t *app_wrk, u8 evt_type, void *msg, + u32 msg_len, int fd); +void app_wrk_send_ctrl_evt (app_worker_t *app_wrk, u8 evt_type, void *msg, + u32 msg_len); int app_worker_send_event (app_worker_t * app, session_t * s, u8 evt); int app_worker_lock_and_send_event (app_worker_t * app, session_t * s, u8 evt_type); -- cgit 1.2.3-korg