zebra/ldpd: introduce ZEBRA_ROUTE_ALL wildcard route type

The ZEBRA_ROUTE_ALL route type can be used by a client to request
all routes from zebra. The main motivation for introducing this is
to allow ldpd to get routes from all OSPF instances, not only from
the default one. Without ZEBRA_ROUTE_ALL, ldpd would need to send a
ZEBRA_REDISTRIBUTE_ADD message for each possible OSPF instance (65k),
which doesn't scale very well.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2016-10-05 17:58:01 -03:00 committed by Donald Sharp
parent f9164b1d74
commit a695cc7b80
3 changed files with 23 additions and 35 deletions

View File

@ -359,8 +359,17 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length,
s = zclient->ibuf;
type = stream_getc(s);
if (type == ZEBRA_ROUTE_CONNECT)
switch (type) {
case ZEBRA_ROUTE_CONNECT:
kr.flags |= F_CONNECTED;
break;
case ZEBRA_ROUTE_BGP:
/* LDP should follow the IGP and ignore BGP routes */
return (0);
default:
break;
}
stream_getl(s); /* flags, unused */
stream_getw(s); /* instance, unused */
message_flags = stream_getc(s);
@ -448,37 +457,11 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length,
static void
ldp_zebra_connected(struct zclient *zclient)
{
int i;
zclient_send_reg_requests(zclient, VRF_DEFAULT);
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
switch (i) {
case ZEBRA_ROUTE_KERNEL:
case ZEBRA_ROUTE_CONNECT:
case ZEBRA_ROUTE_STATIC:
case ZEBRA_ROUTE_ISIS:
zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient,
AFI_IP, i, 0, VRF_DEFAULT);
zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient,
AFI_IP6, i, 0, VRF_DEFAULT);
break;
case ZEBRA_ROUTE_RIP:
case ZEBRA_ROUTE_OSPF:
zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient,
AFI_IP, i, 0, VRF_DEFAULT);
break;
case ZEBRA_ROUTE_RIPNG:
case ZEBRA_ROUTE_OSPF6:
zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient,
AFI_IP6, i, 0, VRF_DEFAULT);
break;
case ZEBRA_ROUTE_BGP:
/* LDP should follow the IGP and ignore BGP routes */
default:
break;
}
}
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT);
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6,
ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT);
}
void

View File

@ -71,6 +71,7 @@ ZEBRA_ROUTE_VNC_DIRECT_RH, vpn-rh, NULL, 'V', 0, 0, "VPN"
ZEBRA_ROUTE_BGP_DIRECT, bgp-direct, NULL, 'b', 0, 0, "BGP-Direct"
# bgp unicast -> vnc
ZEBRA_ROUTE_BGP_DIRECT_EXT, bgp-direct-to-nve-groups, NULL, 'e', 0, 0, "BGP2VNC"
ZEBRA_ROUTE_ALL, wildcard, none, '-', 0, 0, "-"
## help strings
ZEBRA_ROUTE_SYSTEM, "Reserved route type, for internal use only"

View File

@ -146,8 +146,8 @@ zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t v
newrib->type, newrib->distance, zebra_check_addr (&rn->p));
if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED)
&& newrib->type == type
&& newrib->instance == instance
&& (type == ZEBRA_ROUTE_ALL ||
(newrib->type == type && newrib->instance == instance))
&& newrib->distance != DISTANCE_INFINITY
&& zebra_check_addr (&rn->p))
{
@ -161,8 +161,8 @@ zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t v
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, newrib)
if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED)
&& newrib->type == type
&& newrib->instance == instance
&& (type == ZEBRA_ROUTE_ALL ||
(newrib->type == type && newrib->instance == instance))
&& newrib->distance != DISTANCE_INFINITY
&& zebra_check_addr (&rn->p))
{
@ -204,6 +204,9 @@ redistribute_update (struct prefix *p, struct rib *rib, struct rib *prev_rib)
if (is_default(p) && client->redist_default)
send_redistribute = 1;
if (vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], rib->vrf_id))
send_redistribute = 1;
if (rib->instance && redist_check_instance(&client->mi_redist[afi][rib->type],
rib->instance))
send_redistribute = 1;
@ -287,6 +290,7 @@ redistribute_delete (struct prefix *p, struct rib *rib)
{
if ((is_default (p) &&
vrf_bitmap_check (client->redist_default, rib->vrf_id)) ||
vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], rib->vrf_id) ||
(rib->instance &&
redist_check_instance(&client->mi_redist[afi][rib->type],
rib->instance)) ||