summaryrefslogtreecommitdiffstats
path: root/sharpd
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2020-09-22 21:27:35 +0200
committerStephen Worley <sworley@cumulusnetworks.com>2020-09-28 18:41:00 +0200
commitc6ce9334b5387f482af4112ed1ffe6a49debe352 (patch)
treef9e2a98bce9af2b94ed49d8a407d96a30428fde5 /sharpd
parentzebra: add type to nhg_prot_del API for sanity check (diff)
downloadfrr-c6ce9334b5387f482af4112ed1ffe6a49debe352.tar.xz
frr-c6ce9334b5387f482af4112ed1ffe6a49debe352.zip
lib,sharpd: align zapi NHG apis a bit
Align the zapi NHG apis to be more consistent with the zapi_route apis. Add a struct zapi_nhg to use for encodings as well. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'sharpd')
-rw-r--r--sharpd/sharp_zebra.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index edbc7460e..50129c236 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -359,34 +359,35 @@ void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label)
void nhg_add(uint32_t id, const struct nexthop_group *nhg)
{
- struct zapi_nexthop nh_array[MULTIPATH_NUM];
+ struct zapi_nhg api_nhg = {};
struct zapi_nexthop *api_nh;
- uint16_t nexthop_num = 0;
struct nexthop *nh;
+ api_nhg.id = id;
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
- if (nexthop_num >= MULTIPATH_NUM) {
+ if (api_nhg.nexthop_num >= MULTIPATH_NUM) {
zlog_warn(
"%s: number of nexthops greater than max multipath size, truncating",
__func__);
break;
}
- api_nh = &nh_array[nexthop_num];
+ api_nh = &api_nhg.nexthops[api_nhg.nexthop_num];
zapi_nexthop_from_nexthop(api_nh, nh);
- nexthop_num++;
+ api_nhg.nexthop_num++;
}
- zclient_nhg_add(zclient, id, nexthop_num, nh_array);
-
- zclient_send_message(zclient);
+ zclient_nhg_send(zclient, ZEBRA_NHG_ADD, &api_nhg);
}
void nhg_del(uint32_t id)
{
- zclient_nhg_del(zclient, id);
- zclient_send_message(zclient);
+ struct zapi_nhg api_nhg = {};
+
+ api_nhg.id = id;
+
+ zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg);
}
void route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance,