]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospf6d: don't update router-id if at least one adjacency is Full
authorLouis Scalbert <louis.scalbert@6wind.com>
Fri, 4 Jun 2021 12:22:06 +0000 (14:22 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Tue, 21 Sep 2021 17:00:38 +0000 (19:00 +0200)
When a router-id change is notified by zebra to ospf6d, we only take
into account the change if no adjacencies are in Full state.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
ospf6d/ospf6_top.c
ospf6d/ospf6_top.h
ospf6d/ospf6_zebra.c

index 6ff3789a804ac00bf126250c1f8734cb5f6c403b..a81cdef4074f2e21d86872d736e47ccd861f8485 100644 (file)
@@ -226,7 +226,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);
+                       ospf6_router_id_update(ospf6, true);
                }
        }
 
@@ -460,7 +460,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);
+               ospf6_router_id_update(ospf6, true);
        ospf6_add(ospf6);
        if (ospf6->vrf_id != VRF_UNKNOWN) {
                vrf = vrf_lookup_by_id(ospf6->vrf_id);
@@ -622,15 +622,34 @@ void ospf6_maxage_remove(struct ospf6 *o)
                                 &o->maxage_remover);
 }
 
-void ospf6_router_id_update(struct ospf6 *ospf6)
+void ospf6_router_id_update(struct ospf6 *ospf6, bool init)
 {
+       in_addr_t new_router_id;
+       struct listnode *node;
+       struct ospf6_area *oa;
+
        if (!ospf6)
                return;
 
        if (ospf6->router_id_static != 0)
-               ospf6->router_id = ospf6->router_id_static;
+               new_router_id = ospf6->router_id_static;
        else
-               ospf6->router_id = ospf6->router_id_zebra;
+               new_router_id = ospf6->router_id_zebra;
+
+       if (ospf6->router_id == new_router_id)
+               return;
+
+       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__);
+                               return;
+                       }
+               }
+
+       ospf6->router_id = new_router_id;
 }
 
 /* start ospf6 */
@@ -723,7 +742,7 @@ static void ospf6_process_reset(struct ospf6 *ospf6)
        ospf6->inst_shutdown = 0;
        ospf6_db_clear(ospf6);
 
-       ospf6_router_id_update(ospf6);
+       ospf6_router_id_update(ospf6, true);
 
        ospf6_asbr_redistribute_reset(ospf6);
        FOR_ALL_INTERFACES (vrf, ifp)
index 58ecf08495b9413ff9e36bb8b97b76587fae7a48..1bb6afc517beefe3b06310adceeca690e00bb4df 100644 (file)
@@ -227,7 +227,7 @@ 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);
+extern void ospf6_router_id_update(struct ospf6 *ospf6, bool init);
 
 extern void ospf6_maxage_remove(struct ospf6 *o);
 extern struct ospf6 *ospf6_instance_create(const char *name);
index 5403e643dc664b542d7ed1b13a71695355f576f0..f8bc890d690269145c836699eee47ce7c742c29c 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);
+       ospf6_router_id_update(o, false);
 
        return 0;
 }