Make initializing smux connection configurable - "smux peer OID" command

initializes connection, and "no smux peer" command terminates it. Fixes
bugzilla #47 and #112.
This commit is contained in:
hasso 2004-10-13 10:33:26 +00:00
parent d68614db1d
commit c75105ab6e
13 changed files with 80 additions and 72 deletions

View File

@ -1,3 +1,8 @@
2004-10-13 Hasso Tepper <hasso at quagga.net>
* bgp_snmp.c: Remove defaults used to initialize smux connection to
snmpd. Connection is initialized only if smux peer is configured.
2004-10-13 Paul Jakma <paul@dishone.st>
* (global) more const'ification and fixups of types to clean up code.

View File

@ -49,10 +49,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#define BGPESTABLISHED 1
#define BGPBACKWARDTRANSITION 2
/* Zebra enterprise BGP MIB. This variable is used for register
OSPF MIB to SNMP agent under SMUX protocol. */
#define BGPDMIB 1,3,6,1,4,1,3317,1,2,2
/* BGP MIB bgpVersion. */
#define BGPVERSION 0
@ -125,7 +121,6 @@ SNMP_LOCAL_VARIABLES
/* BGP-MIB instances. */
oid bgp_oid [] = { BGP4MIB };
oid bgpd_oid [] = { BGPDMIB };
/* IP address 0.0.0.0. */
static struct in_addr bgp_empty_addr = {0};
@ -880,8 +875,7 @@ bgp_snmp_init ()
if ( !(bm = bgp_get_master ()) )
return;
smux_init (bm->master, bgpd_oid, sizeof bgpd_oid / sizeof (oid));
smux_init (bm->master);
REGISTER_MIB("mibII/bgp", bgp_variables, variable, bgp_oid);
smux_start ();
}
#endif /* HAVE_SNMP */

View File

@ -2,6 +2,10 @@
* command.c: Make CMD_ERR_NOTHING_TODO nonfatal if reading
configuration from file. Fixes critical bugzilla #113.
* smux.c, smux.h: Remove all defaults to initialize smux connection to
snmpd by default even if not configured to do so. "smux peer OID
<password>" initializes now connection and "no smux peer" terminates
it.
2004-10-13 Paul Jakma <paul@dishone.st>

View File

@ -52,16 +52,11 @@ int smux_sock = -1;
struct list *treelist;
/* SMUX oid. */
oid *smux_oid;
oid *smux_oid = NULL;
size_t smux_oid_len;
/* SMUX default oid. */
oid *smux_default_oid;
size_t smux_default_oid_len;
/* SMUX password. */
char *smux_passwd;
const char *smux_default_passwd = "";
char *smux_passwd = NULL;
/* SMUX read threads. */
struct thread *smux_read_thread;
@ -1316,11 +1311,14 @@ smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
return CMD_WARNING;
}
if (smux_oid && smux_oid != smux_default_oid)
free (smux_oid);
if (smux_oid)
{
free (smux_oid);
smux_oid = NULL;
}
/* careful, smux_passwd might point to string constant */
if (smux_passwd && smux_passwd != smux_default_passwd)
if (smux_passwd)
{
free (smux_passwd);
smux_passwd = NULL;
@ -1331,8 +1329,10 @@ smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
if (passwd_str)
smux_passwd = strdup (passwd_str);
else
smux_passwd = strdup ("");
return CMD_SUCCESS;
return 0;
}
int
@ -1364,19 +1364,19 @@ smux_header_generic (struct variable *v, oid *name, size_t *length, int exact,
int
smux_peer_default ()
{
if (smux_oid != smux_default_oid)
if (smux_oid)
{
free (smux_oid);
smux_oid = smux_default_oid;
smux_oid_len = smux_default_oid_len;
smux_oid = NULL;
}
/* careful, smux_passwd might be pointing at string constant */
if (smux_passwd != smux_default_passwd)
if (smux_passwd)
{
free (smux_passwd);
smux_passwd = (char *)smux_default_passwd;
smux_passwd = NULL;
}
return CMD_SUCCESS;
}
@ -1387,7 +1387,13 @@ DEFUN (smux_peer,
"SNMP MUX peer settings\n"
"Object ID used in SMUX peering\n")
{
return smux_peer_oid (vty, argv[0], NULL);
if (smux_peer_oid (vty, argv[0], NULL) == 0)
{
smux_start();
return CMD_SUCCESS;
}
else
return CMD_WARNING;
}
DEFUN (smux_peer_password,
@ -1398,31 +1404,42 @@ DEFUN (smux_peer_password,
"SMUX peering object ID\n"
"SMUX peering password\n")
{
return smux_peer_oid (vty, argv[0], argv[1]);
if (smux_peer_oid (vty, argv[0], argv[1]) == 0)
{
smux_start();
return CMD_SUCCESS;
}
else
return CMD_WARNING;
}
DEFUN (no_smux_peer,
no_smux_peer_cmd,
"no smux peer",
NO_STR
"SNMP MUX protocol settings\n"
"SNMP MUX peer settings\n")
{
smux_stop();
return smux_peer_default ();
}
ALIAS (no_smux_peer,
no_smux_peer_oid_cmd,
"no smux peer OID",
NO_STR
"SNMP MUX protocol settings\n"
"SNMP MUX peer settings\n"
"Object ID used in SMUX peering\n")
{
return smux_peer_default ();
}
"SMUX peering object ID\n")
DEFUN (no_smux_peer_password,
no_smux_peer_password_cmd,
ALIAS (no_smux_peer,
no_smux_peer_oid_password_cmd,
"no smux peer OID PASSWORD",
NO_STR
"SNMP MUX protocol settings\n"
"SNMP MUX peer settings\n"
"SMUX peering object ID\n"
"SMUX peering password\n")
{
return smux_peer_default ();
}
int
config_write_smux (struct vty *vty)
@ -1430,7 +1447,7 @@ config_write_smux (struct vty *vty)
int first = 1;
unsigned int i;
if (smux_oid != smux_default_oid || smux_passwd != smux_default_passwd)
if (smux_oid)
{
vty_out (vty, "smux peer ");
for (i = 0; i < smux_oid_len; i++)
@ -1478,18 +1495,8 @@ smux_tree_cmp(struct subtree *tree1, struct subtree *tree2)
/* Initialize some values then schedule first SMUX connection. */
void
smux_init (struct thread_master *tm, oid defoid[], size_t defoid_len)
smux_init (struct thread_master *tm)
{
/* Set default SMUX oid. */
smux_default_oid = defoid;
smux_default_oid_len = defoid_len;
smux_oid = smux_default_oid;
smux_oid_len = smux_default_oid_len;
/* be careful with smux_passwd, points to string constant by default */
smux_passwd = (char *)smux_default_passwd;
/* copy callers thread master */
master = tm;
@ -1503,7 +1510,8 @@ smux_init (struct thread_master *tm, oid defoid[], size_t defoid_len)
install_element (CONFIG_NODE, &smux_peer_cmd);
install_element (CONFIG_NODE, &smux_peer_password_cmd);
install_element (CONFIG_NODE, &no_smux_peer_cmd);
install_element (CONFIG_NODE, &no_smux_peer_password_cmd);
install_element (CONFIG_NODE, &no_smux_peer_oid_cmd);
install_element (CONFIG_NODE, &no_smux_peer_oid_password_cmd);
}
void

View File

@ -144,7 +144,7 @@ struct trap_object
(u_char *) &snmp_in_addr_val \
)
void smux_init (struct thread_master *tm, oid [], size_t);
void smux_init (struct thread_master *tm);
void smux_start (void);
void smux_register_mib(const char *, struct variable *, size_t, int, oid [], size_t);
int smux_header_generic (struct variable *, oid [], size_t *, int, size_t *,

View File

@ -1,3 +1,8 @@
2004-10-12 Hasso Tepper <hasso at quagga.net>
* ospf6_snmp.c: Remove defaults used to initialize smux connection to
snmpd. Connection is initialized only if smux peer is configured.
2004-10-11 Hasso Tepper <hasso at quagga.net>
* osp6_top.c, ospf6_top.h: Better handling for router-id. If we use

View File

@ -50,9 +50,6 @@
/* OSPFv3-MIB */
#define OSPFv3MIB 1,3,6,1,3,102
/* Zebra enterprise ospf6d MIB */
#define OSPF6DOID 1,3,6,1,4,1,3317,1,2,6
/* OSPFv3 MIB General Group values. */
#define OSPFv3ROUTERID 1
#define OSPFv3ADMINSTAT 2
@ -101,7 +98,6 @@ static struct in_addr tmp;
/* OSPFv3-MIB instances. */
oid ospfv3_oid [] = { OSPFv3MIB };
oid ospf6d_oid [] = { OSPF6DOID };
/* empty ID 0.0.0.0 e.g. empty router-id */
static struct in_addr ospf6_empty_id = {0};
@ -295,9 +291,8 @@ ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
void
ospf6_snmp_init (struct thread_master *master)
{
smux_init (master, ospf6d_oid, sizeof (ospf6d_oid) / sizeof (oid));
smux_init (master);
REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
smux_start ();
}
#endif /* HAVE_SNMP */

View File

@ -1,6 +1,8 @@
2004-10-13 Hasso Tepper <hasso at quagga.net>
* ospf_main.c: Unbreak compilation with ospfapi disabled.
* ospf_snmp.c: Remove defaults used to initialize smux connection to
snmpd. Connection is initialized only if smux peer is configured.
2004-10-12 Hasso Tepper <hasso at quagga.net>

View File

@ -52,10 +52,6 @@
/* OSPF2-MIB. */
#define OSPF2MIB 1,3,6,1,2,1,14
/* Zebra enterprise OSPF MIB. This variable is used for register
OSPF MIB to SNMP agent under SMUX protocol. */
#define OSPFDOID 1,3,6,1,4,1,3317,1,2,5
/* OSPF MIB General Group values. */
#define OSPFROUTERID 1
#define OSPFADMINSTAT 2
@ -214,7 +210,6 @@ SNMP_LOCAL_VARIABLES
/* OSPF-MIB instances. */
oid ospf_oid [] = { OSPF2MIB };
oid ospfd_oid [] = { OSPFDOID };
/* IP address 0.0.0.0. */
static struct in_addr ospf_empty_addr = {0};
@ -2479,8 +2474,7 @@ ospf_snmp_init ()
{
ospf_snmp_iflist = list_new ();
ospf_snmp_vl_table = route_table_init ();
smux_init (om->master, ospfd_oid, sizeof (ospfd_oid) / sizeof (oid));
smux_init (om->master);
REGISTER_MIB("mibII/ospf", ospf_variables, variable, ospf_oid);
smux_start ();
}
#endif /* HAVE_SNMP */

View File

@ -1,3 +1,8 @@
2004-10-13 Hasso Tepper <hasso at quagga.net>
* ripd_snmp.c: Remove defaults used to initialize smux connection to
snmpd. Connection is initialized only if smux peer is configured.
2004-10-11 Hasso Tepper <hasso at quagga.net>
* *.c: Make more strings const.

View File

@ -41,10 +41,6 @@
/* RIPv2-MIB. */
#define RIPV2MIB 1,3,6,1,2,1,23
/* Zebra enterprise RIP MIB. This variable is used for register
RIPv2-MIB to SNMP agent under SMUX protocol. */
#define RIPDOID 1,3,6,1,4,1,3317,1,2,3
/* RIPv2-MIB rip2Globals values. */
#define RIP2GLOBALROUTECHANGES 1
#define RIP2GLOBALQUERIES 2
@ -90,7 +86,6 @@ SNMP_LOCAL_VARIABLES
/* RIP-MIB instances. */
oid rip_oid [] = { RIPV2MIB };
oid ripd_oid [] = { RIPDOID };
/* Interface cache table sorted by interface's address. */
struct route_table *rip_ifaddr_table;
@ -575,8 +570,7 @@ rip_snmp_init ()
{
rip_ifaddr_table = route_table_init ();
smux_init (master, ripd_oid, sizeof (ripd_oid) / sizeof (oid));
smux_init (master);
REGISTER_MIB("mibII/rip", rip_variables, variable, rip_oid);
smux_start ();
}
#endif /* HAVE_SNMP */

View File

@ -1,3 +1,8 @@
2004-10-13 Hasso Tepper <hasso at quagga.net>
* zebra_snmp.c: Remove defaults used to initialize smux connection to
snmpd. Connection is initialized only if smux peer is configured.
2004-10-12 Hasso Tepper <hasso at quagga.net>
* zebra_vty.c: Unbreak "show ip route" command help and make it work

View File

@ -40,7 +40,6 @@
#include "zebra/zserv.h"
#define IPFWMIB 1,3,6,1,2,1,4,24
#define ZEBRAOID 1,3,6,1,4,1,3317,1,2,1
/* ipForwardTable */
#define IPFORWARDDEST 1
@ -87,7 +86,6 @@
extern struct zebra_t zebrad;
oid ipfw_oid [] = { IPFWMIB };
oid zebra_oid [] = { ZEBRAOID };
/* Hook functions. */
u_char * ipFwNumber ();
@ -564,8 +562,7 @@ ipCidrTable (struct variable *v, oid objid[], size_t *objid_len,
void
zebra_snmp_init ()
{
smux_init (zebrad.master, zebra_oid, sizeof (zebra_oid) / sizeof (oid));
smux_init (zebrad.master);
REGISTER_MIB("mibII/ipforward", zebra_variables, variable, ipfw_oid);
smux_start ();
}
#endif /* HAVE_SNMP */