summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Lee <dlqs@gmx.com>2021-08-18 20:31:56 +0800
committerDonald Lee <dlqs@gmx.com>2021-10-20 00:56:00 +0800
commit1247efcce494cc5c4c3bcd5d67b7b2f018d48fb5 (patch)
treedbee27421e172461412930aca29096b8961b729d
parent4f7e32bafee78efe0da315a433e7ca75922fa2f0 (diff)
zebra: Add dplane hook point
Signed-off-by: Donald Lee <dlqs@gmx.com>
-rw-r--r--lib/zebra.h3
-rw-r--r--zebra/zebra_rib.c26
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/zebra.h b/lib/zebra.h
index 6a02dcb922..c9794352c7 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -383,6 +383,9 @@ typedef uint32_t route_tag_t;
#define ROUTE_TAG_MAX UINT32_MAX
#define ROUTE_TAG_PRI PRIu32
+/* Name of hook calls */
+#define ZEBRA_ON_RIB_PROCESS_HOOK_CALL "on_rib_process_dplane_results"
+
#ifdef __cplusplus
}
#endif
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 24c51e485f..c6853a8d4c 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -39,6 +39,7 @@
#include "nexthop_group_private.h"
#include "frr_pthread.h"
#include "printfrr.h"
+#include "frrscript.h"
#include "zebra/zebra_router.h"
#include "zebra/connected.h"
@@ -57,6 +58,7 @@
#include "zebra/zapi_msg.h"
#include "zebra/zebra_dplane.h"
#include "zebra/zebra_evpn_mh.h"
+#include "zebra/zebra_script.h"
DEFINE_MGROUP(ZEBRA, "zebra");
@@ -4134,7 +4136,31 @@ static int rib_process_dplane_results(struct thread *thread)
continue;
}
+#ifdef HAVE_SCRIPTING
+ char *script_name = frrscript_names_get_script_name(
+ ZEBRA_ON_RIB_PROCESS_HOOK_CALL);
+
+ int ret = 1;
+ struct frrscript *fs;
+
+ if (script_name) {
+ fs = frrscript_new(script_name);
+ if (fs)
+ ret = frrscript_load(
+ fs, ZEBRA_ON_RIB_PROCESS_HOOK_CALL,
+ NULL);
+ }
+#endif /* HAVE_SCRIPTING */
+
while (ctx) {
+
+#ifdef HAVE_SCRIPTING
+ if (ret == 0)
+ frrscript_call(fs,
+ ZEBRA_ON_RIB_PROCESS_HOOK_CALL,
+ ("ctx", ctx));
+#endif /* HAVE_SCRIPTING */
+
switch (dplane_ctx_get_op(ctx)) {
case DPLANE_OP_ROUTE_INSTALL:
case DPLANE_OP_ROUTE_UPDATE: