]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: add a hook to inform a vrf is enabled/disabled
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 29 Oct 2019 16:52:52 +0000 (17:52 +0100)
committerLouis Scalbert <louis.scalbert@6wind.com>
Thu, 18 Jan 2024 12:22:17 +0000 (13:22 +0100)
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 <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
bgpd/bgp_main.c
bgpd/bgpd.h

index e8d5a0307a9a13cfe9384f9213d3887d75db0f34..739fab7ddddfb3d6f59a3633a691d86e174a4f98 100644 (file)
@@ -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. */
index 4c12872ee9e0f345d05931b1781772c6caa73800..73a909f98f4b3b73eea4f2ae878fbdd470daced2 100644 (file)
@@ -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 {