summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2022-01-14 12:50:51 -0500
committerDonald Sharp <sharpd@nvidia.com>2022-01-18 08:39:41 -0500
commita7704e1b98dbb9eaeaff988fe924d9e8910faf0c (patch)
tree544220dfc87d3e7007c2351bcd9fd38997c19af1 /zebra
parent69a2d597d2ca8afb401ecd94d44c543df41b1d4b (diff)
zebra: Modify route_notify_internal to use a route_node
Pass in the route_node that is under consideration into route_notify_internal to allow calling functions to reduce stack size as well as looking up data. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/rib.h3
-rw-r--r--zebra/zapi_msg.c44
-rw-r--r--zebra/zapi_msg.h4
-rw-r--r--zebra/zebra_rib.c19
4 files changed, 34 insertions, 36 deletions
diff --git a/zebra/rib.h b/zebra/rib.h
index b7416322f9..a0ec1f0e4f 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -493,6 +493,9 @@ extern uint8_t route_distance(int type);
extern void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq,
bool rt_delete);
+extern struct route_node *
+rib_find_rn_from_ctx(const struct zebra_dplane_ctx *ctx);
+
/*
* Inline functions.
*/
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 3ec0baf8c7..359b8876e0 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -743,11 +743,11 @@ int zsend_nhg_notify(uint16_t type, uint16_t instance, uint32_t session_id,
* Common utility send route notification, called from a path using a
* route_entry and from a path using a dataplane context.
*/
-static int route_notify_internal(const struct prefix *p, int type,
+static int route_notify_internal(const struct route_node *rn, int type,
uint16_t instance, vrf_id_t vrf_id,
uint32_t table_id,
- enum zapi_route_notify_owner note,
- afi_t afi, safi_t safi)
+ enum zapi_route_notify_owner note, afi_t afi,
+ safi_t safi)
{
struct zserv *client;
struct stream *s;
@@ -757,16 +757,16 @@ static int route_notify_internal(const struct prefix *p, int type,
if (!client || !client->notify_owner) {
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug(
- "Not Notifying Owner: %s about prefix %pFX(%u) %d vrf: %u",
- zebra_route_string(type), p, table_id, note,
+ "Not Notifying Owner: %s about prefix %pRN(%u) %d vrf: %u",
+ zebra_route_string(type), rn, table_id, note,
vrf_id);
return 0;
}
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug(
- "Notifying Owner: %s about prefix %pFX(%u) %d vrf: %u",
- zebra_route_string(type), p, table_id, note, vrf_id);
+ "Notifying Owner: %s about prefix %pRN(%u) %d vrf: %u",
+ zebra_route_string(type), rn, table_id, note, vrf_id);
/* We're just allocating a small-ish buffer here, since we only
* encode a small amount of data.
@@ -779,11 +779,11 @@ static int route_notify_internal(const struct prefix *p, int type,
stream_put(s, &note, sizeof(note));
- stream_putc(s, p->family);
+ stream_putc(s, rn->p.family);
- blen = prefix_blen(p);
- stream_putc(s, p->prefixlen);
- stream_put(s, &p->u.prefix, blen);
+ blen = prefix_blen(&rn->p);
+ stream_putc(s, rn->p.prefixlen);
+ stream_put(s, &rn->p.u.prefix, blen);
stream_putl(s, table_id);
@@ -796,11 +796,12 @@ static int route_notify_internal(const struct prefix *p, int type,
return zserv_send_message(client, s);
}
-int zsend_route_notify_owner(struct route_entry *re, const struct prefix *p,
- enum zapi_route_notify_owner note,
- afi_t afi, safi_t safi)
+int zsend_route_notify_owner(const struct route_node *rn,
+ struct route_entry *re,
+ enum zapi_route_notify_owner note, afi_t afi,
+ safi_t safi)
{
- return (route_notify_internal(p, re->type, re->instance, re->vrf_id,
+ return (route_notify_internal(rn, re->type, re->instance, re->vrf_id,
re->table, note, afi, safi));
}
@@ -810,14 +811,11 @@ int zsend_route_notify_owner(struct route_entry *re, const struct prefix *p,
int zsend_route_notify_owner_ctx(const struct zebra_dplane_ctx *ctx,
enum zapi_route_notify_owner note)
{
- return (route_notify_internal(dplane_ctx_get_dest(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)));
+ 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)));
}
static void zread_route_notify_request(ZAPI_HANDLER_ARGS)
diff --git a/zebra/zapi_msg.h b/zebra/zapi_msg.h
index 44a22c5ed9..b3fe7318f9 100644
--- a/zebra/zapi_msg.h
+++ b/zebra/zapi_msg.h
@@ -75,8 +75,8 @@ extern int zsend_interface_vrf_update(struct zserv *zclient,
extern int zsend_interface_link_params(struct zserv *zclient,
struct interface *ifp);
extern int zsend_pw_update(struct zserv *client, struct zebra_pw *pw);
-extern int zsend_route_notify_owner(struct route_entry *re,
- const struct prefix *p,
+extern int zsend_route_notify_owner(const struct route_node *rn,
+ struct route_entry *re,
enum zapi_route_notify_owner note,
afi_t afi, safi_t safi);
extern int zsend_route_notify_owner_ctx(const struct zebra_dplane_ctx *ctx,
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 25757352d7..82478233a9 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -575,7 +575,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re,
* know that they've lost
*/
if (old && (old != re) && (old->type != re->type))
- zsend_route_notify_owner(old, p, ZAPI_ROUTE_BETTER_ADMIN_WON,
+ zsend_route_notify_owner(rn, old, ZAPI_ROUTE_BETTER_ADMIN_WON,
info->afi, info->safi);
/* Update fib selection */
@@ -1192,9 +1192,9 @@ static void rib_process(struct route_node *rn)
info = srcdest_rnode_table_info(rn);
srcdest_rnode_prefixes(rn, &p, NULL);
- zsend_route_notify_owner(re, p,
- ZAPI_ROUTE_FAIL_INSTALL,
- info->afi, info->safi);
+ zsend_route_notify_owner(
+ rn, re, ZAPI_ROUTE_FAIL_INSTALL,
+ info->afi, info->safi);
continue;
}
} else {
@@ -1755,8 +1755,7 @@ done:
* when processing dplane results, e.g. Note well: the route-node is returned
* with a ref held - route_unlock_node() must be called eventually.
*/
-static struct route_node *
-rib_find_rn_from_ctx(const struct zebra_dplane_ctx *ctx)
+struct route_node *rib_find_rn_from_ctx(const struct zebra_dplane_ctx *ctx)
{
struct route_table *table = NULL;
struct route_node *rn = NULL;
@@ -1803,7 +1802,6 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
bool is_update = false;
enum dplane_op_e op;
enum zebra_dplane_result status;
- const struct prefix *dest_pfx;
uint32_t seq;
rib_dest_t *dest;
bool fib_changed = false;
@@ -1825,7 +1823,6 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
}
dest = rib_dest_from_rnode(rn);
- srcdest_rnode_prefixes(rn, &dest_pfx, NULL);
info = srcdest_rnode_table_info(rn);
op = dplane_ctx_get_op(ctx);
@@ -1983,9 +1980,9 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
} if (old_re)
SET_FLAG(old_re->status, ROUTE_ENTRY_FAILED);
if (re)
- zsend_route_notify_owner(re, dest_pfx,
- ZAPI_ROUTE_FAIL_INSTALL,
- info->afi, info->safi);
+ zsend_route_notify_owner(
+ rn, re, ZAPI_ROUTE_FAIL_INSTALL,
+ info->afi, info->safi);
zlog_warn("%s(%u:%u):%pRN: Route install failed",
VRF_LOGNAME(vrf), dplane_ctx_get_vrf(ctx),