mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 05:23:59 +00:00
bgpd: rfapi - open rfd for vrf groups on export config,
keep open until group deleted Signed-off-by: Lou Berger <lberger@labn.net>
This commit is contained in:
parent
02a82b47b3
commit
9d6a46aa1e
@ -1459,9 +1459,11 @@ DEFUN (vnc_export_nvegroup,
|
||||
|
||||
rfg_new = bgp_rfapi_cfg_match_byname(bgp, argv[5]->arg,
|
||||
RFAPI_GROUP_CFG_NVE);
|
||||
if (rfg_new == NULL)
|
||||
if (rfg_new == NULL) {
|
||||
rfg_new = bgp_rfapi_cfg_match_byname(bgp, argv[5]->arg,
|
||||
RFAPI_GROUP_CFG_VRF);
|
||||
vnc_add_vrf_opener(bgp, rfg_new);
|
||||
}
|
||||
|
||||
if (rfg_new == NULL) {
|
||||
vty_out(vty, "Can't group named \"%s\".\n", argv[5]->arg);
|
||||
@ -2432,8 +2434,7 @@ bgp_rfapi_delete_named_nve_group(struct vty *vty, /* NULL = no output */
|
||||
*/
|
||||
for (ALL_LIST_ELEMENTS_RO(bgp->rfapi_cfg->rfg_export_direct_bgp_l, node,
|
||||
rfgn)) {
|
||||
if (rfg_name == NULL || (type == RFAPI_GROUP_CFG_NVE
|
||||
&& !strcmp(rfgn->name, rfg_name))) {
|
||||
if (rfgn->rfg == rfg) {
|
||||
rfgn->rfg = NULL;
|
||||
/* remove exported routes from this group */
|
||||
vnc_direct_bgp_del_group(bgp, rfg);
|
||||
@ -2446,21 +2447,25 @@ bgp_rfapi_delete_named_nve_group(struct vty *vty, /* NULL = no output */
|
||||
*/
|
||||
for (ALL_LIST_ELEMENTS_RO(bgp->rfapi_cfg->rfg_export_zebra_l, node,
|
||||
rfgn)) {
|
||||
|
||||
if (rfg_name == NULL || (type == RFAPI_GROUP_CFG_NVE
|
||||
&& !strcmp(rfgn->name, rfg_name))) {
|
||||
if (rfgn->rfg == rfg) {
|
||||
rfgn->rfg = NULL;
|
||||
/* remove exported routes from this group */
|
||||
vnc_zebra_del_group(bgp, rfg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rfg)
|
||||
if (rfg) {
|
||||
if (rfg->rfd)
|
||||
clear_vnc_vrf_closer(rfg);
|
||||
bgp_rfapi_delete_nve_group(vty, bgp, rfg);
|
||||
}
|
||||
else /* must be delete all */
|
||||
for (ALL_LIST_ELEMENTS(bgp->rfapi_cfg->nve_groups_sequential,
|
||||
node, nnode, rfg))
|
||||
node, nnode, rfg)) {
|
||||
if (rfg->rfd)
|
||||
clear_vnc_vrf_closer(rfg);
|
||||
bgp_rfapi_delete_nve_group(vty, bgp, rfg);
|
||||
}
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -345,6 +345,7 @@ extern void rfapi_un_options_free(struct rfapi_un_option *goner);
|
||||
|
||||
extern void rfapi_vn_options_free(struct rfapi_vn_option *goner);
|
||||
|
||||
extern void vnc_add_vrf_opener(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg);
|
||||
extern void clear_vnc_vrf_closer(struct rfapi_nve_group_cfg *rfg);
|
||||
/*------------------------------------------
|
||||
* rfapi_extract_l2o
|
||||
|
@ -4632,6 +4632,35 @@ notcfg:
|
||||
* add [vrf <vrf-name>] prefix <prefix>
|
||||
* [rd <value>] [label <value>] [local-preference <0-4294967295>]
|
||||
************************************************************************/
|
||||
void vnc_add_vrf_opener(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg)
|
||||
{
|
||||
if (rfg->rfd == NULL) /* need new rfapi_handle */
|
||||
{
|
||||
/* based on rfapi_open */
|
||||
struct rfapi_descriptor *rfd;
|
||||
rfd = XCALLOC(MTYPE_RFAPI_DESC,
|
||||
sizeof(struct rfapi_descriptor));
|
||||
rfd->bgp = bgp;
|
||||
rfg->rfd = rfd;
|
||||
/* leave most fields empty as will get from (dynamic) config
|
||||
* when needed */
|
||||
rfd->default_tunneltype_option.type = BGP_ENCAP_TYPE_MPLS;
|
||||
rfd->cookie = rfg;
|
||||
if (rfg->vn_prefix.family
|
||||
&& !CHECK_FLAG(rfg->flags, RFAPI_RFG_VPN_NH_SELF)) {
|
||||
rfapiQprefix2Raddr(&rfg->vn_prefix, &rfd->vn_addr);
|
||||
} else {
|
||||
memset(&rfd->vn_addr, 0, sizeof(struct rfapi_ip_addr));
|
||||
rfd->vn_addr.addr_family = AF_INET;
|
||||
rfd->vn_addr.addr.v4 = bgp->router_id;
|
||||
}
|
||||
rfd->un_addr = rfd->vn_addr; /* sigh, need something in UN for
|
||||
lookups */
|
||||
vnc_zlog_debug_verbose("%s: Opening RFD for VRF %s", __func__,
|
||||
rfg->name);
|
||||
rfapi_init_and_open(bgp, rfd, rfg);
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: this functions parallels vnc_direct_add_rn_group_rd */
|
||||
static int vnc_add_vrf_prefix(struct vty *vty, const char *arg_vrf,
|
||||
@ -4725,32 +4754,7 @@ static int vnc_add_vrf_prefix(struct vty *vty, const char *arg_vrf,
|
||||
}
|
||||
}
|
||||
rpfx.cost = 255 - (pref & 255);
|
||||
if (rfg->rfd == NULL) /* need new rfapi_handle */
|
||||
{
|
||||
/* based on rfapi_open */
|
||||
struct rfapi_descriptor *rfd;
|
||||
rfd = XCALLOC(MTYPE_RFAPI_DESC,
|
||||
sizeof(struct rfapi_descriptor));
|
||||
rfd->bgp = bgp;
|
||||
rfg->rfd = rfd;
|
||||
/* leave most fields empty as will get from (dynamic) config
|
||||
* when needed */
|
||||
rfd->default_tunneltype_option.type = BGP_ENCAP_TYPE_MPLS;
|
||||
rfd->cookie = rfg;
|
||||
if (rfg->vn_prefix.family
|
||||
&& !CHECK_FLAG(rfg->flags, RFAPI_RFG_VPN_NH_SELF)) {
|
||||
rfapiQprefix2Raddr(&rfg->vn_prefix, &rfd->vn_addr);
|
||||
} else {
|
||||
memset(&rfd->vn_addr, 0, sizeof(struct rfapi_ip_addr));
|
||||
rfd->vn_addr.addr_family = AF_INET;
|
||||
rfd->vn_addr.addr.v4 = bgp->router_id;
|
||||
}
|
||||
rfd->un_addr = rfd->vn_addr; /* sigh, need something in UN for
|
||||
lookups */
|
||||
vnc_zlog_debug_verbose("%s: Opening RFD for VRF %s", __func__,
|
||||
rfg->name);
|
||||
rfapi_init_and_open(bgp, rfd, rfg);
|
||||
}
|
||||
vnc_add_vrf_opener(bgp, rfg);
|
||||
|
||||
if (!rfapi_register(rfg->rfd, &rpfx, RFAPI_INFINITE_LIFETIME, NULL,
|
||||
(cur_opt ? optary : NULL), RFAPI_REGISTER_ADD)) {
|
||||
@ -4907,7 +4911,6 @@ static int vnc_clear_vrf(struct vty *vty, struct bgp *bgp, const char *arg_vrf,
|
||||
|
||||
start_count = rfapi_cfg_group_it_count(rfg);
|
||||
clear_vnc_prefix(&cda);
|
||||
clear_vnc_vrf_closer(rfg);
|
||||
vty_out(vty, "Cleared %u out of %d prefixes.\n", cda.pfx_count,
|
||||
start_count);
|
||||
return CMD_SUCCESS;
|
||||
|
@ -1367,9 +1367,6 @@ static void vnc_direct_del_rn_group_rd(struct bgp *bgp,
|
||||
NULL, /* RD not used for unicast */
|
||||
NULL,
|
||||
NULL); /* tag not used for unicast */
|
||||
if (rfg->type == RFAPI_GROUP_CFG_VRF) {
|
||||
clear_vnc_vrf_closer(rfg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user