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>
This commit is contained in:
Donald Sharp 2022-01-14 12:50:51 -05:00
parent 69a2d597d2
commit a7704e1b98
4 changed files with 34 additions and 36 deletions

View file

@ -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, extern void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq,
bool rt_delete); bool rt_delete);
extern struct route_node *
rib_find_rn_from_ctx(const struct zebra_dplane_ctx *ctx);
/* /*
* Inline functions. * Inline functions.
*/ */

View file

@ -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 * Common utility send route notification, called from a path using a
* route_entry and from a path using a dataplane context. * 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, uint16_t instance, vrf_id_t vrf_id,
uint32_t table_id, uint32_t table_id,
enum zapi_route_notify_owner note, enum zapi_route_notify_owner note, afi_t afi,
afi_t afi, safi_t safi) safi_t safi)
{ {
struct zserv *client; struct zserv *client;
struct stream *s; struct stream *s;
@ -757,16 +757,16 @@ static int route_notify_internal(const struct prefix *p, int type,
if (!client || !client->notify_owner) { if (!client || !client->notify_owner) {
if (IS_ZEBRA_DEBUG_PACKET) if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug( zlog_debug(
"Not Notifying Owner: %s about prefix %pFX(%u) %d vrf: %u", "Not Notifying Owner: %s about prefix %pRN(%u) %d vrf: %u",
zebra_route_string(type), p, table_id, note, zebra_route_string(type), rn, table_id, note,
vrf_id); vrf_id);
return 0; return 0;
} }
if (IS_ZEBRA_DEBUG_PACKET) if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug( zlog_debug(
"Notifying Owner: %s about prefix %pFX(%u) %d vrf: %u", "Notifying Owner: %s about prefix %pRN(%u) %d vrf: %u",
zebra_route_string(type), p, table_id, note, vrf_id); zebra_route_string(type), rn, table_id, note, vrf_id);
/* We're just allocating a small-ish buffer here, since we only /* We're just allocating a small-ish buffer here, since we only
* encode a small amount of data. * 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_put(s, &note, sizeof(note));
stream_putc(s, p->family); stream_putc(s, rn->p.family);
blen = prefix_blen(p); blen = prefix_blen(&rn->p);
stream_putc(s, p->prefixlen); stream_putc(s, rn->p.prefixlen);
stream_put(s, &p->u.prefix, blen); stream_put(s, &rn->p.u.prefix, blen);
stream_putl(s, table_id); 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); return zserv_send_message(client, s);
} }
int zsend_route_notify_owner(struct route_entry *re, const struct prefix *p, int zsend_route_notify_owner(const struct route_node *rn,
enum zapi_route_notify_owner note, struct route_entry *re,
afi_t afi, safi_t safi) 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)); re->table, note, afi, safi));
} }
@ -810,13 +811,10 @@ 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, int zsend_route_notify_owner_ctx(const struct zebra_dplane_ctx *ctx,
enum zapi_route_notify_owner note) enum zapi_route_notify_owner note)
{ {
return (route_notify_internal(dplane_ctx_get_dest(ctx), return (route_notify_internal(
dplane_ctx_get_type(ctx), rib_find_rn_from_ctx(ctx), dplane_ctx_get_type(ctx),
dplane_ctx_get_instance(ctx), dplane_ctx_get_instance(ctx), dplane_ctx_get_vrf(ctx),
dplane_ctx_get_vrf(ctx), dplane_ctx_get_table(ctx), note, dplane_ctx_get_afi(ctx),
dplane_ctx_get_table(ctx),
note,
dplane_ctx_get_afi(ctx),
dplane_ctx_get_safi(ctx))); dplane_ctx_get_safi(ctx)));
} }

View file

@ -75,8 +75,8 @@ extern int zsend_interface_vrf_update(struct zserv *zclient,
extern int zsend_interface_link_params(struct zserv *zclient, extern int zsend_interface_link_params(struct zserv *zclient,
struct interface *ifp); struct interface *ifp);
extern int zsend_pw_update(struct zserv *client, struct zebra_pw *pw); extern int zsend_pw_update(struct zserv *client, struct zebra_pw *pw);
extern int zsend_route_notify_owner(struct route_entry *re, extern int zsend_route_notify_owner(const struct route_node *rn,
const struct prefix *p, struct route_entry *re,
enum zapi_route_notify_owner note, enum zapi_route_notify_owner note,
afi_t afi, safi_t safi); afi_t afi, safi_t safi);
extern int zsend_route_notify_owner_ctx(const struct zebra_dplane_ctx *ctx, extern int zsend_route_notify_owner_ctx(const struct zebra_dplane_ctx *ctx,

View file

@ -575,7 +575,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re,
* know that they've lost * know that they've lost
*/ */
if (old && (old != re) && (old->type != re->type)) 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); info->afi, info->safi);
/* Update fib selection */ /* Update fib selection */
@ -1192,8 +1192,8 @@ static void rib_process(struct route_node *rn)
info = srcdest_rnode_table_info(rn); info = srcdest_rnode_table_info(rn);
srcdest_rnode_prefixes(rn, &p, NULL); srcdest_rnode_prefixes(rn, &p, NULL);
zsend_route_notify_owner(re, p, zsend_route_notify_owner(
ZAPI_ROUTE_FAIL_INSTALL, rn, re, ZAPI_ROUTE_FAIL_INSTALL,
info->afi, info->safi); info->afi, info->safi);
continue; continue;
} }
@ -1755,8 +1755,7 @@ done:
* when processing dplane results, e.g. Note well: the route-node is returned * when processing dplane results, e.g. Note well: the route-node is returned
* with a ref held - route_unlock_node() must be called eventually. * with a ref held - route_unlock_node() must be called eventually.
*/ */
static struct route_node * struct route_node *rib_find_rn_from_ctx(const struct zebra_dplane_ctx *ctx)
rib_find_rn_from_ctx(const struct zebra_dplane_ctx *ctx)
{ {
struct route_table *table = NULL; struct route_table *table = NULL;
struct route_node *rn = NULL; struct route_node *rn = NULL;
@ -1803,7 +1802,6 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
bool is_update = false; bool is_update = false;
enum dplane_op_e op; enum dplane_op_e op;
enum zebra_dplane_result status; enum zebra_dplane_result status;
const struct prefix *dest_pfx;
uint32_t seq; uint32_t seq;
rib_dest_t *dest; rib_dest_t *dest;
bool fib_changed = false; bool fib_changed = false;
@ -1825,7 +1823,6 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
} }
dest = rib_dest_from_rnode(rn); dest = rib_dest_from_rnode(rn);
srcdest_rnode_prefixes(rn, &dest_pfx, NULL);
info = srcdest_rnode_table_info(rn); info = srcdest_rnode_table_info(rn);
op = dplane_ctx_get_op(ctx); op = dplane_ctx_get_op(ctx);
@ -1983,8 +1980,8 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
} if (old_re) } if (old_re)
SET_FLAG(old_re->status, ROUTE_ENTRY_FAILED); SET_FLAG(old_re->status, ROUTE_ENTRY_FAILED);
if (re) if (re)
zsend_route_notify_owner(re, dest_pfx, zsend_route_notify_owner(
ZAPI_ROUTE_FAIL_INSTALL, rn, re, ZAPI_ROUTE_FAIL_INSTALL,
info->afi, info->safi); info->afi, info->safi);
zlog_warn("%s(%u:%u):%pRN: Route install failed", zlog_warn("%s(%u:%u):%pRN: Route install failed",