zebra: Pass rn to zebra_redistribute_check instead

FRR is using struct prefix and afi to be passed
around.  When all that is needed is the route node.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-01-14 11:18:48 -05:00
parent ee78ed680b
commit c8671e9f9b

View File

@ -149,23 +149,25 @@ static void zebra_redistribute(struct zserv *client, int type,
* Function to check if prefix is candidate for * Function to check if prefix is candidate for
* redistribute. * redistribute.
*/ */
static bool zebra_redistribute_check(const struct route_entry *re, static bool zebra_redistribute_check(const struct route_node *rn,
struct zserv *client, const struct route_entry *re,
const struct prefix *p, int afi) struct zserv *client)
{ {
struct zebra_vrf *zvrf; struct zebra_vrf *zvrf;
afi_t afi;
/* Process only if there is valid re */ /* Process only if there is valid re */
if (!re) if (!re)
return false; return false;
afi = family2afi(rn->p.family);
zvrf = vrf_info_lookup(re->vrf_id); zvrf = vrf_info_lookup(re->vrf_id);
if (re->vrf_id == VRF_DEFAULT && zvrf->table_id != re->table) if (re->vrf_id == VRF_DEFAULT && zvrf->table_id != re->table)
return false; return false;
/* If default route and redistributed */ /* If default route and redistributed */
if (is_default_prefix(p) if (is_default_prefix(&rn->p) &&
&& vrf_bitmap_check(client->redist_default[afi], re->vrf_id)) vrf_bitmap_check(client->redist_default[afi], re->vrf_id))
return true; return true;
/* If redistribute in enabled for zebra route all */ /* If redistribute in enabled for zebra route all */
@ -218,8 +220,7 @@ void redistribute_update(const struct route_node *rn,
const struct prefix *p, *src_p; const struct prefix *p, *src_p;
srcdest_rnode_prefixes(rn, &p, &src_p); srcdest_rnode_prefixes(rn, &p, &src_p);
if (zebra_redistribute_check(re, client, p, if (zebra_redistribute_check(rn, re, client)) {
family2afi(p->family))) {
if (IS_ZEBRA_DEBUG_RIB) { if (IS_ZEBRA_DEBUG_RIB) {
zlog_debug( zlog_debug(
"%s: client %s %pRN(%u:%u), type=%d, distance=%d, metric=%d", "%s: client %s %pRN(%u:%u), type=%d, distance=%d, metric=%d",
@ -230,8 +231,7 @@ void redistribute_update(const struct route_node *rn,
} }
zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_ADD, zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_ADD,
client, p, src_p, re); client, p, src_p, re);
} else if (zebra_redistribute_check(prev_re, client, p, } else if (zebra_redistribute_check(rn, prev_re, client))
family2afi(p->family)))
zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL, zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
client, p, src_p, prev_re); client, p, src_p, prev_re);
} }
@ -286,13 +286,11 @@ void redistribute_delete(const struct route_node *rn,
* Skip this client if it will receive an update for the * Skip this client if it will receive an update for the
* 'new' re * 'new' re
*/ */
if (zebra_redistribute_check(new_re, client, &rn->p, if (zebra_redistribute_check(rn, new_re, client))
family2afi(rn->p.family)))
continue; continue;
/* Send a delete for the 'old' re to any subscribed client. */ /* Send a delete for the 'old' re to any subscribed client. */
if (zebra_redistribute_check(old_re, client, &rn->p, if (zebra_redistribute_check(rn, old_re, client)) {
family2afi(rn->p.family))) {
const struct prefix *p, *src_p; const struct prefix *p, *src_p;
srcdest_rnode_prefixes(rn, &p, &src_p); srcdest_rnode_prefixes(rn, &p, &src_p);