]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospf6d: factorize router-id update
authorLouis Scalbert <louis.scalbert@6wind.com>
Wed, 30 Jun 2021 13:18:50 +0000 (15:18 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Thu, 1 Jul 2021 12:40:14 +0000 (14:40 +0200)
ospf6_router_id_update function is used by ospf6_router_id_update_zebra
to update the running the ospf6 router-id.

This patches makes the functions to (un)configure ospf6 router-id use
the same function as ospf6_router_id_update_zebra.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
---

ospf6d/ospf6_top.c
ospf6d/ospf6_top.h
ospf6d/ospf6_zebra.c

index e0984902855619fa06b204406662ae87d6053948..f18eea21292a93e06ad1af858b9e36c269d924b4 100644 (file)
@@ -225,7 +225,7 @@ static int ospf6_vrf_enable(struct vrf *vrf)
                        thread_add_read(master, ospf6_receive, ospf6, ospf6->fd,
                                        &ospf6->t_ospf6_receive);
 
-                       ospf6_router_id_update(ospf6, true);
+                       ospf6_router_id_update(ospf6, true, NULL);
                }
        }
 
@@ -440,7 +440,7 @@ struct ospf6 *ospf6_instance_create(const char *name)
        if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES)
                SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
        if (ospf6->router_id == 0)
-               ospf6_router_id_update(ospf6, true);
+               ospf6_router_id_update(ospf6, true, NULL);
        ospf6_add(ospf6);
        if (ospf6->vrf_id != VRF_UNKNOWN) {
                vrf = vrf_lookup_by_id(ospf6->vrf_id);
@@ -594,7 +594,7 @@ void ospf6_maxage_remove(struct ospf6 *o)
                                 &o->maxage_remover);
 }
 
-void ospf6_router_id_update(struct ospf6 *ospf6, bool init)
+void ospf6_router_id_update(struct ospf6 *ospf6, bool init, struct vty *vty)
 {
        in_addr_t new_router_id;
        struct listnode *node;
@@ -606,7 +606,7 @@ void ospf6_router_id_update(struct ospf6 *ospf6, bool init)
        if (ospf6->router_id_static != 0)
                new_router_id = ospf6->router_id_static;
        else
-               new_router_id = ospf6->zebra_router_id;
+               new_router_id = ospf6->router_id_zebra;
 
        if (ospf6->router_id == new_router_id)
                return;
@@ -614,9 +614,15 @@ void ospf6_router_id_update(struct ospf6 *ospf6, bool init)
        if (!init)
                for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
                        if (oa->full_nbrs) {
-                               zlog_err(
-                                       "%s: cannot update router-id. Save config and restart ospf6d\n",
-                                       __func__);
+                               if (vty)
+                                       vty_out(vty,
+                                               "For this router-id change to take effect,"
+                                               " run the \"clear ipv6 ospf6 process\" command\n");
+                               else
+                                       zlog_err(
+                                               "%s: cannot update router-id."
+                                               " Run the \"clear ipv6 ospf6 process\" command\n",
+                                               __func__);
                                return;
                        }
                }
@@ -713,7 +719,7 @@ static void ospf6_process_reset(struct ospf6 *ospf6)
        ospf6->inst_shutdown = 0;
        ospf6_db_clear(ospf6);
 
-       ospf6_router_id_update(ospf6, true);
+       ospf6_router_id_update(ospf6, true, NULL);
 
        ospf6_asbr_redistribute_reset(ospf6);
        FOR_ALL_INTERFACES (vrf, ifp)
@@ -757,8 +763,6 @@ DEFUN(ospf6_router_id,
        int ret;
        const char *router_id_str;
        uint32_t router_id;
-       struct ospf6_area *oa;
-       struct listnode *node;
 
        argv_find(argv, argc, "A.B.C.D", &idx);
        router_id_str = argv[idx]->arg;
@@ -771,15 +775,7 @@ DEFUN(ospf6_router_id,
 
        o->router_id_static = router_id;
 
-       for (ALL_LIST_ELEMENTS_RO(o->area_list, node, oa)) {
-               if (oa->full_nbrs) {
-                       vty_out(vty,
-                               "For this router-id change to take effect, run the \"clear ipv6 ospf6 process\" command\n");
-                       return CMD_SUCCESS;
-               }
-       }
-
-       o->router_id = router_id;
+       ospf6_router_id_update(o, false, vty);
 
        return CMD_SUCCESS;
 }
@@ -792,21 +788,10 @@ DEFUN(no_ospf6_router_id,
       V4NOTATION_STR)
 {
        VTY_DECLVAR_CONTEXT(ospf6, o);
-       struct ospf6_area *oa;
-       struct listnode *node;
 
        o->router_id_static = 0;
 
-       for (ALL_LIST_ELEMENTS_RO(o->area_list, node, oa)) {
-               if (oa->full_nbrs) {
-                       vty_out(vty,
-                               "For this router-id change to take effect, run the \"clear ipv6 ospf6 process\" command\n");
-                       return CMD_SUCCESS;
-               }
-       }
-       o->router_id = 0;
-       if (o->router_id_zebra)
-               o->router_id = o->router_id_zebra;
+       ospf6_router_id_update(o, false, vty);
 
        return CMD_SUCCESS;
 }
index aba5d645360b3bb91b568a8f3bebf1c75712895e..f58af459ba8a50c5e039efff87a0a801ea35becc 100644 (file)
@@ -175,7 +175,8 @@ extern void ospf6_master_init(struct thread_master *master);
 extern void install_element_ospf6_clear_process(void);
 extern void ospf6_top_init(void);
 extern void ospf6_delete(struct ospf6 *o);
-extern void ospf6_router_id_update(struct ospf6 *ospf6, bool init);
+extern void ospf6_router_id_update(struct ospf6 *ospf6, bool init,
+                                  struct vty *vty);
 
 extern void ospf6_maxage_remove(struct ospf6 *o);
 extern struct ospf6 *ospf6_instance_create(const char *name);
index 1c9541710edd2d08e0baf494b231d145fe5dd970..727e6f7fef22de410d9fac97725878cdbf623af5 100644 (file)
@@ -101,7 +101,7 @@ static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
 
        o->router_id_zebra = router_id.u.prefix4.s_addr;
 
-       ospf6_router_id_update(o, false);
+       ospf6_router_id_update(o, false, NULL);
 
        return 0;
 }