mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 17:40:04 +00:00
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>
This commit is contained in:
parent
ee70f62979
commit
34f86754a2
@ -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;
|
||||
|
@ -484,7 +484,8 @@ struct zapi_route {
|
||||
|
||||
struct zapi_labels {
|
||||
uint8_t message;
|
||||
#define ZAPI_LABELS_FTN 0x01
|
||||
#define ZAPI_LABELS_FTN 0x01
|
||||
#define ZAPI_LABELS_HAS_BACKUPS 0x02
|
||||
enum lsp_types_t type;
|
||||
mpls_label_t local_label;
|
||||
struct {
|
||||
@ -495,6 +496,10 @@ struct zapi_labels {
|
||||
|
||||
uint16_t nexthop_num;
|
||||
struct zapi_nexthop nexthops[MULTIPATH_NUM];
|
||||
|
||||
/* Backup nexthops, if present */
|
||||
uint16_t backup_nexthop_num;
|
||||
struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
|
||||
};
|
||||
|
||||
struct zapi_pw {
|
||||
|
Loading…
Reference in New Issue
Block a user