zebra: Add function to install a nhe into the kernel

Add a function for installing Nexthop Group hash entires into
the kernel. It sends the entry to the dataplane and does any
post-processing immediately after that.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
Stephen Worley 2019-03-06 14:58:57 -05:00
parent 7f6077d063
commit 5be96a2d3a
2 changed files with 27 additions and 0 deletions

View File

@ -36,6 +36,7 @@
#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
@ -845,3 +846,27 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re)
return curr_active;
}
/**
* zebra_nhg_install_kernel() - Install Nexthop Group hash entry into kernel
*
* @nhe: Nexthop Group hash entry to install
*/
void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe)
{
int ret = dplane_nexthop_add(nhe);
switch (ret) {
case ZEBRA_DPLANE_REQUEST_QUEUED:
SET_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED);
break;
case ZEBRA_DPLANE_REQUEST_FAILURE:
flog_err(EC_ZEBRA_DP_INSTALL_FAIL,
"Failed to install Nexthop ID (%u) into the kernel",
nhe->id);
break;
case ZEBRA_DPLANE_REQUEST_SUCCESS:
SET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
break;
}
}

View File

@ -78,4 +78,6 @@ void zebra_nhg_release(struct nhg_hash_entry *nhe);
void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe);
extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);
void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe);
#endif