summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-09-23 19:03:35 +0300
committerGitHub <noreply@github.com>2021-09-23 19:03:35 +0300
commitd5cd3fd1e0b4398c8f40c7f7241be8bacd5b6927 (patch)
tree05e07791c707ad493db3217c8d3b29f0fa2d2077
parent4ab65e0983d10b168c3657f253a5935488ac1d1c (diff)
parent078f6092127102c683a25d58d2c64bb7cfa38247 (diff)
Merge pull request #9084 from louis-oui/fix-ospf6-router-id
ospf6d: fix LSAs remain in LSDB with an old router-id value
-rw-r--r--ospf6d/ospf6_top.c74
-rw-r--r--ospf6d/ospf6_top.h2
-rw-r--r--ospf6d/ospf6_zebra.c2
3 files changed, 43 insertions, 35 deletions
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index 3122d616cb..894ebc7681 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -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);
@@ -630,15 +630,35 @@ void ospf6_maxage_remove(struct ospf6 *o)
&o->maxage_remover);
}
-void ospf6_router_id_update(struct ospf6 *ospf6)
+bool 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;
+ return true;
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 true;
+
+ if (!init)
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
+ if (oa->full_nbrs) {
+ zlog_err(
+ "%s: cannot update router-id. Run the \"clear ipv6 ospf6 process\" command\n",
+ __func__);
+ return false;
+ }
+ }
+
+ ospf6->router_id = new_router_id;
+ return true;
}
/* start ospf6 */
@@ -731,8 +751,6 @@ static void ospf6_process_reset(struct ospf6 *ospf6)
ospf6->inst_shutdown = 0;
ospf6_db_clear(ospf6);
- ospf6_router_id_update(ospf6);
-
ospf6_asbr_redistribute_reset(ospf6);
FOR_ALL_INTERFACES (vrf, ifp)
ospf6_interface_clear(ifp);
@@ -754,10 +772,12 @@ DEFPY (clear_router_ospf6,
vrf_name = name;
ospf6 = ospf6_lookup_by_vrf_name(vrf_name);
- if (ospf6 == NULL)
+ if (ospf6 == NULL) {
vty_out(vty, "OSPFv3 is not configured\n");
- else
+ } else {
+ ospf6_router_id_update(ospf6, true);
ospf6_process_reset(ospf6);
+ }
return CMD_SUCCESS;
}
@@ -775,8 +795,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;
@@ -789,15 +807,11 @@ 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;
+ if (ospf6_router_id_update(o, false))
+ ospf6_process_reset(o);
+ else
+ vty_out(vty,
+ "For this router-id change to take effect run the \"clear ipv6 ospf6 process\" command\n");
return CMD_SUCCESS;
}
@@ -810,21 +824,15 @@ 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;
+
+ if (ospf6_router_id_update(o, false))
+ ospf6_process_reset(o);
+ else
+ vty_out(vty,
+ "For this router-id change to take effect run the \"clear ipv6 ospf6 process\" command\n");
return CMD_SUCCESS;
}
diff --git a/ospf6d/ospf6_top.h b/ospf6d/ospf6_top.h
index 3188b1f58f..9a0b1279ce 100644
--- a/ospf6d/ospf6_top.h
+++ b/ospf6d/ospf6_top.h
@@ -239,7 +239,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 bool 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);
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index c2e91d09bb..a6929b32c4 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -102,7 +102,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;
}