Skip to content

Commit

Permalink
zebra: fix crash with nexthop group group type
Browse files Browse the repository at this point in the history
The following crash happens when ZEBRA attempts to check
if the nexthop of the route has labeled nexthops or not.

> FRRouting#6  0x000055b590b14078 in zebra_rib_labeled_unicast (re=0x55b592b80640) at zebra/zebra_rib.c:671
> FRRouting#7  0x000055b590b14b1a in rib_process_add_fib (zvrf=0x55b592b6a740, rn=0x55b5929f02f0, new=0x55b592b80640) at zebra/zebra_rib.c:994
> FRRouting#8  0x000055b590b15ce9 in rib_process (rn=0x55b5929f02f0) at zebra/zebra_rib.c:1481
> FRRouting#9  0x000055b590b18927 in process_subq_route (lnode=0x55b592b806f0, qindex=8 '\b') at zebra/zebra_rib.c:2653
> FRRouting#10 0x000055b590b1a227 in process_subq (subq=0x55b5928a8d80, qindex=META_QUEUE_BGP) at zebra/zebra_rib.c:3256
> FRRouting#11 0x000055b590b1a30f in meta_queue_process (dummy=0x55b5928a8be0, data=0x55b5928a8c80) at zebra/zebra_rib.c:3295
> FRRouting#12 0x00007fdfd2790368 in work_queue_run (thread=0x7ffd2e913e10) at lib/workqueue.c:282
> FRRouting#13 0x00007fdfd277e5e6 in event_call (thread=0x7ffd2e913e10) at lib/event.c:1974
> FRRouting#14 0x00007fdfd26fcf43 in frr_run (master=0x55b59261aee0) at lib/libfrr.c:1214
> FRRouting#15 0x000055b590a9912b in main (argc=9, argv=0x7ffd2e9140e8) at zebra/main.c:509

When a nexthop group with TYPE_GROUP is used, the dependent
nexthop groups must be used instead.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
  • Loading branch information
pguibert6WIND committed Feb 27, 2024
1 parent 6a32d59 commit f60444b
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions zebra/zebra_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,22 +656,44 @@ struct route_entry *rib_lookup_ipv4(struct prefix_ipv4 *p, vrf_id_t vrf_id)
return NULL;
}

static int _zebra_rib_labeled_unicast(struct nexthop_group *nhg)
{
struct nexthop *nexthop = NULL;

for (ALL_NEXTHOPS_PTR(nhg, nexthop))
if (!nexthop->nh_label || !nexthop->nh_label->num_labels)
return 0;
return 1;
}
/*
* Is this RIB labeled-unicast? It must be of type BGP and all paths
* (nexthops) must have a label.
*/
int zebra_rib_labeled_unicast(struct route_entry *re)
{
struct nexthop *nexthop = NULL;
struct nexthop_group_id *nhgid;
struct nhg_hash_entry *nhe_tmp;

if (re->type != ZEBRA_ROUTE_BGP)
return 0;

for (ALL_NEXTHOPS(re->nhe->nhg, nexthop))
if (!nexthop->nh_label || !nexthop->nh_label->num_labels)
return 0;
if (re->nhe == NULL)
return 0;

return 1;
if (CHECK_FLAG(re->nhe->nhg.flags, NEXTHOP_GROUP_TYPE_GROUP)) {
for (nhgid = re->nhe->nhg.group; nhgid; nhgid = nhgid->next) {
nhe_tmp = zebra_nhg_lookup_id(nhgid->id_grp);
if (nhe_tmp)
nhgid->nhg = &nhe_tmp->nhg;
else
nhgid->nhg = NULL;
if (nhgid->nhg)
if (_zebra_rib_labeled_unicast(nhgid->nhg))
return 1;
}
return 0;
}
return _zebra_rib_labeled_unicast(&re->nhe->nhg);
}


Expand Down

0 comments on commit f60444b

Please sign in to comment.