summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-03-07 18:15:30 -0500
committerStephen Worley <sworley@cumulusnetworks.com>2019-10-25 11:13:37 -0400
commit5f3c9e520c71993ca65a9aaafd9db715eda0b2e5 (patch)
tree390ed9245272dbd4e3e0cfdb4132c802b603e794
parent147bad16b96824a3e881650ff89196ddd988ab7f (diff)
zebra: Add dataplane process result function for nexthops
Add a function that can handle the results of a dataplane ctx status, dpending on the operation performed. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
-rw-r--r--zebra/zebra_nhg.c77
-rw-r--r--zebra/zebra_nhg.h4
2 files changed, 80 insertions, 1 deletions
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index e876a99b69..2ac8678e12 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -36,7 +36,6 @@
#include "zebra/zebra_routemap.h"
#include "zebra/rt.h"
#include "zebra_errors.h"
-#include "zebra_dplane.h"
/**
* zebra_nhg_lookup_id() - Lookup the nexthop group id in the id table
@@ -898,6 +897,82 @@ void zebra_nhg_uninstall_kernel(struct nhg_hash_entry *nhe)
}
}
+/**
+ * zebra_nhg_dplane_result() - Process dplane result
+ *
+ * @ctx: Dataplane context
+ */
+void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
+{
+ enum dplane_op_e op;
+ enum zebra_dplane_result status;
+ uint32_t id = 0;
+ struct nhg_hash_entry *nhe = NULL;
+
+ op = dplane_ctx_get_op(ctx);
+ status = dplane_ctx_get_status(ctx);
+
+ id = dplane_ctx_get_nhe(ctx)->id;
+ nhe = zebra_nhg_lookup_id(id);
+
+ if (nhe) {
+ if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
+ zlog_debug(
+ "Nexthop dplane ctx %p, op %s, nexthop ID (%u), result %s",
+ ctx, dplane_op2str(op), nhe->id,
+ dplane_res2str(status));
+
+ switch (op) {
+ case DPLANE_OP_NH_DELETE:
+ if (status == ZEBRA_DPLANE_REQUEST_SUCCESS) {
+ UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
+ zebra_nhg_release(nhe);
+ } else {
+ flog_err(
+ EC_ZEBRA_DP_DELETE_FAIL,
+ "Failed to uninstall Nexthop ID (%u) from the kernel",
+ nhe->id);
+ }
+ break;
+ case DPLANE_OP_NH_INSTALL:
+ case DPLANE_OP_NH_UPDATE:
+ if (status == ZEBRA_DPLANE_REQUEST_SUCCESS) {
+ SET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
+ } else {
+ flog_err(
+ EC_ZEBRA_DP_INSTALL_FAIL,
+ "Failed to install Nexthop ID (%u) into the kernel",
+ nhe->id);
+ UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
+ }
+ UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED);
+ break;
+ case DPLANE_OP_ROUTE_INSTALL:
+ case DPLANE_OP_ROUTE_UPDATE:
+ case DPLANE_OP_ROUTE_DELETE:
+ case DPLANE_OP_ROUTE_NOTIFY:
+ case DPLANE_OP_LSP_INSTALL:
+ case DPLANE_OP_LSP_UPDATE:
+ case DPLANE_OP_LSP_DELETE:
+ case DPLANE_OP_LSP_NOTIFY:
+ case DPLANE_OP_PW_INSTALL:
+ case DPLANE_OP_PW_UNINSTALL:
+ case DPLANE_OP_SYS_ROUTE_ADD:
+ case DPLANE_OP_SYS_ROUTE_DELETE:
+ case DPLANE_OP_ADDR_INSTALL:
+ case DPLANE_OP_ADDR_UNINSTALL:
+ case DPLANE_OP_MAC_INSTALL:
+ case DPLANE_OP_MAC_DELETE:
+ case DPLANE_OP_NONE:
+ break;
+ }
+ dplane_ctx_fini(&ctx);
+
+ } else {
+ flog_err(
+ EC_ZEBRA_NHG_SYNC,
+ "%s operation preformed on Nexthop ID (%u) in the kernel, that we no longer have in our table",
+ dplane_op2str(op), id);
}
}
diff --git a/zebra/zebra_nhg.h b/zebra/zebra_nhg.h
index 8ecb9d0636..a7a97f5529 100644
--- a/zebra/zebra_nhg.h
+++ b/zebra/zebra_nhg.h
@@ -26,6 +26,8 @@
#include "zebra/rib.h"
#include "lib/nexthop_group.h"
+#include "zebra/zebra_dplane.h"
+
struct nhg_hash_entry {
uint32_t id;
vrf_id_t vrf_id;
@@ -83,4 +85,6 @@ void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe);
void zebra_nhg_uninstall_kernel(struct nhg_hash_entry *nhe);
void zebra_nhg_cleanup_tables(void);
+
+void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx);
#endif