]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripngd/ripngd.c
*: make all route_map_rule_cmd const
[mirror_frr.git] / ripngd / ripngd.c
index 49f7dda646a9cac67282986bfab019e1fd7b0451..ad2ddd0dba8a2ace03f0ca269d234bd9c388209f 100644 (file)
@@ -2361,7 +2361,7 @@ DEFUN (show_ipv6_protocols,
     return CMD_SUCCESS;
 
   vty_out (vty, "Routing Protocol is \"ripng\"\n");
-  
+
   vty_out (vty, "Sending updates every %ld seconds, next due in %d seconds\n",
           ripng->update_time, 0);
 
@@ -2776,7 +2776,39 @@ 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;
+
+                       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++;
+                       }
+               }
+               if (old_vrf_name)
+                       XFREE(MTYPE_RIPNG_VRF_NAME, old_vrf_name);
+       }
+
+       if (ripng->enabled)
                return 0;
 
        if (IS_RIPNG_DEBUG_EVENT)
@@ -2784,13 +2816,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 +2847,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)