forked from FRRouting/frr
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*: Modify agentx to be allowed to be called
If you had a situation where an operator turned on ospfd with snmp but not ospf6d and agentx was configured then you get into a situation where ospf6d would complain that the config for agentx did not exist. Let's modify the code to allow this situation to happen. Fixes: FRRouting#15896 Signed-off-by: Donald Sharp <[email protected]>
- Loading branch information
1 parent
8ac0a1d
commit 88d3912
Showing
14 changed files
with
100 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* SNMP cli support | ||
* Copyright (C) 2024 Donald Sharp <[email protected]> NVIDIA Corporation | ||
*/ | ||
#include <zebra.h> | ||
|
||
#include "lib/hook.h" | ||
#include "lib/libagentx.h" | ||
#include "command.h" | ||
|
||
DEFINE_HOOK(agentx_cli_enabled, (), ()); | ||
DEFINE_HOOK(agentx_cli_disabled, (), ()); | ||
|
||
bool agentx_enabled = false; | ||
|
||
/* AgentX node. */ | ||
static int config_write_agentx(struct vty *vty) | ||
{ | ||
if (agentx_enabled) | ||
vty_out(vty, "agentx\n"); | ||
return 1; | ||
} | ||
|
||
static struct cmd_node agentx_node = { | ||
.name = "smux", | ||
.node = SMUX_NODE, | ||
.prompt = "", | ||
.config_write = config_write_agentx, | ||
}; | ||
|
||
DEFUN(agentx_enable, agentx_enable_cmd, "agentx", | ||
"SNMP AgentX protocol settings\n") | ||
{ | ||
if (!hook_have_hooks(agentx_cli_enabled)) { | ||
zlog_info( | ||
"agentx specified but the agentx Module is not loaded, is this intentional?"); | ||
|
||
return CMD_SUCCESS; | ||
} | ||
|
||
hook_call(agentx_cli_enabled); | ||
|
||
return CMD_SUCCESS; | ||
} | ||
|
||
DEFUN(no_agentx, no_agentx_cmd, "no agentx", | ||
NO_STR "SNMP AgentX protocol settings\n") | ||
{ | ||
vty_out(vty, "SNMP AgentX support cannot be disabled once enabled\n"); | ||
if (!hook_call(agentx_cli_disabled)) | ||
return CMD_WARNING_CONFIG_FAILED; | ||
|
||
return CMD_SUCCESS; | ||
} | ||
|
||
void libagentx_init(void) | ||
{ | ||
install_node(&agentx_node); | ||
install_element(CONFIG_NODE, &agentx_enable_cmd); | ||
install_element(CONFIG_NODE, &no_agentx_cmd); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* SNMP cli support | ||
* Copyright (C) 2024 Donald Sharp <[email protected]> NVIDIA Corporation | ||
*/ | ||
#ifndef __LIBAGENTX_H__ | ||
#define __LIBAGENTX_H__ | ||
|
||
extern void libagentx_init(void); | ||
extern bool agentx_enabled; | ||
|
||
DECLARE_HOOK(agentx_cli_enabled, (), ()); | ||
DECLARE_HOOK(agentx_cli_disabled, (), ()); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters