From 26fc23661cd36ff67c939287d5b27d8e6cbf089f Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Wed, 14 Oct 2020 02:39:08 +0300 Subject: [PATCH] ospfd: remove all "ip ospf area" params when clearing instance Currently, only default area parameter is cleared, but we should do the same for all area parameters with interface addresses. Signed-off-by: Igor Ryzhov --- ospfd/ospf_vty.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 53e8260621..83ad474f41 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -8021,6 +8021,7 @@ DEFUN (ip_ospf_area, struct ospf *ospf = NULL; unsigned short instance = 0; char *areaid; + uint32_t count = 0; if (argv_find(argv, argc, "(1-65535)", &idx)) instance = strtol(argv[idx]->arg, NULL, 10); @@ -8045,15 +8046,28 @@ DEFUN (ip_ospf_area, * allow the other instance(process) handle * the configuration command. */ + count = 0; + params = IF_DEF_PARAMS(ifp); if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) { UNSET_IF_PARAM(params, if_area); - ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); + count++; + } + + for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn)) + if ((params = rn->info) && OSPF_IF_PARAM_CONFIGURED(params, if_area)) { + UNSET_IF_PARAM(params, if_area); + count++; + } + + if (count > 0) { + ospf = ospf_lookup_by_vrf_id(ifp->vrf_id); if (ospf) { ospf_interface_area_unset(ospf, ifp); - ospf->if_ospf_cli_count--; + ospf->if_ospf_cli_count -= count; } } + return CMD_NOT_MY_INSTANCE; } -- 2.39.5