mirror of
https://github.com/FRRouting/frr.git
synced 2025-05-01 05:57: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_nhg api_nhg = {};
|
||||||
struct zapi_nexthop *api_nh;
|
struct zapi_nexthop *api_nh;
|
||||||
struct nexthop *nh;
|
struct nexthop *nh;
|
||||||
|
bool is_valid = true;
|
||||||
|
|
||||||
api_nhg.id = id;
|
api_nhg.id = id;
|
||||||
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
|
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
|
||||||
|
@ -549,12 +550,25 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
||||||
break;
|
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];
|
api_nh = &api_nhg.nexthops[api_nhg.nexthop_num];
|
||||||
|
|
||||||
zapi_nexthop_from_nexthop(api_nh, nh);
|
zapi_nexthop_from_nexthop(api_nh, nh);
|
||||||
api_nhg.nexthop_num++;
|
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) {
|
if (backup_nhg) {
|
||||||
for (ALL_NEXTHOPS_PTR(backup_nhg, nh)) {
|
for (ALL_NEXTHOPS_PTR(backup_nhg, nh)) {
|
||||||
if (api_nhg.backup_nexthop_num >= MULTIPATH_NUM) {
|
if (api_nhg.backup_nexthop_num >= MULTIPATH_NUM) {
|
||||||
|
@ -563,6 +577,20 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
||||||
__func__);
|
__func__);
|
||||||
break;
|
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_nh = &api_nhg.backup_nexthops
|
||||||
[api_nhg.backup_nexthop_num];
|
[api_nhg.backup_nexthop_num];
|
||||||
|
|
||||||
|
@ -571,7 +599,9 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zclient_nhg_send(zclient, ZEBRA_NHG_ADD, &api_nhg);
|
done:
|
||||||
|
if (is_valid)
|
||||||
|
zclient_nhg_send(zclient, ZEBRA_NHG_ADD, &api_nhg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nhg_del(uint32_t id)
|
void nhg_del(uint32_t id)
|
||||||
|
|
Loading…
Reference in a new issue