Skip to content

Commit

Permalink
Merge pull request #16420 from pguibert6WIND/trap_rfc4382
Browse files Browse the repository at this point in the history
bgpd: add bgp snmp traps rfc4382 command
  • Loading branch information
ton31337 authored Aug 12, 2024
2 parents 263eb6d + d95f9a3 commit 8c936d4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bgpd/bgp_mplsvpn_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ static int bgp_vrf_check_update_active(struct bgp *bgp, struct interface *ifp)
/* add trap in here */
bgp->snmp_stats->active = new_active;

if (!CHECK_FLAG(bm->options, BGP_OPT_TRAPS_RFC4382)) {
bgp_mpls_l3vpn_update_last_changed(bgp);
return 0;
}

/* send relevent trap */
if (bgp->snmp_stats->active)
trap = MPLSL3VPNVRFUP;
Expand Down
22 changes: 22 additions & 0 deletions bgpd/bgp_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ DEFPY(bgp_snmp_traps_rfc4273, bgp_snmp_traps_rfc4273_cmd,
return CMD_SUCCESS;
}

DEFPY(bgp_snmp_traps_rfc4382, bgp_snmp_traps_rfc4382_cmd,
"[no$no] bgp snmp traps rfc4382",
NO_STR BGP_STR
"Configure BGP SNMP\n"
"Configure SNMP traps for BGP\n"
"Configure use of rfc4382 SNMP traps for BGP\n")
{
if (no) {
UNSET_FLAG(bm->options, BGP_OPT_TRAPS_RFC4382);
return CMD_SUCCESS;
}
SET_FLAG(bm->options, BGP_OPT_TRAPS_RFC4382);
return CMD_SUCCESS;
}

DEFPY(bgp_snmp_traps_bgp4_mibv2, bgp_snmp_traps_bgp4_mibv2_cmd,
"[no$no] bgp snmp traps bgp4-mibv2",
NO_STR BGP_STR
Expand All @@ -69,9 +84,12 @@ 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);
install_element(CONFIG_NODE, &bgp_snmp_traps_rfc4382_cmd);

SET_FLAG(bm->options, BGP_OPT_TRAPS_RFC4273);
/* BGP4MIBv2 traps are disabled by default */

SET_FLAG(bm->options, BGP_OPT_TRAPS_RFC4382);
}

int bgp_cli_snmp_traps_config_write(struct vty *vty)
Expand All @@ -86,6 +104,10 @@ int bgp_cli_snmp_traps_config_write(struct vty *vty)
vty_out(vty, "bgp snmp traps bgp4-mibv2\n");
write++;
}
if (!CHECK_FLAG(bm->options, BGP_OPT_TRAPS_RFC4382)) {
vty_out(vty, "no bgp snmp traps rfc4382\n");
write++;
}

return write;
}
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ struct bgp_master {
#define BGP_OPT_NO_ZEBRA (1 << 2)
#define BGP_OPT_TRAPS_RFC4273 (1 << 3)
#define BGP_OPT_TRAPS_BGP4MIBV2 (1 << 4)
#define BGP_OPT_TRAPS_RFC4382 (1 << 5)

uint64_t updgrp_idspace;
uint64_t subgrp_idspace;
Expand Down
6 changes: 6 additions & 0 deletions doc/user/snmptrap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,9 @@ possibility to select the MIB he wants to receive traps from:
By default, only rfc4273 traps are enabled and sent.
.. [Draft-IETF-idr-bgp4-mibv2-11] <https://tools.ietf.org/id/draft-ietf-idr-bgp4-mibv2-11.txt>
The :rfc:`4382` also defines traps to inform when an L3VPN network changes
the operational status of its VRF interface. The user can choose to suppress
those traps or not.
.. clicmd:: bgp snmp traps rfc4382

0 comments on commit 8c936d4

Please sign in to comment.