mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-11-03 04:28:24 +00:00
ripngd: change vrf name with bypassing nb api
ripngd operational & config data may already applied and available, while an external event requests for changing the vrf name. this change updates the config and operational context of yang. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
d487770793
commit
be2bad2edb
@ -2777,7 +2777,43 @@ static int ripng_vrf_enable(struct vrf *vrf)
|
||||
int socket;
|
||||
|
||||
ripng = ripng_lookup_by_vrf_name(vrf->name);
|
||||
if (!ripng || ripng->enabled)
|
||||
if (!ripng) {
|
||||
char *old_vrf_name = NULL;
|
||||
|
||||
ripng = (struct ripng *)vrf->info;
|
||||
if (!ripng)
|
||||
return 0;
|
||||
/* update vrf name */
|
||||
if (ripng->vrf_name)
|
||||
old_vrf_name = ripng->vrf_name;
|
||||
ripng->vrf_name = XSTRDUP(MTYPE_RIPNG_VRF_NAME, vrf->name);
|
||||
/*
|
||||
* HACK: Change the RIPng VRF in the running configuration directly,
|
||||
* bypassing the northbound layer. This is necessary to avoid deleting
|
||||
* the RIPng and readding it in the new VRF, which would have
|
||||
* several implications.
|
||||
*/
|
||||
if (yang_module_find("frr-ripngd") && old_vrf_name) {
|
||||
struct lyd_node *ripng_dnode;
|
||||
|
||||
pthread_rwlock_wrlock(&running_config->lock);
|
||||
{
|
||||
ripng_dnode = yang_dnode_get(
|
||||
running_config->dnode,
|
||||
"/frr-ripngd:ripngd/instance[vrf='%s']/vrf",
|
||||
old_vrf_name);
|
||||
if (ripng_dnode) {
|
||||
yang_dnode_change_leaf(ripng_dnode, vrf->name);
|
||||
running_config->version++;
|
||||
}
|
||||
}
|
||||
pthread_rwlock_unlock(&running_config->lock);
|
||||
}
|
||||
if (old_vrf_name)
|
||||
XFREE(MTYPE_RIPNG_VRF_NAME, old_vrf_name);
|
||||
}
|
||||
|
||||
if (ripng->enabled)
|
||||
return 0;
|
||||
|
||||
if (IS_RIPNG_DEBUG_EVENT)
|
||||
@ -2785,13 +2821,11 @@ static int ripng_vrf_enable(struct vrf *vrf)
|
||||
vrf->vrf_id);
|
||||
|
||||
/* Activate the VRF RIPng instance. */
|
||||
if (!ripng->enabled) {
|
||||
socket = ripng_make_socket(vrf);
|
||||
if (socket < 0)
|
||||
return -1;
|
||||
socket = ripng_make_socket(vrf);
|
||||
if (socket < 0)
|
||||
return -1;
|
||||
|
||||
ripng_instance_enable(ripng, vrf, socket);
|
||||
}
|
||||
ripng_instance_enable(ripng, vrf, socket);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user