bgpd: 'redistribute' triggers both IPv4 and IPv6 code paths

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

Whenever you did "redistribute" zebra would kick this off for ipv4 and
ipv6. No real issue other than this is sub-optimal
This commit is contained in:
Daniel Walton 2017-05-16 23:58:34 +00:00
parent 10a6a98b0a
commit 501be9875b

View File

@ -108,42 +108,38 @@ zebra_redistribute_default (struct zserv *client, vrf_id_t vrf_id)
/* Redistribute routes. */
static void
zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t vrf_id)
zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t vrf_id, int afi)
{
struct rib *newrib;
struct route_table *table;
struct route_node *rn;
int afi;
for (afi = AFI_IP; afi <= AFI_IP6; afi++)
{
table = zebra_vrf_table (afi, SAFI_UNICAST, vrf_id);
if (! table)
continue;
table = zebra_vrf_table (afi, SAFI_UNICAST, vrf_id);
if (! table)
return;
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, newrib)
{
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("%s: checking: selected=%d, type=%d, distance=%d, "
"zebra_check_addr=%d", __func__,
CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED),
newrib->type, newrib->distance,
zebra_check_addr (&rn->p));
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, newrib)
{
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("%s: checking: selected=%d, type=%d, distance=%d, "
"zebra_check_addr=%d", __func__,
CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED),
newrib->type, newrib->distance,
zebra_check_addr (&rn->p));
if (! CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED))
continue;
if ((type != ZEBRA_ROUTE_ALL &&
(newrib->type != type || newrib->instance != instance)))
continue;
if (newrib->distance == DISTANCE_INFINITY)
continue;
if (! zebra_check_addr (&rn->p))
continue;
if (! CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED))
continue;
if ((type != ZEBRA_ROUTE_ALL &&
(newrib->type != type || newrib->instance != instance)))
continue;
if (newrib->distance == DISTANCE_INFINITY)
continue;
if (! zebra_check_addr (&rn->p))
continue;
zsend_redistribute_route (1, client, &rn->p, newrib);
}
}
zsend_redistribute_route (1, client, &rn->p, newrib);
}
}
/* Either advertise a route for redistribution to registered clients or */
@ -262,13 +258,13 @@ zebra_redistribute_add (int command, struct zserv *client, int length,
if (! redist_check_instance (&client->mi_redist[afi][type], instance))
{
redist_add_instance (&client->mi_redist[afi][type], instance);
zebra_redistribute (client, type, instance, zvrf_id (zvrf));
zebra_redistribute (client, type, instance, zvrf_id (zvrf), afi);
}
} else {
if (! vrf_bitmap_check (client->redist[afi][type], zvrf_id (zvrf)))
{
vrf_bitmap_set (client->redist[afi][type], zvrf_id (zvrf));
zebra_redistribute (client, type, 0, zvrf_id (zvrf));
zebra_redistribute (client, type, 0, zvrf_id (zvrf), afi);
}
}
}