summaryrefslogtreecommitdiff
path: root/lib/nexthop_group.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2020-05-27 17:39:41 -0400
committerStephen Worley <sworley@cumulusnetworks.com>2020-09-28 12:40:59 -0400
commit0de1db8f3bd8d25be9dbebc3a090f85d60b41b14 (patch)
tree28e12799ca0198a29582c6f005206d5f5b42c792 /lib/nexthop_group.c
parent9c6c48bc101f8f4b47fa9f373e436c85d04608cf (diff)
lib,sharpd,pbrd: `set installable` nhg command
Add a command `set installable` that allows configured nexthop groups to be treated as separate/installable objects in the RIB. A callback needs to be implemented per daemon to handle installing the NHG into the rib via zapi when this command is set. This patch includes the implementation for sharpd. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'lib/nexthop_group.c')
-rw-r--r--lib/nexthop_group.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index 83905abe43..136970cff4 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -54,6 +54,7 @@ struct nexthop_group_hooks {
void (*del_nexthop)(const struct nexthop_group_cmd *nhg,
const struct nexthop *nhop);
void (*delete)(const char *name);
+ void (*installable)(const struct nexthop_group_cmd *nhg);
};
static struct nexthop_group_hooks nhg_hooks;
@@ -675,6 +676,37 @@ DEFPY(no_nexthop_group_backup, no_nexthop_group_backup_cmd,
return CMD_SUCCESS;
}
+DEFPY(set_installable, set_installable_cmd,
+ "set installable",
+ "Set for nexthop-group\n"
+ "Install nexthop-group into RIB as separate object\n")
+{
+ VTY_DECLVAR_CONTEXT(nexthop_group_cmd, nhgc);
+
+ nhgc->installable = true;
+
+ if (nhg_hooks.installable)
+ nhg_hooks.installable(nhgc);
+
+ return CMD_SUCCESS;
+}
+
+DEFPY(no_set_installable, no_set_installable_cmd,
+ "no set installable",
+ NO_STR
+ "Set for nexthop-group\n"
+ "Install nexthop-group into RIB as separate object\n")
+{
+ VTY_DECLVAR_CONTEXT(nexthop_group_cmd, nhgc);
+
+ nhgc->installable = false;
+
+ if (nhg_hooks.installable)
+ nhg_hooks.installable(nhgc);
+
+ return CMD_SUCCESS;
+}
+
static void nexthop_group_save_nhop(struct nexthop_group_cmd *nhgc,
const char *nhvrf_name,
const union sockunion *addr,
@@ -1147,6 +1179,9 @@ static int nexthop_group_write(struct vty *vty)
vty_out(vty, "nexthop-group %s\n", nhgc->name);
+ if (nhgc->installable)
+ vty_out(vty, " set installable\n");
+
if (nhgc->backup_list_name[0])
vty_out(vty, " backup-group %s\n",
nhgc->backup_list_name);
@@ -1316,12 +1351,14 @@ static const struct cmd_variable_handler nhg_name_handlers[] = {
{.tokenname = "NHGNAME", .completions = nhg_name_autocomplete},
{.completions = NULL}};
-void nexthop_group_init(void (*new)(const char *name),
- void (*add_nexthop)(const struct nexthop_group_cmd *nhg,
- const struct nexthop *nhop),
- void (*del_nexthop)(const struct nexthop_group_cmd *nhg,
- const struct nexthop *nhop),
- void (*delete)(const char *name))
+void nexthop_group_init(
+ void (*new)(const char *name),
+ void (*add_nexthop)(const struct nexthop_group_cmd *nhg,
+ const struct nexthop *nhop),
+ void (*del_nexthop)(const struct nexthop_group_cmd *nhg,
+ const struct nexthop *nhop),
+ void (*delete)(const char *name),
+ void (*installable)(const struct nexthop_group_cmd *nhg))
{
RB_INIT(nhgc_entry_head, &nhgc_entries);
@@ -1334,6 +1371,8 @@ void nexthop_group_init(void (*new)(const char *name),
install_default(NH_GROUP_NODE);
install_element(NH_GROUP_NODE, &nexthop_group_backup_cmd);
install_element(NH_GROUP_NODE, &no_nexthop_group_backup_cmd);
+ install_element(NH_GROUP_NODE, &set_installable_cmd);
+ install_element(NH_GROUP_NODE, &no_set_installable_cmd);
install_element(NH_GROUP_NODE, &ecmp_nexthops_cmd);
memset(&nhg_hooks, 0, sizeof(nhg_hooks));
@@ -1346,4 +1385,6 @@ void nexthop_group_init(void (*new)(const char *name),
nhg_hooks.del_nexthop = del_nexthop;
if (delete)
nhg_hooks.delete = delete;
+ if (installable)
+ nhg_hooks.installable = installable;
}