summaryrefslogtreecommitdiff
path: root/lib/zclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index be2c4e54a0..fe0cd3ce27 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -2811,6 +2811,27 @@ int zapi_labels_encode(struct stream *s, int cmd, struct zapi_labels *zl)
return -1;
}
+ if (CHECK_FLAG(zl->message, ZAPI_LABELS_HAS_BACKUPS)) {
+
+ if (zl->backup_nexthop_num > MULTIPATH_NUM) {
+ flog_err(
+ EC_LIB_ZAPI_ENCODE,
+ "%s: label %u: can't encode %u nexthops (maximum is %u)",
+ __func__, zl->local_label, zl->nexthop_num,
+ MULTIPATH_NUM);
+ return -1;
+ }
+ stream_putw(s, zl->backup_nexthop_num);
+
+ for (int i = 0; i < zl->backup_nexthop_num; i++) {
+ znh = &zl->backup_nexthops[i];
+
+ if (zapi_nexthop_encode(s, znh, 0) < 0)
+ return -1;
+ }
+
+ }
+
/* Put length at the first point of the stream. */
stream_putw_at(s, 0, stream_get_endp(s));
@@ -2885,6 +2906,28 @@ int zapi_labels_decode(struct stream *s, struct zapi_labels *zl)
return -1;
}
+ if (CHECK_FLAG(zl->message, ZAPI_LABELS_HAS_BACKUPS)) {
+ STREAM_GETW(s, zl->backup_nexthop_num);
+
+ if (zl->backup_nexthop_num > MULTIPATH_NUM) {
+ flog_warn(
+ EC_LIB_ZAPI_ENCODE,
+ "%s: Prefix %pFX has %d backup nexthops, but we can only use the first %d",
+ __func__, &zl->route.prefix,
+ zl->backup_nexthop_num, MULTIPATH_NUM);
+ }
+
+ zl->backup_nexthop_num = MIN(MULTIPATH_NUM,
+ zl->backup_nexthop_num);
+
+ for (int i = 0; i < zl->backup_nexthop_num; i++) {
+ znh = &zl->backup_nexthops[i];
+
+ if (zapi_nexthop_decode(s, znh, 0) < 0)
+ return -1;
+ }
+ }
+
return 0;
stream_failure:
return -1;