summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2023-12-21 11:04:01 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2024-01-18 13:22:18 +0100
commita3bd9bad3765b32b1828c9c7ca7e24800691288c (patch)
tree25c346cd242af2a610cac40370c49b9a63450c1e /bgpd
parentbgpd: add a hook to inform a vrf is enabled/disabled (diff)
downloadfrr-a3bd9bad3765b32b1828c9c7ca7e24800691288c.tar.xz
frr-a3bd9bad3765b32b1828c9c7ca7e24800691288c.zip
bgpd: start or stop rpki at vrf creation or deletion
Start or stop a RPKI cache servers in VRF when they are created or deleted. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_rpki.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index 8e1b5c130..458677b8a 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -105,6 +105,8 @@ struct rpki_vrf {
QOBJ_FIELDS;
};
+static struct rpki_vrf *find_rpki_vrf(const char *vrfname);
+static int bgp_rpki_vrf_update(struct vrf *vrf, bool enabled);
static int bgp_rpki_write_debug(struct vty *vty, bool running);
static int start(struct rpki_vrf *rpki_vrf);
static void stop(struct rpki_vrf *rpki_vrf);
@@ -267,6 +269,24 @@ static struct rtr_socket *create_rtr_socket(struct tr_socket *tr_socket)
return rtr_socket;
}
+static int bgp_rpki_vrf_update(struct vrf *vrf, bool enabled)
+{
+ struct rpki_vrf *rpki;
+
+ if (vrf->vrf_id == VRF_DEFAULT)
+ rpki = find_rpki_vrf(NULL);
+ else
+ rpki = find_rpki_vrf(vrf->name);
+ if (!rpki)
+ return 0;
+
+ if (enabled)
+ start(rpki);
+ else
+ stop(rpki);
+ return 1;
+}
+
static struct rpki_vrf *find_rpki_vrf(const char *vrfname)
{
struct listnode *rpki_vrf_nnode;
@@ -711,6 +731,7 @@ static int bgp_rpki_module_init(void)
hook_register(frr_late_init, bgp_rpki_init);
hook_register(frr_early_fini, bgp_rpki_fini);
hook_register(bgp_hook_config_write_debug, &bgp_rpki_write_debug);
+ hook_register(bgp_hook_vrf_update, &bgp_rpki_vrf_update);
return 0;
}
@@ -735,6 +756,7 @@ static void sync_expired(struct event *thread)
static int start(struct rpki_vrf *rpki_vrf)
{
struct list *cache_list = NULL;
+ struct vrf *vrf;
int ret;
rpki_vrf->rtr_is_stopping = false;
@@ -748,6 +770,16 @@ static int start(struct rpki_vrf *rpki_vrf)
"No caches were found in config. Prefix validation is off.");
return ERROR;
}
+
+ if (rpki_vrf->vrfname)
+ vrf = vrf_lookup_by_name(rpki_vrf->vrfname);
+ else
+ vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ if (!vrf || !CHECK_FLAG(vrf->status, VRF_ACTIVE)) {
+ RPKI_DEBUG("VRF %s not present or disabled", rpki_vrf->vrfname);
+ return ERROR;
+ }
+
RPKI_DEBUG("Init rtr_mgr.");
int groups_len = listcount(cache_list);
struct rtr_mgr_group *groups = get_groups(rpki_vrf->cache_list);