Skip to content

Commit

Permalink
bgpd: add hooks for displaying module debug messages
Browse files Browse the repository at this point in the history
when a plugin is attached, some debugs may be attached to that plugin.
For that, add one hook that is interacting with vty: a boolean indicates
what the usage is for: either for impacting the 'show running-config',
or for impacting the 'show debugging' command.

Signed-off-by: Philippe Guibert <[email protected]>
Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
pguibert6WIND authored and louis-6wind committed Dec 21, 2023
1 parent 3015f8c commit 6378913
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bgpd/bgp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "memory.h"
#include "queue.h"
#include "filter.h"
#include "hook.h"

#include "bgpd/bgpd.h"
#include "bgpd/bgp_aspath.h"
Expand All @@ -37,6 +38,9 @@

#include "bgpd/bgp_debug_clippy.c"

DEFINE_HOOK(bgp_hook_config_write_debug, (struct vty *vty, bool running),
(vty, running));

unsigned long conf_bgp_debug_as4;
unsigned long conf_bgp_debug_neighbor_events;
unsigned long conf_bgp_debug_events;
Expand Down Expand Up @@ -2245,6 +2249,8 @@ DEFUN_NOSH (show_debugging_bgp,

cmd_show_lib_debugs(vty);

hook_call(bgp_hook_config_write_debug, vty, false);

return CMD_SUCCESS;
}

Expand Down Expand Up @@ -2379,6 +2385,9 @@ static int bgp_config_write_debug(struct vty *vty)
write++;
}

if (hook_call(bgp_hook_config_write_debug, vty, true))
write++;

return write;
}

Expand Down
6 changes: 6 additions & 0 deletions bgpd/bgp_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
#ifndef _QUAGGA_BGP_DEBUG_H
#define _QUAGGA_BGP_DEBUG_H

#include "hook.h"
#include "vty.h"

#include "bgp_attr.h"
#include "bgp_updgrp.h"

DECLARE_HOOK(bgp_hook_config_write_debug, (struct vty *vty, bool running),
(vty, running));

/* sort of packet direction */
#define DUMP_ON 1
#define DUMP_SEND 2
Expand Down

0 comments on commit 6378913

Please sign in to comment.