diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2024-03-26 16:54:54 +0200 |
|---|---|---|
| committer | Mark Stapp <mjs@cisco.com> | 2024-08-27 09:53:02 -0400 |
| commit | 5dac6961540422a1ca139fae8c5ea9e5a437c4ba (patch) | |
| tree | 3ff27afc04b9605f832c747b82449b58d5aa5455 /vrrpd | |
| parent | 1797b7eefc730bb4f5aec08f130861650c61dd97 (diff) | |
lib: rework debug init
The debug library allows to register a `debug_set_all` callback which
should enable all debugs in a daemon. This callback is implemented
exactly the same in each daemon. Instead of duplicating the code, rework
the lib to allow registration of each debug type, and implement the
common code only once in the lib.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'vrrpd')
| -rw-r--r-- | vrrpd/vrrp_debug.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/vrrpd/vrrp_debug.c b/vrrpd/vrrp_debug.c index a772b3b5c5..ebaeca27d3 100644 --- a/vrrpd/vrrp_debug.c +++ b/vrrpd/vrrp_debug.c @@ -42,26 +42,6 @@ const char *vrrp_debugs_conflines[] = { }; /* clang-format on */ -/* - * Set or unset flags on all debugs for vrrpd. - * - * flags - * The flags to set - * - * set - * Whether to set or unset the specified flags - */ -static void vrrp_debug_set_all(uint32_t flags, bool set) -{ - for (unsigned int i = 0; i < array_size(vrrp_debugs); i++) { - DEBUG_FLAGS_SET(vrrp_debugs[i], flags, set); - - /* if all modes have been turned off, don't preserve options */ - if (!DEBUG_MODE_CHECK(vrrp_debugs[i], DEBUG_MODE_ALL)) - DEBUG_CLEAR(vrrp_debugs[i]); - } -} - static int vrrp_debug_config_write_helper(struct vty *vty, bool config) { uint32_t mode = DEBUG_MODE_ALL; @@ -110,9 +90,13 @@ void vrrp_debug_set(struct interface *ifp, uint8_t vrid, int vtynode, /* ------------------------------------------------------------------------- */ -struct debug_callbacks vrrp_dbg_cbs = {.debug_set_all = vrrp_debug_set_all}; - void vrrp_debug_init(void) { - debug_init(&vrrp_dbg_cbs); + debug_install(&vrrp_dbg_arp); + debug_install(&vrrp_dbg_auto); + debug_install(&vrrp_dbg_ndisc); + debug_install(&vrrp_dbg_pkt); + debug_install(&vrrp_dbg_proto); + debug_install(&vrrp_dbg_sock); + debug_install(&vrrp_dbg_zebra); } |
