mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 18:37:06 +00:00
bgpd: add instance delete & config write hooks
Both of these hooks are necessary for proper operation of extensions that need to latch on to a particular instance. - without the delete hook, it's impossible to get rid of stale references, leading to crashes with invalid instance pointers. - the config-write hook is necessary because per-instance config needs to be written inside the "router bgp" block to have the appropriate context; adding a separate config node can't do that. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
2ed9fe4a2b
commit
2b9bcf306d
@ -94,6 +94,10 @@ DEFINE_MTYPE_STATIC(BGPD, BGP_EVPN_INFO, "BGP EVPN instance information");
|
|||||||
DEFINE_QOBJ_TYPE(bgp_master)
|
DEFINE_QOBJ_TYPE(bgp_master)
|
||||||
DEFINE_QOBJ_TYPE(bgp)
|
DEFINE_QOBJ_TYPE(bgp)
|
||||||
DEFINE_QOBJ_TYPE(peer)
|
DEFINE_QOBJ_TYPE(peer)
|
||||||
|
DEFINE_HOOK(bgp_inst_delete, (struct bgp *bgp), (bgp))
|
||||||
|
DEFINE_HOOK(bgp_inst_config_write,
|
||||||
|
(struct bgp *bgp, struct vty *vty),
|
||||||
|
(bgp, vty))
|
||||||
|
|
||||||
/* BGP process wide configuration. */
|
/* BGP process wide configuration. */
|
||||||
static struct bgp_master bgp_master;
|
static struct bgp_master bgp_master;
|
||||||
@ -3286,6 +3290,9 @@ int bgp_delete(struct bgp *bgp)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(bgp);
|
assert(bgp);
|
||||||
|
|
||||||
|
hook_call(bgp_inst_delete, bgp);
|
||||||
|
|
||||||
THREAD_OFF(bgp->t_startup);
|
THREAD_OFF(bgp->t_startup);
|
||||||
THREAD_OFF(bgp->t_maxmed_onstartup);
|
THREAD_OFF(bgp->t_maxmed_onstartup);
|
||||||
THREAD_OFF(bgp->t_update_delay);
|
THREAD_OFF(bgp->t_update_delay);
|
||||||
@ -7797,6 +7804,8 @@ int bgp_config_write(struct vty *vty)
|
|||||||
/* EVPN configuration. */
|
/* EVPN configuration. */
|
||||||
bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN);
|
bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN);
|
||||||
|
|
||||||
|
hook_call(bgp_inst_config_write, bgp, vty);
|
||||||
|
|
||||||
#if ENABLE_BGP_VNC
|
#if ENABLE_BGP_VNC
|
||||||
bgp_rfapi_cfg_write(vty, bgp);
|
bgp_rfapi_cfg_write(vty, bgp);
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "qobj.h"
|
#include "qobj.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "hook.h"
|
||||||
#include "frr_pthread.h"
|
#include "frr_pthread.h"
|
||||||
#include "lib/json.h"
|
#include "lib/json.h"
|
||||||
#include "vrf.h"
|
#include "vrf.h"
|
||||||
@ -572,6 +573,11 @@ struct bgp {
|
|||||||
};
|
};
|
||||||
DECLARE_QOBJ_TYPE(bgp)
|
DECLARE_QOBJ_TYPE(bgp)
|
||||||
|
|
||||||
|
DECLARE_HOOK(bgp_inst_delete, (struct bgp *bgp), (bgp))
|
||||||
|
DECLARE_HOOK(bgp_inst_config_write,
|
||||||
|
(struct bgp *bgp, struct vty *vty),
|
||||||
|
(bgp, vty))
|
||||||
|
|
||||||
#define BGP_ROUTE_ADV_HOLD(bgp) (bgp->main_peers_update_hold)
|
#define BGP_ROUTE_ADV_HOLD(bgp) (bgp->main_peers_update_hold)
|
||||||
|
|
||||||
#define IS_BGP_INST_KNOWN_TO_ZEBRA(bgp) \
|
#define IS_BGP_INST_KNOWN_TO_ZEBRA(bgp) \
|
||||||
|
Loading…
Reference in New Issue
Block a user