From b9d64870c10924200e259dac97a5690f89e25cf7 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 29 Oct 2019 17:52:52 +0100 Subject: [PATCH] bgpd: add a hook to inform a vrf is enabled/disabled Add a hook to call a future callback function when bgpd knows from zebra about the activation of de-activation of a VRF. It will be used by the RPKI module in next commits. Signed-off-by: Philippe Guibert Signed-off-by: Louis Scalbert --- bgpd/bgp_main.c | 5 +++++ bgpd/bgpd.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index e8d5a0307a..739fab7ddd 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -55,6 +55,9 @@ #include "bgpd/rfapi/rfapi_backend.h" #endif +DEFINE_HOOK(bgp_hook_vrf_update, (struct vrf *vrf, bool enabled), + (vrf, enabled)); + /* bgpd options, we use GNU getopt library. */ static const struct option longopts[] = { { "bgp_port", required_argument, NULL, 'p' }, @@ -287,6 +290,7 @@ static int bgp_vrf_enable(struct vrf *vrf) bgp_handle_socket(bgp, vrf, old_vrf_id, true); bgp_instance_up(bgp); + hook_call(bgp_hook_vrf_update, vrf, true); vpn_leak_zebra_vrf_label_update(bgp, AFI_IP); vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6); vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP); @@ -333,6 +337,7 @@ static int bgp_vrf_disable(struct vrf *vrf) * "down". */ bgp_instance_down(bgp); bgp_vrf_unlink(bgp, vrf); + hook_call(bgp_hook_vrf_update, vrf, false); } /* Note: This is a callback, the VRF will be deleted by the caller. */ diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 4c12872ee9..73a909f98f 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -839,6 +839,8 @@ DECLARE_HOOK(bgp_inst_config_write, (bgp, vty)); DECLARE_HOOK(bgp_snmp_traps_config_write, (struct vty *vty), (vty)); DECLARE_HOOK(bgp_config_end, (struct bgp *bgp), (bgp)); +DECLARE_HOOK(bgp_hook_vrf_update, (struct vrf *vrf, bool enabled), + (vrf, enabled)); /* Thread callback information */ struct afi_safi_info { -- 2.39.5