From: Steven Luong Date: Fri, 1 Aug 2025 22:26:49 +0000 (-0700) Subject: tcp: conditionally initializing log track for unbind X-Git-Tag: v26.02-rc0~130 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F12%2F43512%2F2;p=vpp.git tcp: conditionally initializing log track for unbind elog track is initialized when tcp open, bind, or syn rcvd message is received. Logging tcp unbind event requires and expects elog track is already initialized. If tcp debug is enabled after the aforementioned 3 messages and the first event that tcp logs is unbind, we crash because elog track is not initialized. Let's check the elog track is initialized yet or not prior to logging an unbind event. If not, we initialize it. Type: fix Change-Id: Ib8fde694dc48f30a87aa3ecd378c1960857e8c38 Signed-off-by: Steven Luong --- diff --git a/src/vnet/tcp/tcp_debug.h b/src/vnet/tcp/tcp_debug.h index 04e921cd601..8ae45655002 100644 --- a/src/vnet/tcp/tcp_debug.h +++ b/src/vnet/tcp/tcp_debug.h @@ -289,17 +289,17 @@ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, _e, \ TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ } -#define TCP_EVT_UNBIND_HANDLER(_tc, ...) \ -{ \ - TCP_EVT_DEALLOC_HANDLER(_tc); \ - ELOG_TYPE_DECLARE (_e) = \ - { \ - .format = "unbind: listener %d", \ - }; \ - TCP_DECLARE_ETD(_tc, _e, 1); \ - ed->data[0] = _tc->c_c_index; \ - TCP_EVT_DEALLOC_HANDLER(_tc); \ -} +#define TCP_EVT_UNBIND_HANDLER(_tc, ...) \ + { \ + if (_tc->c_elog_track.name == 0) \ + TCP_EVT_INIT_HANDLER (_tc, 1); \ + ELOG_TYPE_DECLARE (_e) = { \ + .format = "unbind: listener %d", \ + }; \ + TCP_DECLARE_ETD (_tc, _e, 1); \ + ed->data[0] = _tc->c_c_index; \ + TCP_EVT_DEALLOC_HANDLER (_tc); \ + } #define TCP_EVT_DELETE_HANDLER(_tc, ...) \ { \