summaryrefslogtreecommitdiffstats
path: root/sharpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2020-11-06 14:19:53 +0100
committerDonald Sharp <sharpd@nvidia.com>2020-11-15 20:50:17 +0100
commit241e5df125ea6fedc69db37ed20fea43fe16a62d (patch)
treeaca539cc7e46310e73357e6c8935690118f7b458 /sharpd
parentbgpd, lib: Indicate when we are buffering instead of immediately sending down... (diff)
downloadfrr-241e5df125ea6fedc69db37ed20fea43fe16a62d.tar.xz
frr-241e5df125ea6fedc69db37ed20fea43fe16a62d.zip
sharpd: Re-arrange route_add|delete
These functions are never called outside of sharp_zebra.c, re-arrange a little to make the inclusions in sharp_zebra.h not needed and to also have these functions return whether or not the underlying buffering system was invoked in stream sending. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'sharpd')
-rw-r--r--sharpd/sharp_zebra.c153
-rw-r--r--sharpd/sharp_zebra.h4
2 files changed, 85 insertions, 72 deletions
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 7a335fca3..bdefad060 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -216,6 +216,91 @@ int sharp_install_lsps_helper(bool install_p, bool update_p,
return ret;
}
+/*
+ * route_add - Encodes a route to zebra
+ *
+ * This function returns true when the route was buffered
+ * by the underlying stream system
+ */
+static bool route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance,
+ uint32_t nhgid, const struct nexthop_group *nhg,
+ const struct nexthop_group *backup_nhg)
+{
+ struct zapi_route api;
+ struct zapi_nexthop *api_nh;
+ struct nexthop *nh;
+ int i = 0;
+
+ memset(&api, 0, sizeof(api));
+ api.vrf_id = vrf_id;
+ api.type = ZEBRA_ROUTE_SHARP;
+ api.instance = instance;
+ api.safi = SAFI_UNICAST;
+ memcpy(&api.prefix, p, sizeof(*p));
+
+ SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
+ SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+
+ /* Only send via ID if nhgroup has been successfully installed */
+ if (nhgid && sharp_nhgroup_id_is_installed(nhgid)) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_NHG);
+ api.nhgid = nhgid;
+ } else {
+ for (ALL_NEXTHOPS_PTR(nhg, nh)) {
+ api_nh = &api.nexthops[i];
+
+ zapi_nexthop_from_nexthop(api_nh, nh);
+
+ i++;
+ }
+ api.nexthop_num = i;
+ }
+
+ /* Include backup nexthops, if present */
+ if (backup_nhg && backup_nhg->nexthop) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_BACKUP_NEXTHOPS);
+
+ i = 0;
+ for (ALL_NEXTHOPS_PTR(backup_nhg, nh)) {
+ api_nh = &api.backup_nexthops[i];
+
+ zapi_backup_nexthop_from_nexthop(api_nh, nh);
+
+ i++;
+ }
+
+ api.backup_nexthop_num = i;
+ }
+
+ if (zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api) == 1)
+ return true;
+ else
+ return false;
+}
+
+/*
+ * route_delete - Encodes a route for deletion to zebra
+ *
+ * This function returns true when the route sent was
+ * buffered by the underlying stream system.
+ */
+static bool route_delete(struct prefix *p, vrf_id_t vrf_id, uint8_t instance)
+{
+ struct zapi_route api;
+
+ memset(&api, 0, sizeof(api));
+ api.vrf_id = vrf_id;
+ api.type = ZEBRA_ROUTE_SHARP;
+ api.safi = SAFI_UNICAST;
+ api.instance = instance;
+ memcpy(&api.prefix, p, sizeof(*p));
+
+ if (zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api) == 1)
+ return true;
+ else
+ return false;
+}
+
void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
uint8_t instance, uint32_t nhgid,
const struct nexthop_group *nhg,
@@ -408,74 +493,6 @@ void nhg_del(uint32_t 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,
- uint32_t nhgid, const struct nexthop_group *nhg,
- const struct nexthop_group *backup_nhg)
-{
- struct zapi_route api;
- struct zapi_nexthop *api_nh;
- struct nexthop *nh;
- int i = 0;
-
- memset(&api, 0, sizeof(api));
- api.vrf_id = vrf_id;
- api.type = ZEBRA_ROUTE_SHARP;
- api.instance = instance;
- api.safi = SAFI_UNICAST;
- memcpy(&api.prefix, p, sizeof(*p));
-
- SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
-
- /* Only send via ID if nhgroup has been successfully installed */
- if (nhgid && sharp_nhgroup_id_is_installed(nhgid)) {
- SET_FLAG(api.message, ZAPI_MESSAGE_NHG);
- api.nhgid = nhgid;
- } else {
- for (ALL_NEXTHOPS_PTR(nhg, nh)) {
- api_nh = &api.nexthops[i];
-
- zapi_nexthop_from_nexthop(api_nh, nh);
-
- i++;
- }
- api.nexthop_num = i;
- }
-
- /* Include backup nexthops, if present */
- if (backup_nhg && backup_nhg->nexthop) {
- SET_FLAG(api.message, ZAPI_MESSAGE_BACKUP_NEXTHOPS);
-
- i = 0;
- for (ALL_NEXTHOPS_PTR(backup_nhg, nh)) {
- api_nh = &api.backup_nexthops[i];
-
- zapi_backup_nexthop_from_nexthop(api_nh, nh);
-
- i++;
- }
-
- api.backup_nexthop_num = i;
- }
-
- zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
-}
-
-void route_delete(struct prefix *p, vrf_id_t vrf_id, uint8_t instance)
-{
- struct zapi_route api;
-
- memset(&api, 0, sizeof(api));
- api.vrf_id = vrf_id;
- api.type = ZEBRA_ROUTE_SHARP;
- api.safi = SAFI_UNICAST;
- api.instance = instance;
- memcpy(&api.prefix, p, sizeof(*p));
- zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
-
- return;
-}
-
void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import,
bool watch, bool connected)
{
diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h
index 4a767abab..8c5fa5e15 100644
--- a/sharpd/sharp_zebra.h
+++ b/sharpd/sharp_zebra.h
@@ -32,10 +32,6 @@ 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,
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,
- const struct nexthop_group *backup_nhg);
-extern void route_delete(struct prefix *p, vrf_id_t vrf_id, uint8_t instance);
extern void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id,
bool import, bool watch, bool connected);