summaryrefslogtreecommitdiffstats
path: root/sharpd
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2021-01-20 22:00:45 +0100
committerMark Stapp <mjs@voltanet.io>2021-01-21 16:13:57 +0100
commit5a9c0931aa9571b875db8658ced6f1dc6f10a2b1 (patch)
tree4298a69e75cadb1c5b3d64f0473fbd682a217e80 /sharpd
parentzebra: use afi_t for route-map address family arg (diff)
downloadfrr-5a9c0931aa9571b875db8658ced6f1dc6f10a2b1.tar.xz
frr-5a9c0931aa9571b875db8658ced6f1dc6f10a2b1.zip
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>
Diffstat (limited to 'sharpd')
-rw-r--r--sharpd/sharp_zebra.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 4445bc013..fed732b84 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -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,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)