From f00b37e710e5dd402a514af8817e2cca7d1710ce Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 29 Jun 2022 15:24:20 -0400 Subject: [PATCH] zebra: make rib_process_dplane_results own ctx freeing The rib_process_dplane_results function was having each sub function handler process the results and then free the ctx. Lot's of functionality that needs to remember to free the context. Let's just free it in the main loop. Signed-off-by: Donald Sharp --- zebra/interface.c | 6 ++---- zebra/zebra_mpls.c | 9 ++------- zebra/zebra_nhg.c | 2 -- zebra/zebra_pbr.c | 3 --- zebra/zebra_rib.c | 33 +++++---------------------------- zebra/zebra_vxlan.c | 3 +-- 6 files changed, 10 insertions(+), 46 deletions(-) diff --git a/zebra/interface.c b/zebra/interface.c index 9800e64503..de7db2d48f 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1504,7 +1504,7 @@ void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx) if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug("%s: can't find zns id %u", __func__, ns_id); - goto done; + return; } ifp = if_lookup_by_index_per_ns(zns, ifindex); @@ -1516,7 +1516,7 @@ void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx) "%s: can't find ifp at nsid %u index %d", __func__, ns_id, ifindex); - goto done; + return; } } @@ -1578,8 +1578,6 @@ void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx) case DPLANE_OP_GRE_SET: break; /* should never hit here */ } -done: - dplane_ctx_fini(&ctx); } /* Dump if address information to vty. */ diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 8237bebf3b..772e30833c 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1855,8 +1855,6 @@ void zebra_mpls_lsp_dplane_result(struct zebra_dplane_ctx *ctx) break; } /* Switch */ - - dplane_ctx_fini(&ctx); } /* @@ -2064,7 +2062,7 @@ void zebra_mpls_process_dplane_notify(struct zebra_dplane_ctx *ctx) /* Look for zebra LSP object */ zvrf = vrf_info_lookup(VRF_DEFAULT); if (zvrf == NULL) - goto done; + return; lsp_table = zvrf->lsp_table; @@ -2074,7 +2072,7 @@ void zebra_mpls_process_dplane_notify(struct zebra_dplane_ctx *ctx) if (is_debug) zlog_debug("dplane LSP notif: in-label %u not found", dplane_ctx_get_in_label(ctx)); - goto done; + return; } /* @@ -2147,9 +2145,6 @@ void zebra_mpls_process_dplane_notify(struct zebra_dplane_ctx *ctx) UNSET_FLAG(lsp->flags, LSP_FLAG_INSTALLED); clear_nhlfe_installed(lsp); } - -done: - dplane_ctx_fini(&ctx); } /* diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 9a0f48158f..8a255981b7 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -3076,8 +3076,6 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx) case DPLANE_OP_INTF_DELETE: break; } - - dplane_ctx_fini(&ctx); } static int zebra_nhg_sweep_entry(struct hash_bucket *bucket, void *arg) diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index e6424fea4f..43e21a6d34 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -1068,9 +1068,6 @@ void zebra_pbr_dplane_result(struct zebra_dplane_ctx *ctx) EC_ZEBRA_PBR_RULE_UPDATE, "Context received in pbr rule dplane result handler with incorrect OP code (%u)", op); - - - dplane_ctx_fini(&ctx); } /* diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 63f15b0f20..261335e4a4 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2087,9 +2087,6 @@ done: if (rn) route_unlock_node(rn); - - /* Return context to dataplane module */ - dplane_ctx_fini(&ctx); } /* @@ -2323,9 +2320,6 @@ static void rib_process_dplane_notify(struct zebra_dplane_ctx *ctx) done: if (rn) route_unlock_node(rn); - - /* Return context to dataplane module */ - dplane_ctx_fini(&ctx); } /* @@ -4191,7 +4185,7 @@ void rib_close_table(struct route_table *table) /* * Handler for async dataplane results after a pseudowire installation */ -static int handle_pw_result(struct zebra_dplane_ctx *ctx) +static void handle_pw_result(struct zebra_dplane_ctx *ctx) { struct zebra_pw *pw; struct zebra_vrf *vrf; @@ -4200,7 +4194,7 @@ static int handle_pw_result(struct zebra_dplane_ctx *ctx) * result for installation attempts here. */ if (dplane_ctx_get_op(ctx) != DPLANE_OP_PW_INSTALL) - goto done; + return; if (dplane_ctx_get_status(ctx) != ZEBRA_DPLANE_REQUEST_SUCCESS) { vrf = zebra_vrf_lookup_by_id(dplane_ctx_get_vrf(ctx)); @@ -4209,14 +4203,8 @@ static int handle_pw_result(struct zebra_dplane_ctx *ctx) zebra_pw_install_failure(pw, dplane_ctx_get_pw_status(ctx)); } - -done: - dplane_ctx_fini(&ctx); - - return 0; } - /* * Handle results from the dataplane system. Dequeue update context * structs, dispatch to appropriate internal handlers. @@ -4289,7 +4277,6 @@ static void rib_process_dplane_results(struct thread *thread) case DPLANE_OP_ROUTE_INSTALL: case DPLANE_OP_ROUTE_UPDATE: case DPLANE_OP_ROUTE_DELETE: - { /* Bit of special case for route updates * that were generated by async notifications: * we don't want to continue processing these @@ -4297,10 +4284,7 @@ static void rib_process_dplane_results(struct thread *thread) */ if (dplane_ctx_get_notif_provider(ctx) == 0) rib_process_result(ctx); - else - dplane_ctx_fini(&ctx); - } - break; + break; case DPLANE_OP_ROUTE_NOTIFY: rib_process_dplane_notify(ctx); @@ -4315,17 +4299,13 @@ static void rib_process_dplane_results(struct thread *thread) case DPLANE_OP_LSP_INSTALL: case DPLANE_OP_LSP_UPDATE: case DPLANE_OP_LSP_DELETE: - { /* Bit of special case for LSP updates * that were generated by async notifications: * we don't want to continue processing these. */ if (dplane_ctx_get_notif_provider(ctx) == 0) zebra_mpls_lsp_dplane_result(ctx); - else - dplane_ctx_fini(&ctx); - } - break; + break; case DPLANE_OP_LSP_NOTIFY: zebra_mpls_process_dplane_notify(ctx); @@ -4338,8 +4318,6 @@ static void rib_process_dplane_results(struct thread *thread) case DPLANE_OP_SYS_ROUTE_ADD: case DPLANE_OP_SYS_ROUTE_DELETE: - /* No further processing in zebra for these. */ - dplane_ctx_fini(&ctx); break; case DPLANE_OP_MAC_INSTALL: @@ -4383,12 +4361,11 @@ static void rib_process_dplane_results(struct thread *thread) case DPLANE_OP_NEIGH_TABLE_UPDATE: case DPLANE_OP_GRE_SET: case DPLANE_OP_NONE: - /* Don't expect this: just return the struct? */ - dplane_ctx_fini(&ctx); break; } /* Dispatch by op code */ + dplane_ctx_fini(&ctx); ctx = dplane_ctx_dequeue(&ctxlist); } diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 4cf309f7fc..dbe1ce3e46 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -6260,8 +6260,7 @@ static int zebra_evpn_cfg_clean_up(struct zserv *client) */ extern void zebra_vxlan_handle_result(struct zebra_dplane_ctx *ctx) { - /* TODO -- anything other than freeing the context? */ - dplane_ctx_fini(&ctx); + return; } /* Cleanup BGP EVPN configuration upon client disconnect */