From 4b220ad052547722eece0a4156d920152fe02661 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Fri, 4 Jun 2021 14:57:42 -0400 Subject: [PATCH 1/3] lib: add dtor for srv6 locator chunk list Add a delete function for the chunk list in an srv6 locator. Signed-off-by: Mark Stapp --- lib/srv6.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/srv6.c b/lib/srv6.c index ceb769ef76..ccb94b2f76 100644 --- a/lib/srv6.c +++ b/lib/srv6.c @@ -129,6 +129,8 @@ struct srv6_locator *srv6_locator_alloc(const char *name) locator = XCALLOC(MTYPE_SRV6_LOCATOR, sizeof(struct srv6_locator)); strlcpy(locator->name, name, sizeof(locator->name)); locator->chunks = list_new(); + locator->chunks->del = (void (*)(void *))srv6_locator_chunk_free; + QOBJ_REG(locator, srv6_locator); return locator; } @@ -144,7 +146,12 @@ struct srv6_locator_chunk *srv6_locator_chunk_alloc(void) void srv6_locator_free(struct srv6_locator *locator) { - XFREE(MTYPE_SRV6_LOCATOR, locator); + if (locator) { + QOBJ_UNREG(locator); + list_delete(&locator->chunks); + + XFREE(MTYPE_SRV6_LOCATOR, locator); + } } void srv6_locator_chunk_free(struct srv6_locator_chunk *chunk) From 16bd37d687f0b7a36044c217cefdbd357b09c896 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Mon, 7 Jun 2021 14:25:46 -0400 Subject: [PATCH 2/3] zebra: small srv6 text cleanup Couple of small typos in srv6 zapi code. Signed-off-by: Mark Stapp --- zebra/zapi_msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 06aaa706dc..d5969ab9bb 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -2848,7 +2848,7 @@ stream_failure: static void zread_table_manager_request(ZAPI_HANDLER_ARGS) { - /* to avoid sending other messages like ZERBA_INTERFACE_UP */ + /* to avoid sending other messages like ZEBRA_INTERFACE_UP */ if (hdr->command == ZEBRA_TABLE_MANAGER_CONNECT) zread_table_manager_connect(client, msg, zvrf_id(zvrf)); else { @@ -2856,7 +2856,7 @@ static void zread_table_manager_request(ZAPI_HANDLER_ARGS) if (!client->proto) { flog_err( EC_ZEBRA_TM_ALIENS, - "Got table request from an unidentified client"); + "Got SRv6 request from an unidentified client"); return; } if (hdr->command == ZEBRA_GET_TABLE_CHUNK) From f502d7af0f1d57d855cc67b3bb349226151c4b97 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Mon, 7 Jun 2021 14:26:25 -0400 Subject: [PATCH 3/3] zebra: srv6 cleanup Use NO_PROTO consistently in tests; make sure zapi client instance and session are used for srv6 'chunks'. Signed-off-by: Mark Stapp --- zebra/zebra_srv6.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_srv6.c b/zebra/zebra_srv6.c index 5664a29682..b11331a180 100644 --- a/zebra/zebra_srv6.c +++ b/zebra/zebra_srv6.c @@ -181,13 +181,13 @@ assign_srv6_locator_chunk(uint8_t proto, loc->status_up = false; chunk = srv6_locator_chunk_alloc(); - chunk->proto = 0; + chunk->proto = NO_PROTO; listnode_add(loc->chunks, chunk); zebra_srv6_locator_add(loc); } for (ALL_LIST_ELEMENTS_RO((struct list *)loc->chunks, node, chunk)) { - if (chunk->proto != 0 && chunk->proto != proto) + if (chunk->proto != NO_PROTO && chunk->proto != proto) continue; chunk_found = true; break; @@ -199,6 +199,8 @@ assign_srv6_locator_chunk(uint8_t proto, } chunk->proto = proto; + chunk->instance = instance; + chunk->session_id = session_id; return loc; }