mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 21:47:15 +02:00
sharpd: don't send invalid nexthop-groups to zebra
Ensure that there are valid (resolved) nexthops, and no invalid backup nexthops, in nhgs sent to zebra for installation. Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
parent
f5b7e50f9a
commit
5a9c0931aa
|
@ -539,6 +539,7 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
|||
struct zapi_nhg api_nhg = {};
|
||||
struct zapi_nexthop *api_nh;
|
||||
struct nexthop *nh;
|
||||
bool is_valid = true;
|
||||
|
||||
api_nhg.id = id;
|
||||
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
|
||||
|
@ -549,12 +550,25 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
|||
break;
|
||||
}
|
||||
|
||||
/* Unresolved nexthops will lead to failure - only send
|
||||
* nexthops that zebra will consider valid.
|
||||
*/
|
||||
if (nh->ifindex == 0)
|
||||
continue;
|
||||
|
||||
api_nh = &api_nhg.nexthops[api_nhg.nexthop_num];
|
||||
|
||||
zapi_nexthop_from_nexthop(api_nh, nh);
|
||||
api_nhg.nexthop_num++;
|
||||
}
|
||||
|
||||
if (api_nhg.nexthop_num == 0) {
|
||||
zlog_debug("%s: nhg %u not sent: no valid nexthops",
|
||||
__func__, id);
|
||||
is_valid = false;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (backup_nhg) {
|
||||
for (ALL_NEXTHOPS_PTR(backup_nhg, nh)) {
|
||||
if (api_nhg.backup_nexthop_num >= MULTIPATH_NUM) {
|
||||
|
@ -563,6 +577,20 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
|||
__func__);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Unresolved nexthop: will be rejected by zebra.
|
||||
* That causes a problem, since the primary nexthops
|
||||
* rely on array indexing into the backup nexthops. If
|
||||
* that array isn't valid, the backup indexes won't be
|
||||
* valid.
|
||||
*/
|
||||
if (nh->ifindex == 0) {
|
||||
zlog_debug("%s: nhg %u: invalid backup nexthop",
|
||||
__func__, id);
|
||||
is_valid = false;
|
||||
break;
|
||||
}
|
||||
|
||||
api_nh = &api_nhg.backup_nexthops
|
||||
[api_nhg.backup_nexthop_num];
|
||||
|
||||
|
@ -571,6 +599,8 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
|||
}
|
||||
}
|
||||
|
||||
done:
|
||||
if (is_valid)
|
||||
zclient_nhg_send(zclient, ZEBRA_NHG_ADD, &api_nhg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue