summaryrefslogtreecommitdiffstats
path: root/ripngd
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2019-09-17 13:22:22 +0200
committerGitHub <noreply@github.com>2019-09-17 13:22:22 +0200
commitfe8d933c2c778647b3fbb75340ea4f752c77137d (patch)
tree418607c7dda54119db93ddcb80f6cde524956a6b /ripngd
parentMerge pull request #4985 from qlyoung/fix-bgp-zero-keepalive-timer (diff)
parentripngd: change vrf name with bypassing nb api (diff)
downloadfrr-fe8d933c2c778647b3fbb75340ea4f752c77137d.tar.xz
frr-fe8d933c2c778647b3fbb75340ea4f752c77137d.zip
Merge pull request #4564 from pguibert6WIND/misc_vrf_update_name
Misc vrf update name
Diffstat (limited to 'ripngd')
-rw-r--r--ripngd/ripngd.c50
1 files changed, 42 insertions, 8 deletions
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 49f7dda64..120f46f0d 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -2776,7 +2776,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)
@@ -2784,13 +2820,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;
}
@@ -2817,7 +2851,7 @@ static int ripng_vrf_disable(struct vrf *vrf)
void ripng_vrf_init(void)
{
vrf_init(ripng_vrf_new, ripng_vrf_enable, ripng_vrf_disable,
- ripng_vrf_delete, NULL);
+ ripng_vrf_delete, ripng_vrf_enable);
}
void ripng_vrf_terminate(void)