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> 2004-10-13 Paul Jakma <paul@dishone.st>
* (global) more const'ification and fixups of types to clean up code. * (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 BGPESTABLISHED 1
#define BGPBACKWARDTRANSITION 2 #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. */ /* BGP MIB bgpVersion. */
#define BGPVERSION 0 #define BGPVERSION 0
@ -125,7 +121,6 @@ SNMP_LOCAL_VARIABLES
/* BGP-MIB instances. */ /* BGP-MIB instances. */
oid bgp_oid [] = { BGP4MIB }; oid bgp_oid [] = { BGP4MIB };
oid bgpd_oid [] = { BGPDMIB };
/* IP address 0.0.0.0. */ /* IP address 0.0.0.0. */
static struct in_addr bgp_empty_addr = {0}; static struct in_addr bgp_empty_addr = {0};
@ -880,8 +875,7 @@ bgp_snmp_init ()
if ( !(bm = bgp_get_master ()) ) if ( !(bm = bgp_get_master ()) )
return; 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); REGISTER_MIB("mibII/bgp", bgp_variables, variable, bgp_oid);
smux_start ();
} }
#endif /* HAVE_SNMP */ #endif /* HAVE_SNMP */

View File

@ -2,6 +2,10 @@
* command.c: Make CMD_ERR_NOTHING_TODO nonfatal if reading * command.c: Make CMD_ERR_NOTHING_TODO nonfatal if reading
configuration from file. Fixes critical bugzilla #113. 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> 2004-10-13 Paul Jakma <paul@dishone.st>

View File

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

View File

@ -144,7 +144,7 @@ struct trap_object
(u_char *) &snmp_in_addr_val \ (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_start (void);
void smux_register_mib(const char *, struct variable *, size_t, int, oid [], size_t); 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 *, 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> 2004-10-11 Hasso Tepper <hasso at quagga.net>
* osp6_top.c, ospf6_top.h: Better handling for router-id. If we use * osp6_top.c, ospf6_top.h: Better handling for router-id. If we use

View File

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

View File

@ -1,6 +1,8 @@
2004-10-13 Hasso Tepper <hasso at quagga.net> 2004-10-13 Hasso Tepper <hasso at quagga.net>
* ospf_main.c: Unbreak compilation with ospfapi disabled. * 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> 2004-10-12 Hasso Tepper <hasso at quagga.net>

View File

@ -52,10 +52,6 @@
/* OSPF2-MIB. */ /* OSPF2-MIB. */
#define OSPF2MIB 1,3,6,1,2,1,14 #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. */ /* OSPF MIB General Group values. */
#define OSPFROUTERID 1 #define OSPFROUTERID 1
#define OSPFADMINSTAT 2 #define OSPFADMINSTAT 2
@ -214,7 +210,6 @@ SNMP_LOCAL_VARIABLES
/* OSPF-MIB instances. */ /* OSPF-MIB instances. */
oid ospf_oid [] = { OSPF2MIB }; oid ospf_oid [] = { OSPF2MIB };
oid ospfd_oid [] = { OSPFDOID };
/* IP address 0.0.0.0. */ /* IP address 0.0.0.0. */
static struct in_addr ospf_empty_addr = {0}; static struct in_addr ospf_empty_addr = {0};
@ -2479,8 +2474,7 @@ ospf_snmp_init ()
{ {
ospf_snmp_iflist = list_new (); ospf_snmp_iflist = list_new ();
ospf_snmp_vl_table = route_table_init (); 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); REGISTER_MIB("mibII/ospf", ospf_variables, variable, ospf_oid);
smux_start ();
} }
#endif /* HAVE_SNMP */ #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> 2004-10-11 Hasso Tepper <hasso at quagga.net>
* *.c: Make more strings const. * *.c: Make more strings const.

View File

@ -41,10 +41,6 @@
/* RIPv2-MIB. */ /* RIPv2-MIB. */
#define RIPV2MIB 1,3,6,1,2,1,23 #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. */ /* RIPv2-MIB rip2Globals values. */
#define RIP2GLOBALROUTECHANGES 1 #define RIP2GLOBALROUTECHANGES 1
#define RIP2GLOBALQUERIES 2 #define RIP2GLOBALQUERIES 2
@ -90,7 +86,6 @@ SNMP_LOCAL_VARIABLES
/* RIP-MIB instances. */ /* RIP-MIB instances. */
oid rip_oid [] = { RIPV2MIB }; oid rip_oid [] = { RIPV2MIB };
oid ripd_oid [] = { RIPDOID };
/* Interface cache table sorted by interface's address. */ /* Interface cache table sorted by interface's address. */
struct route_table *rip_ifaddr_table; struct route_table *rip_ifaddr_table;
@ -575,8 +570,7 @@ rip_snmp_init ()
{ {
rip_ifaddr_table = route_table_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); REGISTER_MIB("mibII/rip", rip_variables, variable, rip_oid);
smux_start ();
} }
#endif /* HAVE_SNMP */ #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> 2004-10-12 Hasso Tepper <hasso at quagga.net>
* zebra_vty.c: Unbreak "show ip route" command help and make it work * zebra_vty.c: Unbreak "show ip route" command help and make it work

View File

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