Merge pull request #5095 from donaldsharp/static_fix_for_ROUTE_ALL

ZEBRA_ROUTE_ALL fix
This commit is contained in:
Jafar Al-Gharaibeh 2019-10-02 09:30:36 -07:00 committed by GitHub
commit 6d7b7e4257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 28 deletions

View File

@ -205,6 +205,15 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)
static void zebra_connected(struct zclient *zclient) static void zebra_connected(struct zclient *zclient)
{ {
zclient_send_reg_requests(zclient, VRF_DEFAULT); zclient_send_reg_requests(zclient, VRF_DEFAULT);
/*
* Do not actually turn this on yet
* This is just the start of the infrastructure needed here
* This can be fixed at a later time.
*
* zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
* ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT);
*/
} }
void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label) void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label)
@ -300,28 +309,13 @@ void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import,
__PRETTY_FUNCTION__); __PRETTY_FUNCTION__);
} }
static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS) static int sharp_debug_nexthops(struct zapi_route *api)
{ {
struct sharp_nh_tracker *nht;
struct zapi_route nhr;
char buf[PREFIX_STRLEN];
int i; int i;
char buf[PREFIX_STRLEN];
if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) { for (i = 0; i < api->nexthop_num; i++) {
zlog_warn("%s: Decode of update failed", __PRETTY_FUNCTION__); struct zapi_nexthop *znh = &api->nexthops[i];
return 0;
}
zlog_debug("Received update for %s",
prefix2str(&nhr.prefix, buf, sizeof(buf)));
nht = sharp_nh_tracker_get(&nhr.prefix);
nht->nhop_num = nhr.nexthop_num;
nht->updates++;
for (i = 0; i < nhr.nexthop_num; i++) {
struct zapi_nexthop *znh = &nhr.nexthops[i];
switch (znh->type) { switch (znh->type) {
case NEXTHOP_TYPE_IPV4_IFINDEX: case NEXTHOP_TYPE_IPV4_IFINDEX:
@ -351,6 +345,45 @@ static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)
break; break;
} }
} }
return i;
}
static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)
{
struct sharp_nh_tracker *nht;
struct zapi_route nhr;
if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) {
zlog_warn("%s: Decode of update failed", __PRETTY_FUNCTION__);
return 0;
}
zlog_debug("Received update for %pFX", &nhr.prefix);
nht = sharp_nh_tracker_get(&nhr.prefix);
nht->nhop_num = nhr.nexthop_num;
nht->updates++;
sharp_debug_nexthops(&nhr);
return 0;
}
static int sharp_redistribute_route(ZAPI_CALLBACK_ARGS)
{
struct zapi_route api;
if (zapi_route_decode(zclient->ibuf, &api) < 0)
zlog_warn("%s: Decode of redistribute failed: %d",
__PRETTY_FUNCTION__,
ZEBRA_REDISTRIBUTE_ROUTE_ADD);
zlog_debug("%s: %pFX (%s)", zserv_command_string(cmd),
&api.prefix, zebra_route_string(api.type));
sharp_debug_nexthops(&api);
return 0; return 0;
} }
@ -372,4 +405,7 @@ void sharp_zebra_init(void)
zclient->route_notify_owner = route_notify_owner; zclient->route_notify_owner = route_notify_owner;
zclient->nexthop_update = sharp_nexthop_update; zclient->nexthop_update = sharp_nexthop_update;
zclient->import_check_update = sharp_nexthop_update; zclient->import_check_update = sharp_nexthop_update;
zclient->redistribute_route_add = sharp_redistribute_route;
zclient->redistribute_route_del = sharp_redistribute_route;
} }

View File

@ -263,8 +263,11 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
} }
/* Add DISTANCE_INFINITY check. */ /* Add DISTANCE_INFINITY check. */
if (old_re && (old_re->distance == DISTANCE_INFINITY)) if (old_re && (old_re->distance == DISTANCE_INFINITY)) {
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug("\tSkipping due to Infinite Distance");
return; return;
}
afi = family2afi(p->family); afi = family2afi(p->family);
if (!afi) { if (!afi) {
@ -310,14 +313,14 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
/* Send a delete for the 'old' re to any subscribed client. */ /* Send a delete for the 'old' re to any subscribed client. */
if (old_re if (old_re
&& ((old_re->instance && (vrf_bitmap_check(client->redist[afi][ZEBRA_ROUTE_ALL],
&& redist_check_instance( old_re->vrf_id)
&client->mi_redist[afi] || (old_re->instance
[old_re->type], && redist_check_instance(
old_re->instance)) &client->mi_redist[afi][old_re->type],
|| vrf_bitmap_check( old_re->instance))
client->redist[afi][old_re->type], || vrf_bitmap_check(client->redist[afi][old_re->type],
old_re->vrf_id))) { old_re->vrf_id))) {
zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL, zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
client, p, src_p, old_re); client, p, src_p, old_re);
} }