forked from Mirror/frr
*: 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: #15896 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
51119823d0
commit
73ad64a6f4
|
@ -26,6 +26,7 @@
|
||||||
#include "bfd.h"
|
#include "bfd.h"
|
||||||
#include "libfrr.h"
|
#include "libfrr.h"
|
||||||
#include "ns.h"
|
#include "ns.h"
|
||||||
|
#include "libagentx.h"
|
||||||
|
|
||||||
#include "bgpd/bgpd.h"
|
#include "bgpd/bgpd.h"
|
||||||
#include "bgpd/bgp_attr.h"
|
#include "bgpd/bgp_attr.h"
|
||||||
|
@ -516,8 +517,10 @@ int main(int argc, char **argv)
|
||||||
bgp_option_set(BGP_OPT_NO_ZEBRA);
|
bgp_option_set(BGP_OPT_NO_ZEBRA);
|
||||||
bgp_error_init();
|
bgp_error_init();
|
||||||
/* Initializations. */
|
/* Initializations. */
|
||||||
|
libagentx_init();
|
||||||
bgp_vrf_init();
|
bgp_vrf_init();
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_SCRIPTING
|
#ifdef HAVE_SCRIPTING
|
||||||
bgp_script_init();
|
bgp_script_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "distribute.h"
|
#include "distribute.h"
|
||||||
#include "libfrr.h"
|
#include "libfrr.h"
|
||||||
#include "routemap.h"
|
#include "routemap.h"
|
||||||
|
#include "libagentx.h"
|
||||||
//#include "if_rmap.h"
|
//#include "if_rmap.h"
|
||||||
|
|
||||||
#include "eigrpd/eigrp_structs.h"
|
#include "eigrpd/eigrp_structs.h"
|
||||||
|
@ -178,9 +179,11 @@ int main(int argc, char **argv, char **envp)
|
||||||
|
|
||||||
/* EIGRP master init. */
|
/* EIGRP master init. */
|
||||||
eigrp_master_init();
|
eigrp_master_init();
|
||||||
|
|
||||||
eigrp_om->master = frr_init();
|
eigrp_om->master = frr_init();
|
||||||
master = eigrp_om->master;
|
master = eigrp_om->master;
|
||||||
|
|
||||||
|
libagentx_init();
|
||||||
eigrp_error_init();
|
eigrp_error_init();
|
||||||
eigrp_vrf_init();
|
eigrp_vrf_init();
|
||||||
vrf_init(NULL, NULL, NULL, NULL);
|
vrf_init(NULL, NULL, NULL, NULL);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "libfrr.h"
|
#include "libfrr.h"
|
||||||
#include "routemap.h"
|
#include "routemap.h"
|
||||||
#include "affinitymap.h"
|
#include "affinitymap.h"
|
||||||
|
#include "libagentx.h"
|
||||||
|
|
||||||
#include "isisd/isis_affinitymap.h"
|
#include "isisd/isis_affinitymap.h"
|
||||||
#include "isisd/isis_constants.h"
|
#include "isisd/isis_constants.h"
|
||||||
|
@ -307,6 +308,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
/*
|
/*
|
||||||
* initializations
|
* initializations
|
||||||
*/
|
*/
|
||||||
|
libagentx_init();
|
||||||
cmd_init_config_callbacks(isis_config_start, isis_config_end);
|
cmd_init_config_callbacks(isis_config_start, isis_config_end);
|
||||||
isis_error_init();
|
isis_error_init();
|
||||||
access_list_init();
|
access_list_init();
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "libfrr.h"
|
#include "libfrr.h"
|
||||||
#include "lib_errors.h"
|
#include "lib_errors.h"
|
||||||
#include "zlog_recirculate.h"
|
#include "zlog_recirculate.h"
|
||||||
|
#include "libagentx.h"
|
||||||
|
|
||||||
static void ldpd_shutdown(void);
|
static void ldpd_shutdown(void);
|
||||||
static pid_t start_child(enum ldpd_process, char *, int, int, int);
|
static pid_t start_child(enum ldpd_process, char *, int, int, int);
|
||||||
|
@ -370,6 +371,7 @@ main(int argc, char *argv[])
|
||||||
zlog_recirculate_subscribe(master, pipe_lde_log[0]);
|
zlog_recirculate_subscribe(master, pipe_lde_log[0]);
|
||||||
zlog_recirculate_subscribe(master, pipe_ldpe_log[0]);
|
zlog_recirculate_subscribe(master, pipe_ldpe_log[0]);
|
||||||
|
|
||||||
|
libagentx_init();
|
||||||
vrf_init(NULL, NULL, NULL, NULL);
|
vrf_init(NULL, NULL, NULL, NULL);
|
||||||
access_list_init();
|
access_list_init();
|
||||||
ldp_vty_init();
|
ldp_vty_init();
|
||||||
|
|
44
lib/agentx.c
44
lib/agentx.c
|
@ -22,12 +22,13 @@
|
||||||
#include "hook.h"
|
#include "hook.h"
|
||||||
#include "libfrr.h"
|
#include "libfrr.h"
|
||||||
#include "xref.h"
|
#include "xref.h"
|
||||||
|
#include "lib/libagentx.h"
|
||||||
|
|
||||||
XREF_SETUP();
|
XREF_SETUP();
|
||||||
|
|
||||||
DEFINE_HOOK(agentx_enabled, (), ());
|
DEFINE_HOOK(agentx_enabled, (), ());
|
||||||
|
|
||||||
static bool agentx_enabled = false;
|
//bool agentx_enabled = false;
|
||||||
|
|
||||||
static struct event_loop *agentx_tm;
|
static struct event_loop *agentx_tm;
|
||||||
static struct event *timeout_thr = NULL;
|
static struct event *timeout_thr = NULL;
|
||||||
|
@ -153,15 +154,6 @@ static void agentx_events_update(void)
|
||||||
netsnmp_large_fd_set_cleanup(&lfds);
|
netsnmp_large_fd_set_cleanup(&lfds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AgentX node. */
|
|
||||||
static int config_write_agentx(struct vty *vty);
|
|
||||||
static struct cmd_node agentx_node = {
|
|
||||||
.name = "smux",
|
|
||||||
.node = SMUX_NODE,
|
|
||||||
.prompt = "",
|
|
||||||
.config_write = config_write_agentx,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Logging NetSNMP messages */
|
/* Logging NetSNMP messages */
|
||||||
static int agentx_log_callback(int major, int minor, void *serverarg,
|
static int agentx_log_callback(int major, int minor, void *serverarg,
|
||||||
void *clientarg)
|
void *clientarg)
|
||||||
|
@ -201,17 +193,7 @@ static int agentx_log_callback(int major, int minor, void *serverarg,
|
||||||
return SNMP_ERR_NOERROR;
|
return SNMP_ERR_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_write_agentx(struct vty *vty)
|
static int agentx_cli_on(void)
|
||||||
{
|
|
||||||
if (agentx_enabled)
|
|
||||||
vty_out(vty, "agentx\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN (agentx_enable,
|
|
||||||
agentx_enable_cmd,
|
|
||||||
"agentx",
|
|
||||||
"SNMP AgentX protocol settings\n")
|
|
||||||
{
|
{
|
||||||
if (!agentx_enabled) {
|
if (!agentx_enabled) {
|
||||||
init_snmp(FRR_SMUX_NAME);
|
init_snmp(FRR_SMUX_NAME);
|
||||||
|
@ -221,19 +203,14 @@ DEFUN (agentx_enable,
|
||||||
hook_call(agentx_enabled);
|
hook_call(agentx_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (no_agentx,
|
static int agentx_cli_off(void)
|
||||||
no_agentx_cmd,
|
|
||||||
"no agentx",
|
|
||||||
NO_STR
|
|
||||||
"SNMP AgentX protocol settings\n")
|
|
||||||
{
|
{
|
||||||
if (!agentx_enabled)
|
if (!agentx_enabled)
|
||||||
return CMD_SUCCESS;
|
return 1;
|
||||||
vty_out(vty, "SNMP AgentX support cannot be disabled once enabled\n");
|
return 0;
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smux_disable(void)
|
static int smux_disable(void)
|
||||||
|
@ -252,6 +229,9 @@ void smux_init(struct event_loop *tm)
|
||||||
{
|
{
|
||||||
agentx_tm = tm;
|
agentx_tm = tm;
|
||||||
|
|
||||||
|
hook_register(agentx_cli_enabled, agentx_cli_on);
|
||||||
|
hook_register(agentx_cli_disabled, agentx_cli_off);
|
||||||
|
|
||||||
netsnmp_enable_subagent();
|
netsnmp_enable_subagent();
|
||||||
snmp_disable_log();
|
snmp_disable_log();
|
||||||
snmp_enable_calllog();
|
snmp_enable_calllog();
|
||||||
|
@ -259,10 +239,6 @@ void smux_init(struct event_loop *tm)
|
||||||
agentx_log_callback, NULL);
|
agentx_log_callback, NULL);
|
||||||
init_agent(FRR_SMUX_NAME);
|
init_agent(FRR_SMUX_NAME);
|
||||||
|
|
||||||
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);
|
hook_register(frr_early_fini, smux_disable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
63
lib/libagentx.c
Normal file
63
lib/libagentx.c
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
/* SNMP cli support
|
||||||
|
* Copyright (C) 2024 Donald Sharp <sharpd@nvidia.com> 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;
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
{
|
||||||
|
agentx_enabled = false;
|
||||||
|
|
||||||
|
install_node(&agentx_node);
|
||||||
|
install_element(CONFIG_NODE, &agentx_enable_cmd);
|
||||||
|
install_element(CONFIG_NODE, &no_agentx_cmd);
|
||||||
|
}
|
14
lib/libagentx.h
Normal file
14
lib/libagentx.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
/* SNMP cli support
|
||||||
|
* Copyright (C) 2024 Donald Sharp <sharpd@nvidia.com> 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
|
|
@ -99,6 +99,7 @@ struct index_oid {
|
||||||
*/
|
*/
|
||||||
extern bool smux_enabled(void);
|
extern bool smux_enabled(void);
|
||||||
|
|
||||||
|
extern void libagentx_init(void);
|
||||||
extern void smux_init(struct event_loop *tm);
|
extern void smux_init(struct event_loop *tm);
|
||||||
extern void smux_agentx_enable(void);
|
extern void smux_agentx_enable(void);
|
||||||
extern void smux_register_mib(const char *, struct variable *, size_t, int,
|
extern void smux_register_mib(const char *, struct variable *, size_t, int,
|
||||||
|
|
|
@ -58,6 +58,7 @@ lib_libfrr_la_SOURCES = \
|
||||||
lib/ldp_sync.c \
|
lib/ldp_sync.c \
|
||||||
lib/lib_errors.c \
|
lib/lib_errors.c \
|
||||||
lib/lib_vty.c \
|
lib/lib_vty.c \
|
||||||
|
lib/libagentx.c \
|
||||||
lib/libfrr.c \
|
lib/libfrr.c \
|
||||||
lib/libfrr_trace.c \
|
lib/libfrr_trace.c \
|
||||||
lib/linklist.c \
|
lib/linklist.c \
|
||||||
|
@ -252,6 +253,7 @@ pkginclude_HEADERS += \
|
||||||
lib/ldp_sync.h \
|
lib/ldp_sync.h \
|
||||||
lib/lib_errors.h \
|
lib/lib_errors.h \
|
||||||
lib/lib_vty.h \
|
lib/lib_vty.h \
|
||||||
|
lib/libagentx.h \
|
||||||
lib/libfrr.h \
|
lib/libfrr.h \
|
||||||
lib/libfrr_trace.h \
|
lib/libfrr_trace.h \
|
||||||
lib/libospf.h \
|
lib/libospf.h \
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "vrf.h"
|
#include "vrf.h"
|
||||||
#include "bfd.h"
|
#include "bfd.h"
|
||||||
#include "libfrr.h"
|
#include "libfrr.h"
|
||||||
|
#include "libagentx.h"
|
||||||
|
|
||||||
#include "ospf6d.h"
|
#include "ospf6d.h"
|
||||||
#include "ospf6_top.h"
|
#include "ospf6_top.h"
|
||||||
|
@ -266,6 +267,7 @@ int main(int argc, char *argv[], char *envp[])
|
||||||
/* thread master */
|
/* thread master */
|
||||||
master = om6->master;
|
master = om6->master;
|
||||||
|
|
||||||
|
libagentx_init();
|
||||||
keychain_init();
|
keychain_init();
|
||||||
ospf6_vrf_init();
|
ospf6_vrf_init();
|
||||||
access_list_init();
|
access_list_init();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "libfrr.h"
|
#include "libfrr.h"
|
||||||
#include "routemap.h"
|
#include "routemap.h"
|
||||||
#include "keychain.h"
|
#include "keychain.h"
|
||||||
|
#include "libagentx.h"
|
||||||
|
|
||||||
#include "ospfd/ospfd.h"
|
#include "ospfd/ospfd.h"
|
||||||
#include "ospfd/ospf_interface.h"
|
#include "ospfd/ospf_interface.h"
|
||||||
|
@ -256,6 +257,7 @@ int main(int argc, char **argv)
|
||||||
master = om->master;
|
master = om->master;
|
||||||
|
|
||||||
/* Library inits. */
|
/* Library inits. */
|
||||||
|
libagentx_init();
|
||||||
ospf_debug_init();
|
ospf_debug_init();
|
||||||
ospf_vrf_init();
|
ospf_vrf_init();
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ frr_top_src = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
# not quite obvious...
|
# not quite obvious...
|
||||||
|
|
||||||
daemon_flags = {
|
daemon_flags = {
|
||||||
"lib/agentx.c": "VTYSH_ISISD|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA",
|
"lib/libagentx.c": "VTYSH_ISISD|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA",
|
||||||
"lib/filter.c": "VTYSH_ACL_SHOW",
|
"lib/filter.c": "VTYSH_ACL_SHOW",
|
||||||
"lib/filter_cli.c": "VTYSH_ACL_CONFIG",
|
"lib/filter_cli.c": "VTYSH_ACL_CONFIG",
|
||||||
"lib/if.c": "VTYSH_INTERFACE",
|
"lib/if.c": "VTYSH_INTERFACE",
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "routemap.h"
|
#include "routemap.h"
|
||||||
#include "bfd.h"
|
#include "bfd.h"
|
||||||
#include "mgmt_be_client.h"
|
#include "mgmt_be_client.h"
|
||||||
|
#include "libagentx.h"
|
||||||
|
|
||||||
#include "ripd/ripd.h"
|
#include "ripd/ripd.h"
|
||||||
#include "ripd/rip_bfd.h"
|
#include "ripd/rip_bfd.h"
|
||||||
|
@ -190,6 +191,7 @@ int main(int argc, char **argv)
|
||||||
master = frr_init();
|
master = frr_init();
|
||||||
|
|
||||||
/* Library initialization. */
|
/* Library initialization. */
|
||||||
|
libagentx_init();
|
||||||
rip_error_init();
|
rip_error_init();
|
||||||
keychain_init_new(true);
|
keychain_init_new(true);
|
||||||
rip_vrf_init();
|
rip_vrf_init();
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "routemap.h"
|
#include "routemap.h"
|
||||||
#include "routing_nb.h"
|
#include "routing_nb.h"
|
||||||
#include "mgmt_be_client.h"
|
#include "mgmt_be_client.h"
|
||||||
|
#include "libagentx.h"
|
||||||
|
|
||||||
#include "zebra/zebra_router.h"
|
#include "zebra/zebra_router.h"
|
||||||
#include "zebra/zebra_errors.h"
|
#include "zebra/zebra_errors.h"
|
||||||
|
@ -435,6 +436,7 @@ int main(int argc, char **argv)
|
||||||
zrouter.master = frr_init();
|
zrouter.master = frr_init();
|
||||||
|
|
||||||
/* Zebra related initialize. */
|
/* Zebra related initialize. */
|
||||||
|
libagentx_init();
|
||||||
zebra_router_init(asic_offload, notify_on_ack, v6_with_v4_nexthop);
|
zebra_router_init(asic_offload, notify_on_ack, v6_with_v4_nexthop);
|
||||||
zserv_init();
|
zserv_init();
|
||||||
zebra_rib_init();
|
zebra_rib_init();
|
||||||
|
|
Loading…
Reference in a new issue