From: Philippe Guibert Date: Tue, 27 Aug 2019 15:00:24 +0000 (+0200) Subject: ripd: change vrf name with bypassing nb api X-Git-Tag: base_7.3~353^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=d4877707934a4e68398cf20d59f3cfd0f03a3906;p=matthieu%2Ffrr.git ripd: change vrf name with bypassing nb api ripd 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 --- diff --git a/ripd/ripd.c b/ripd/ripd.c index f5d577abaf..c1c2824f2a 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3641,6 +3641,41 @@ static int rip_vrf_enable(struct vrf *vrf) int socket; rip = rip_lookup_by_vrf_name(vrf->name); + if (!rip) { + char *old_vrf_name = NULL; + + rip = (struct rip *)vrf->info; + if (!rip) + return 0; + /* update vrf name */ + if (rip->vrf_name) + old_vrf_name = rip->vrf_name; + rip->vrf_name = XSTRDUP(MTYPE_RIP_VRF_NAME, vrf->name); + /* + * HACK: Change the RIP VRF in the running configuration directly, + * bypassing the northbound layer. This is necessary to avoid deleting + * the RIP and readding it in the new VRF, which would have + * several implications. + */ + if (yang_module_find("frr-ripd") && old_vrf_name) { + struct lyd_node *rip_dnode; + + pthread_rwlock_wrlock(&running_config->lock); + { + rip_dnode = yang_dnode_get( + running_config->dnode, + "/frr-ripd:ripd/instance[vrf='%s']/vrf", + old_vrf_name); + if (rip_dnode) { + yang_dnode_change_leaf(rip_dnode, vrf->name); + running_config->version++; + } + } + pthread_rwlock_unlock(&running_config->lock); + } + if (old_vrf_name) + XFREE(MTYPE_RIP_VRF_NAME, old_vrf_name); + } if (!rip || rip->enabled) return 0;