summaryrefslogtreecommitdiff
path: root/zebra/zebra_rib.c
diff options
context:
space:
mode:
authorMark Stapp <mjs.ietf@gmail.com>2022-02-02 08:35:00 -0500
committerGitHub <noreply@github.com>2022-02-02 08:35:00 -0500
commit3d1ff4bfdb159583a62e72ccb359a8508c4cbb2e (patch)
tree45d34fef009c1f114f8c795454e21902d2e016be /zebra/zebra_rib.c
parent249932f969e96ffb27276146d59f9031326c373b (diff)
parent0ef6eacc95c82014c04f13be3b641ff3983040ca (diff)
Merge pull request #10409 from idryzhov/zebra-mq-clean-crash
zebra: fix cleanup of meta queues on vrf disable
Diffstat (limited to 'zebra/zebra_rib.c')
-rw-r--r--zebra/zebra_rib.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index d00413a222..fbd3c6eb77 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2944,6 +2944,59 @@ void meta_queue_free(struct meta_queue *mq)
XFREE(MTYPE_WORK_QUEUE, mq);
}
+void rib_meta_queue_free_vrf(struct meta_queue *mq, struct zebra_vrf *zvrf)
+{
+ vrf_id_t vrf_id = zvrf->vrf->vrf_id;
+ unsigned int i;
+
+ for (i = 0; i < MQ_SIZE; i++) {
+ struct listnode *lnode, *nnode;
+ void *data;
+ bool del;
+
+ for (ALL_LIST_ELEMENTS(mq->subq[i], lnode, nnode, data)) {
+ del = false;
+
+ if (i == META_QUEUE_EVPN) {
+ struct wq_evpn_wrapper *w = data;
+
+ if (w->vrf_id == vrf_id) {
+ XFREE(MTYPE_WQ_WRAPPER, w);
+ del = true;
+ }
+ } else if (i ==
+ route_info[ZEBRA_ROUTE_NHG].meta_q_map) {
+ struct wq_nhg_wrapper *w = data;
+
+ if (w->type == WQ_NHG_WRAPPER_TYPE_CTX &&
+ w->u.ctx->vrf_id == vrf_id) {
+ nhg_ctx_free(&w->u.ctx);
+ XFREE(MTYPE_WQ_WRAPPER, w);
+ del = true;
+ } else if (w->type == WQ_NHG_WRAPPER_TYPE_NHG &&
+ w->u.nhe->vrf_id == vrf_id) {
+ zebra_nhg_free(w->u.nhe);
+ XFREE(MTYPE_WQ_WRAPPER, w);
+ del = true;
+ }
+ } else {
+ struct route_node *rnode = data;
+ rib_dest_t *dest = rib_dest_from_rnode(rnode);
+
+ if (dest && rib_dest_vrf(dest) == zvrf) {
+ route_unlock_node(rnode);
+ del = true;
+ }
+ }
+
+ if (del) {
+ list_delete_node(mq->subq[i], lnode);
+ mq->size--;
+ }
+ }
+ }
+}
+
/* initialise zebra rib work queue */
static void rib_queue_init(void)
{