diff options
| author | Mark Stapp <mjs@voltanet.io> | 2020-04-09 13:53:38 -0400 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2020-06-01 14:46:32 -0400 |
| commit | 665edffd1e47e46b292b362e23125f6057c8a85f (patch) | |
| tree | 61e5fe839bf4039813830de0e7a4a5ed3a15f7a9 /sharpd/sharp_zebra.c | |
| parent | ae076fc276a22b2a5331b066964901e65034e73c (diff) | |
sharpd: include backup nh info with lsps
If present in a configured nexthop_group, include
backup nexthop/nhlfe info with LSP zapi add/update
messages.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'sharpd/sharp_zebra.c')
| -rw-r--r-- | sharpd/sharp_zebra.c | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index e1bd6f5722..0795096440 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -89,7 +89,8 @@ static int sharp_ifp_down(struct interface *ifp) int sharp_install_lsps_helper(bool install_p, const struct prefix *p, uint8_t type, int instance, uint32_t in_label, - const struct nexthop_group *nhg) + const struct nexthop_group *nhg, + const struct nexthop_group *backup_nhg) { struct zapi_labels zl = {}; struct zapi_nexthop *znh; @@ -106,32 +107,68 @@ int sharp_install_lsps_helper(bool install_p, const struct prefix *p, zl.route.instance = instance; } + /* List of nexthops is optional for delete */ i = 0; - for (ALL_NEXTHOPS_PTR(nhg, nh)) { - znh = &zl.nexthops[i]; + if (nhg) { + for (ALL_NEXTHOPS_PTR(nhg, nh)) { + znh = &zl.nexthops[i]; - /* Must have labels to be useful */ - if (nh->nh_label == NULL || nh->nh_label->num_labels == 0) - continue; + /* Must have labels to be useful */ + if (nh->nh_label == NULL || + nh->nh_label->num_labels == 0) + continue; - if (nh->type == NEXTHOP_TYPE_IFINDEX || - nh->type == NEXTHOP_TYPE_BLACKHOLE) - /* Hmm - can't really deal with these types */ - continue; + if (nh->type == NEXTHOP_TYPE_IFINDEX || + nh->type == NEXTHOP_TYPE_BLACKHOLE) + /* Hmm - can't really deal with these types */ + continue; - ret = zapi_nexthop_from_nexthop(znh, nh); - if (ret < 0) - return -1; + ret = zapi_nexthop_from_nexthop(znh, nh); + if (ret < 0) + return -1; - i++; + i++; + } } - /* Whoops - no nexthops isn't very useful */ - if (i == 0) + /* Whoops - no nexthops isn't very useful for install */ + if (i == 0 && install_p) return -1; zl.nexthop_num = i; + /* Add optional backup nexthop info. Since these are used by index, + * we can't just skip over an invalid backup nexthop: we will + * invalidate the entire operation. + */ + if (backup_nhg != NULL) { + i = 0; + for (ALL_NEXTHOPS_PTR(backup_nhg, nh)) { + znh = &zl.backup_nexthops[i]; + + /* Must have labels to be useful */ + if (nh->nh_label == NULL || + nh->nh_label->num_labels == 0) + return -1; + + if (nh->type == NEXTHOP_TYPE_IFINDEX || + nh->type == NEXTHOP_TYPE_BLACKHOLE) + /* Hmm - can't really deal with these types */ + return -1; + + ret = zapi_nexthop_from_nexthop(znh, nh); + if (ret < 0) + return -1; + + i++; + } + + if (i > 0) + SET_FLAG(zl.message, ZAPI_LABELS_HAS_BACKUPS); + + zl.backup_nexthop_num = i; + } + if (install_p) ret = zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_ADD, &zl); |
