Skip to content

Commit

Permalink
lib: On shutdown, disable snmp from working
Browse files Browse the repository at this point in the history
When shutting down ensure that any daemon operating with
snmp tells it to stop operating so no more data is sent.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Dec 15, 2022
1 parent 2fcd46f commit 6f83bbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/agentx.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "linklist.h"
#include "lib/version.h"
#include "lib_errors.h"
#include "hook.h"
#include "libfrr.h"
#include "xref.h"

XREF_SETUP();
Expand Down Expand Up @@ -245,6 +247,13 @@ DEFUN (no_agentx,
return CMD_WARNING_CONFIG_FAILED;
}

static int smux_disable(void)
{
agentx_enabled = false;

return 0;
}

bool smux_enabled(void)
{
return agentx_enabled;
Expand All @@ -264,6 +273,8 @@ void smux_init(struct thread_master *tm)
install_node(&agentx_node);
install_element(CONFIG_NODE, &agentx_enable_cmd);
install_element(CONFIG_NODE, &no_agentx_cmd);

hook_register(frr_early_fini, smux_disable);
}

void smux_agentx_enable(void)
Expand Down
3 changes: 3 additions & 0 deletions lib/smux.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ struct index_oid {

#define SNMP_IP6ADDRESS(V) (*var_len = sizeof(struct in6_addr), (uint8_t *)&V)

/*
* Check to see if snmp is enabled or not
*/
extern bool smux_enabled(void);

extern void smux_init(struct thread_master *tm);
Expand Down

0 comments on commit 6f83bbd

Please sign in to comment.