summaryrefslogtreecommitdiffstats
path: root/sharpd
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2020-09-25 19:48:21 +0200
committerStephen Worley <sworley@cumulusnetworks.com>2020-09-28 18:41:00 +0200
commit21735352987e56f11facdc9fb1f4c53602aba9f6 (patch)
treed085984eacfd352271cb47980c1443db92aa7059 /sharpd
parentlib,sharpd: align zapi NHG apis a bit (diff)
downloadfrr-21735352987e56f11facdc9fb1f4c53602aba9f6.tar.xz
frr-21735352987e56f11facdc9fb1f4c53602aba9f6.zip
lib,zebra,sharpd: add code for backup proto-NHs but disabled
Add the zapi code for encoding/decoding of backup nexthops for when we are ready for it, but disable it for now so that we revert to the old way with them. When zebra gets a proto-NHG with a backup in it, we early fail and tell the upper level proto. In this case sharpd. Sharpd then reverts to the old way of installation with the route. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'sharpd')
-rw-r--r--sharpd/sharp_nht.c12
-rw-r--r--sharpd/sharp_zebra.c19
-rw-r--r--sharpd/sharp_zebra.h3
3 files changed, 30 insertions, 4 deletions
diff --git a/sharpd/sharp_nht.c b/sharpd/sharp_nht.c
index 9f3155272..5b3fe2583 100644
--- a/sharpd/sharp_nht.c
+++ b/sharpd/sharp_nht.c
@@ -133,11 +133,15 @@ static void sharp_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc,
{
struct sharp_nhg lookup;
struct sharp_nhg *snhg;
+ struct nexthop_group_cmd *bnhgc = NULL;
strlcpy(lookup.name, nhgc->name, sizeof(lookup.name));
snhg = sharp_nhg_rb_find(&nhg_head, &lookup);
- nhg_add(snhg->id, &nhgc->nhg);
+ if (nhgc->backup_list_name[0])
+ bnhgc = nhgc_find(nhgc->backup_list_name);
+
+ nhg_add(snhg->id, &nhgc->nhg, (bnhgc ? &bnhgc->nhg : NULL));
}
static void sharp_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhgc,
@@ -145,11 +149,15 @@ static void sharp_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhgc,
{
struct sharp_nhg lookup;
struct sharp_nhg *snhg;
+ struct nexthop_group_cmd *bnhgc = NULL;
strlcpy(lookup.name, nhgc->name, sizeof(lookup.name));
snhg = sharp_nhg_rb_find(&nhg_head, &lookup);
- nhg_add(snhg->id, &nhgc->nhg);
+ if (nhgc->backup_list_name[0])
+ bnhgc = nhgc_find(nhgc->backup_list_name);
+
+ nhg_add(snhg->id, &nhgc->nhg, (bnhgc ? &bnhgc->nhg : NULL));
}
static void sharp_nhgroup_delete_cb(const char *name)
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 50129c236..d167e8e27 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -357,7 +357,8 @@ void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label)
zclient_send_vrf_label(zclient, vrf_id, afi, label, ZEBRA_LSP_SHARP);
}
-void nhg_add(uint32_t id, const struct nexthop_group *nhg)
+void nhg_add(uint32_t id, const struct nexthop_group *nhg,
+ const struct nexthop_group *backup_nhg)
{
struct zapi_nhg api_nhg = {};
struct zapi_nexthop *api_nh;
@@ -378,6 +379,22 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg)
api_nhg.nexthop_num++;
}
+ if (backup_nhg) {
+ for (ALL_NEXTHOPS_PTR(backup_nhg, nh)) {
+ if (api_nhg.backup_nexthop_num >= MULTIPATH_NUM) {
+ zlog_warn(
+ "%s: number of backup nexthops greater than max multipath size, truncating",
+ __func__);
+ break;
+ }
+ api_nh = &api_nhg.backup_nexthops
+ [api_nhg.backup_nexthop_num];
+
+ zapi_backup_nexthop_from_nexthop(api_nh, nh);
+ api_nhg.backup_nexthop_num++;
+ }
+ }
+
zclient_nhg_send(zclient, ZEBRA_NHG_ADD, &api_nhg);
}
diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h
index 69d7343cc..4a767abab 100644
--- a/sharpd/sharp_zebra.h
+++ b/sharpd/sharp_zebra.h
@@ -29,7 +29,8 @@ int sharp_zclient_create(uint32_t session_id);
int sharp_zclient_delete(uint32_t session_id);
extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label);
-extern void nhg_add(uint32_t id, const struct nexthop_group *nhg);
+extern void nhg_add(uint32_t id, const struct nexthop_group *nhg,
+ const struct nexthop_group *backup_nhg);
extern void nhg_del(uint32_t id);
extern void route_add(const struct prefix *p, vrf_id_t, uint8_t instance,
uint32_t nhgid, const struct nexthop_group *nhg,