Skip to content

Commit 6d7b7e4

Browse files
authored
Merge pull request #5095 from donaldsharp/static_fix_for_ROUTE_ALL
ZEBRA_ROUTE_ALL fix
2 parents f3762d2 + 0e965c6 commit 6d7b7e4

File tree

2 files changed

+67
-28
lines changed

2 files changed

+67
-28
lines changed

sharpd/sharp_zebra.c

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)
205205
static void zebra_connected(struct zclient *zclient)
206206
{
207207
zclient_send_reg_requests(zclient, VRF_DEFAULT);
208+
209+
/*
210+
* Do not actually turn this on yet
211+
* This is just the start of the infrastructure needed here
212+
* This can be fixed at a later time.
213+
*
214+
* zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
215+
* ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT);
216+
*/
208217
}
209218

210219
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,
300309
__PRETTY_FUNCTION__);
301310
}
302311

303-
static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)
312+
static int sharp_debug_nexthops(struct zapi_route *api)
304313
{
305-
struct sharp_nh_tracker *nht;
306-
struct zapi_route nhr;
307-
char buf[PREFIX_STRLEN];
308314
int i;
315+
char buf[PREFIX_STRLEN];
309316

310-
if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) {
311-
zlog_warn("%s: Decode of update failed", __PRETTY_FUNCTION__);
312-
313-
return 0;
314-
}
315-
316-
zlog_debug("Received update for %s",
317-
prefix2str(&nhr.prefix, buf, sizeof(buf)));
318-
319-
nht = sharp_nh_tracker_get(&nhr.prefix);
320-
nht->nhop_num = nhr.nexthop_num;
321-
nht->updates++;
322-
323-
for (i = 0; i < nhr.nexthop_num; i++) {
324-
struct zapi_nexthop *znh = &nhr.nexthops[i];
317+
for (i = 0; i < api->nexthop_num; i++) {
318+
struct zapi_nexthop *znh = &api->nexthops[i];
325319

326320
switch (znh->type) {
327321
case NEXTHOP_TYPE_IPV4_IFINDEX:
@@ -351,6 +345,45 @@ static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)
351345
break;
352346
}
353347
}
348+
349+
return i;
350+
}
351+
static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)
352+
{
353+
struct sharp_nh_tracker *nht;
354+
struct zapi_route nhr;
355+
356+
if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) {
357+
zlog_warn("%s: Decode of update failed", __PRETTY_FUNCTION__);
358+
359+
return 0;
360+
}
361+
362+
zlog_debug("Received update for %pFX", &nhr.prefix);
363+
364+
nht = sharp_nh_tracker_get(&nhr.prefix);
365+
nht->nhop_num = nhr.nexthop_num;
366+
nht->updates++;
367+
368+
sharp_debug_nexthops(&nhr);
369+
370+
return 0;
371+
}
372+
373+
static int sharp_redistribute_route(ZAPI_CALLBACK_ARGS)
374+
{
375+
struct zapi_route api;
376+
377+
if (zapi_route_decode(zclient->ibuf, &api) < 0)
378+
zlog_warn("%s: Decode of redistribute failed: %d",
379+
__PRETTY_FUNCTION__,
380+
ZEBRA_REDISTRIBUTE_ROUTE_ADD);
381+
382+
zlog_debug("%s: %pFX (%s)", zserv_command_string(cmd),
383+
&api.prefix, zebra_route_string(api.type));
384+
385+
sharp_debug_nexthops(&api);
386+
354387
return 0;
355388
}
356389

@@ -372,4 +405,7 @@ void sharp_zebra_init(void)
372405
zclient->route_notify_owner = route_notify_owner;
373406
zclient->nexthop_update = sharp_nexthop_update;
374407
zclient->import_check_update = sharp_nexthop_update;
408+
409+
zclient->redistribute_route_add = sharp_redistribute_route;
410+
zclient->redistribute_route_del = sharp_redistribute_route;
375411
}

zebra/redistribute.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,11 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
263263
}
264264

265265
/* Add DISTANCE_INFINITY check. */
266-
if (old_re && (old_re->distance == DISTANCE_INFINITY))
266+
if (old_re && (old_re->distance == DISTANCE_INFINITY)) {
267+
if (IS_ZEBRA_DEBUG_RIB)
268+
zlog_debug("\tSkipping due to Infinite Distance");
267269
return;
270+
}
268271

269272
afi = family2afi(p->family);
270273
if (!afi) {
@@ -310,14 +313,14 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
310313

311314
/* Send a delete for the 'old' re to any subscribed client. */
312315
if (old_re
313-
&& ((old_re->instance
314-
&& redist_check_instance(
315-
&client->mi_redist[afi]
316-
[old_re->type],
317-
old_re->instance))
318-
|| vrf_bitmap_check(
319-
client->redist[afi][old_re->type],
320-
old_re->vrf_id))) {
316+
&& (vrf_bitmap_check(client->redist[afi][ZEBRA_ROUTE_ALL],
317+
old_re->vrf_id)
318+
|| (old_re->instance
319+
&& redist_check_instance(
320+
&client->mi_redist[afi][old_re->type],
321+
old_re->instance))
322+
|| vrf_bitmap_check(client->redist[afi][old_re->type],
323+
old_re->vrf_id))) {
321324
zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
322325
client, p, src_p, old_re);
323326
}

0 commit comments

Comments
 (0)