From 75750ccfce46b1cff072427a4f8ee94e5c95a885 Mon Sep 17 00:00:00 2001 From: Emanuele Di Pascale Date: Fri, 3 Jul 2020 16:55:28 +0200 Subject: isisd: gracefully handle spf error the code in isis_spf_add2tent was asserting in case the vertex we were trying to add was already present in the path or tent trees. This however CAN happen if the user accidentally configures the system Id of the area to the same value of an estabished neighbor. Handle this more gracefully by logging and returning, to prevent crashes. Signed-off-by: Emanuele Di Pascale --- isisd/isis_spf.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index daf97859f..dfcea9a92 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -373,12 +373,25 @@ static struct isis_vertex *isis_spf_add2tent(struct isis_spftree *spftree, struct isis_vertex *vertex; struct listnode *node; struct isis_adjacency *parent_adj; -#ifdef EXTREME_DEBUG char buff[VID2STR_BUFFER]; -#endif - assert(isis_find_vertex(&spftree->paths, id, vtype) == NULL); - assert(isis_find_vertex(&spftree->tents, id, vtype) == NULL); + vertex = isis_find_vertex(&spftree->paths, id, vtype); + if (vertex != NULL) { + zlog_err( + "%s: vertex %s of type %s already in PATH; check for sysId collisions with established neighbors", + __func__, vid2string(vertex, buff, sizeof(buff)), + vtype2string(vertex->type)); + return NULL; + } + vertex = isis_find_vertex(&spftree->tents, id, vtype); + if (vertex != NULL) { + zlog_err( + "%s: vertex %s of type %s already in TENT; check for sysId collisions with established neighbors", + __func__, vid2string(vertex, buff, sizeof(buff)), + vtype2string(vertex->type)); + return NULL; + } + vertex = isis_vertex_new(spftree, id, vtype); vertex->d_N = cost; vertex->depth = depth; -- cgit v1.2.3