diff options
| author | Louis Scalbert <louis.scalbert@6wind.com> | 2021-06-30 15:18:50 +0200 | 
|---|---|---|
| committer | Louis Scalbert <louis.scalbert@6wind.com> | 2021-09-21 19:00:38 +0200 | 
| commit | a30494760f1f994f54b971231733eaba928c6246 (patch) | |
| tree | 06db8f64ab008991f403010bf8ebbd42f344529a | |
| parent | 436a55a1d5cd0722b4f6e9bc0c9f9ce20e4e0dac (diff) | |
ospf6d: factorize router-id update
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>
| -rw-r--r-- | ospf6d/ospf6_top.c | 40 | ||||
| -rw-r--r-- | ospf6d/ospf6_top.h | 2 | 
2 files changed, 13 insertions, 29 deletions
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index a81cdef407..8ef2f93011 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -622,14 +622,14 @@ void ospf6_maxage_remove(struct ospf6 *o)  				 &o->maxage_remover);  } -void ospf6_router_id_update(struct ospf6 *ospf6, bool init) +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)  		new_router_id = ospf6->router_id_static; @@ -637,19 +637,20 @@ void ospf6_router_id_update(struct ospf6 *ospf6, bool init)  		new_router_id = ospf6->router_id_zebra;  	if (ospf6->router_id == new_router_id) -		return; +		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. Save config and restart ospf6d\n", +					"%s: cannot update router-id. Run the \"clear ipv6 ospf6 process\" command\n",  					__func__); -				return; +				return false;  			}  		}  	ospf6->router_id = new_router_id; +	return true;  }  /* start ospf6 */ @@ -786,8 +787,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; @@ -800,15 +799,9 @@ 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, vty) +		vty_out(vty, +			"For this router-id change to take effect run the \"clear ipv6 ospf6 process\" command\n");  	return CMD_SUCCESS;  } @@ -821,21 +814,12 @@ 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, vty) +		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 1bb6afc517..aa52f1bfb9 100644 --- a/ospf6d/ospf6_top.h +++ b/ospf6d/ospf6_top.h @@ -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, bool init); +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);  | 
