]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Unlock the route node when sending route notifications
authorDonald Sharp <sharpd@nvidia.com>
Wed, 31 May 2023 15:40:07 +0000 (11:40 -0400)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Tue, 6 Jun 2023 05:53:21 +0000 (05:53 +0000)
When using a context to send route notifications to upper
level protocols, the code was using a locking function to
get the route node.  There is no need for this to be locked
as such FRR should free it up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 82c6e4fea54eb65e153e6bc45bb718367b0b5132)

zebra/rib.h
zebra/zapi_msg.c

index c9bd2b8c957fbf56e5d2bf17006b3b7bbcd27ed1..d6e4e7825ac2d00a4b95cfbecb5f51044368dcba 100644 (file)
@@ -476,6 +476,13 @@ extern uint8_t route_distance(int type);
 extern void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq,
                                           bool rt_delete);
 
+/*
+ * rib_find_rn_from_ctx
+ *
+ * Returns a lock increased route_node for the appropriate
+ * table and prefix specified by the context.  Developer
+ * should unlock the node when done.
+ */
 extern struct route_node *
 rib_find_rn_from_ctx(const struct zebra_dplane_ctx *ctx);
 
index 761ba789b87afb1ab3193956ec67432477444a6a..a32a82d73c7bb55f44da1793979bedd8498ef3c8 100644 (file)
@@ -818,11 +818,17 @@ int zsend_route_notify_owner(const struct route_node *rn,
 int zsend_route_notify_owner_ctx(const struct zebra_dplane_ctx *ctx,
                                 enum zapi_route_notify_owner note)
 {
-       return (route_notify_internal(
-               rib_find_rn_from_ctx(ctx), dplane_ctx_get_type(ctx),
-               dplane_ctx_get_instance(ctx), dplane_ctx_get_vrf(ctx),
-               dplane_ctx_get_table(ctx), note, dplane_ctx_get_afi(ctx),
-               dplane_ctx_get_safi(ctx)));
+       int result;
+       struct route_node *rn = rib_find_rn_from_ctx(ctx);
+
+       result = route_notify_internal(
+               rn, dplane_ctx_get_type(ctx), dplane_ctx_get_instance(ctx),
+               dplane_ctx_get_vrf(ctx), dplane_ctx_get_table(ctx), note,
+               dplane_ctx_get_afi(ctx), dplane_ctx_get_safi(ctx));
+
+       route_unlock_node(rn);
+
+       return result;
 }
 
 static void zread_route_notify_request(ZAPI_HANDLER_ARGS)