summaryrefslogtreecommitdiff
path: root/lib/zclient.c
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2023-11-21 10:56:47 -0500
committerGitHub <noreply@github.com>2023-11-21 10:56:47 -0500
commit01af05fbd55edf444d2e39d9de44f5aef2b37719 (patch)
tree16e3d190df7f5b46a2385d528651cac29c649e23 /lib/zclient.c
parentb41f7b1b8e3647dac9826b9768d44c5e80ad1b47 (diff)
parent03c4375a4ac2b7a9837b79ab7d0bd732595ded27 (diff)
Merge pull request #14834 from opensourcerouting/zclient-nexthop-update
*: move common NHT update decoding bits into lib/
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 47d6c5fbaf..a52d092e3b 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -2269,8 +2269,8 @@ const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf,
/*
* Decode the nexthop-tracking update message
*/
-bool zapi_nexthop_update_decode(struct stream *s, struct prefix *match,
- struct zapi_route *nhr)
+static bool zapi_nexthop_update_decode(struct stream *s, struct prefix *match,
+ struct zapi_route *nhr)
{
uint32_t i;
@@ -4298,6 +4298,28 @@ stream_failure:
return -1;
}
+static int zclient_nexthop_update(ZAPI_CALLBACK_ARGS)
+{
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
+ struct prefix match;
+ struct zapi_route route;
+
+ if (!vrf) {
+ zlog_warn("nexthop update for unknown VRF ID %u", vrf_id);
+ return 0;
+ }
+
+ if (!zapi_nexthop_update_decode(zclient->ibuf, &match, &route)) {
+ zlog_err("failed to decode nexthop update");
+ return -1;
+ }
+
+ if (zclient->nexthop_update)
+ zclient->nexthop_update(vrf, &match, &route);
+
+ return 0;
+}
+
static zclient_handler *const lib_handlers[] = {
/* fundamentals */
[ZEBRA_CAPABILITIES] = zclient_capability_decode,
@@ -4311,6 +4333,9 @@ static zclient_handler *const lib_handlers[] = {
[ZEBRA_INTERFACE_UP] = zclient_interface_up,
[ZEBRA_INTERFACE_DOWN] = zclient_interface_down,
+ /* NHT pre-decode */
+ [ZEBRA_NEXTHOP_UPDATE] = zclient_nexthop_update,
+
/* BFD */
[ZEBRA_BFD_DEST_REPLAY] = zclient_bfd_session_replay,
[ZEBRA_INTERFACE_BFD_DEST_UPDATE] = zclient_bfd_session_update,