Skip to content

Commit

Permalink
bgpd: add support of bgp snmp traps bgp4-mibv2<enable|disable> command
Browse files Browse the repository at this point in the history
since the MIB bgp4-mibv2 notification are  redundant with MIB RFC4273
we added a command
"bgp snmp traps bgp4-mibv2<enable|disable>" for allowing or not
the diffusion of notifications.

Signed-off-by: Francois Dumontet <[email protected]>
  • Loading branch information
fdumontet6WIND committed Sep 1, 2023
1 parent 8069a7a commit f83618e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
32 changes: 31 additions & 1 deletion bgpd/bgp_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,41 @@ DEFPY (bgp_snmp_traps_rfc4273,
return CMD_ERR_INCOMPLETE;
}

DEFPY (bgp_snmp_traps_bgp4_mibv2,
bgp_snmp_traps_bgp4_mibv2_cmd,
"bgp snmp traps bgp4-mibv2<enable$on|disable$off>",
BGP_STR
"Configure BGP SNMP\n"
"Configure SNMP traps for BGP \n"
"Configure use of bgp4-mibv2 SNMP traps for BGP \n"
"Specify using of bgp4-mibv2 traps\n"
"Specify unusing bgp4-mibv2 traps\n")
{

if (on){
SET_FLAG(bgp_snmp_traps_flags,
BGP_SNMP_TRAPS_BGP4MIBV2_ENABLED);
return CMD_SUCCESS;
}
if (off){
UNSET_FLAG(bgp_snmp_traps_flags,
BGP_SNMP_TRAPS_BGP4MIBV2_ENABLED);
return CMD_SUCCESS;
}

vty_out(vty, "bgp traps configuration must be specified \n");
return CMD_ERR_INCOMPLETE;
}

static void bgp_snmp_traps_init(void)
{
install_element(CONFIG_NODE, &bgp_snmp_traps_rfc4273_cmd);
install_element(CONFIG_NODE, &bgp_snmp_traps_bgp4_mibv2_cmd);

SET_FLAG(bgp_snmp_traps_flags,
BGP_SNMP_TRAPS_RFC4273_ENABLED);
SET_FLAG(bgp_snmp_traps_flags,
BGP_SNMP_TRAPS_RFC4273_ENABLED);
BGP_SNMP_TRAPS_BGP4MIBV2_ENABLED);
}

int bgp_cli_snmp_traps_config_write(struct vty *vty)
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_snmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
extern uint32_t bgp_snmp_traps_flags;

#define BGP_SNMP_TRAPS_RFC4273_ENABLED (1 << 0)
#define BGP_SNMP_TRAPS_BGP4MIBV2_ENABLED (1 << 1)

#endif /* _FRR_BGP_SNMP_H_ */
2 changes: 1 addition & 1 deletion bgpd/bgp_snmp_bgp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ int bgpTrapEstablished(struct peer *peer)
if (!CHECK_FLAG(bgp_snmp_traps_flags,
BGP_SNMP_TRAPS_RFC4273_ENABLED))
return 0;

/* Check if this peer just went to Established */
if ((peer->connection->ostatus != OpenConfirm) ||
!(peer_established(peer)))
Expand Down
8 changes: 8 additions & 0 deletions bgpd/bgp_snmp_bgp4v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,10 @@ int bgpv2TrapEstablished(struct peer *peer)
oid index[sizeof(oid) * IN6_ADDR_SIZE];
size_t length;

if (!CHECK_FLAG(bgp_snmp_traps_flags,
BGP_SNMP_TRAPS_BGP4MIBV2_ENABLED))
return 0;

/* Check if this peer just went to Established */
if ((peer->connection->ostatus != OpenConfirm) ||
!(peer_established(peer)))
Expand Down Expand Up @@ -1472,6 +1476,10 @@ int bgpv2TrapBackwardTransition(struct peer *peer)
oid index[sizeof(oid) * IN6_ADDR_SIZE];
size_t length;

if (!CHECK_FLAG(bgp_snmp_traps_flags,
BGP_SNMP_TRAPS_BGP4MIBV2_ENABLED))
return 0;

switch (sockunion_family(&peer->su)) {
case AF_INET:
oid_copy_in_addr(index, &peer->su.sin.sin_addr);
Expand Down

0 comments on commit f83618e

Please sign in to comment.