diff options
| author | Mark Stapp <mjs@voltanet.io> | 2020-04-02 09:29:36 -0400 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2020-06-01 14:46:12 -0400 |
| commit | 34f86754a20ad1a796430ee9483fce93bc30dfa2 (patch) | |
| tree | 045b372f40b1b6011177511fc71bd70fdc5faef8 /lib/zclient.c | |
| parent | ee70f629792b90f92ea7e6becec2450f37bc191b (diff) | |
lib: add backup nexthop/nhlfe to zapi label messages
Add backup nexthops/nhlfes to the zapi messages used
to convey LSPs to zebra.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 43 |
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; |
