summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2022-10-24 15:09:23 +0200
committerDonald Sharp <sharpd@nvidia.com>2022-11-04 18:34:27 +0100
commitf0f618dcdbcd70047897109851b61ded5a63d5e8 (patch)
tree10906516f5e23dfab9a61292a922df14e1e65980
parentlib, zebra: Add ability to encode/decode resilient nhg's (diff)
downloadfrr-f0f618dcdbcd70047897109851b61ded5a63d5e8.tar.xz
frr-f0f618dcdbcd70047897109851b61ded5a63d5e8.zip
lib, vtysh: Add ability to specify resilient nhgs
Add the ability to specify a resilient nexthop group nexthop-group A resilient buckets 32 idle_timer 100 unbalanced_timer 500 nexthop 192.168.100.1 enp7s0 nexthop 192.168.100.33 enp7s0 nexthop 192.168.122.1 enp1s0 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
-rw-r--r--lib/nexthop_group.c51
-rw-r--r--vtysh/vtysh_config.c22
2 files changed, 68 insertions, 5 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index f6479f8d2..f1417021b 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -674,6 +674,47 @@ DEFPY(no_nexthop_group_backup, no_nexthop_group_backup_cmd,
return CMD_SUCCESS;
}
+DEFPY(nexthop_group_resilience,
+ nexthop_group_resilience_cmd,
+ "resilient buckets (1-256) idle-timer (1-4294967295) unbalanced-timer (1-4294967295)",
+ "A resilient Nexthop Group\n"
+ "Buckets in the Hash for this Group\n"
+ "Number of buckets\n"
+ "The Idle timer for this Resilient Nexthop Group in seconds\n"
+ "Number of seconds of Idle time\n"
+ "The length of time that the Nexthop Group can be unbalanced\n"
+ "Number of seconds of Unbalanced time\n")
+{
+ VTY_DECLVAR_CONTEXT(nexthop_group_cmd, nhgc);
+
+ nhgc->nhg.nhgr.buckets = buckets;
+ nhgc->nhg.nhgr.idle_timer = idle_timer;
+ nhgc->nhg.nhgr.unbalanced_timer = unbalanced_timer;
+
+ return CMD_SUCCESS;
+}
+
+DEFPY(no_nexthop_group_resilience,
+ no_nexthop_group_resilience_cmd,
+ "no resilient [buckets (1-256) idle-timer (1-4294967295) unbalanced-timer (1-4294967295)]",
+ NO_STR
+ "A resilient Nexthop Group\n"
+ "Buckets in the Hash for this Group\n"
+ "Number of buckets\n"
+ "The Idle timer for this Resilient Nexthop Group in seconds\n"
+ "Number of seconds of Idle time\n"
+ "The length of time that the Nexthop Group can be unbalanced\n"
+ "Number of seconds of Unbalanced time\n")
+{
+ VTY_DECLVAR_CONTEXT(nexthop_group_cmd, nhgc);
+
+ nhgc->nhg.nhgr.buckets = 0;
+ nhgc->nhg.nhgr.idle_timer = 0;
+ nhgc->nhg.nhgr.unbalanced_timer = 0;
+
+ return CMD_SUCCESS;
+}
+
static void nexthop_group_save_nhop(struct nexthop_group_cmd *nhgc,
const char *nhvrf_name,
const union sockunion *addr,
@@ -1129,6 +1170,13 @@ static int nexthop_group_write(struct vty *vty)
vty_out(vty, "nexthop-group %s\n", nhgc->name);
+ if (nhgc->nhg.nhgr.buckets)
+ vty_out(vty,
+ " resilient buckets %u idle-timer %u unbalanced-timer %u\n",
+ nhgc->nhg.nhgr.buckets,
+ nhgc->nhg.nhgr.idle_timer,
+ nhgc->nhg.nhgr.unbalanced_timer);
+
if (nhgc->backup_list_name[0])
vty_out(vty, " backup-group %s\n",
nhgc->backup_list_name);
@@ -1318,6 +1366,9 @@ void nexthop_group_init(void (*new)(const char *name),
install_element(NH_GROUP_NODE, &no_nexthop_group_backup_cmd);
install_element(NH_GROUP_NODE, &ecmp_nexthops_cmd);
+ install_element(NH_GROUP_NODE, &nexthop_group_resilience_cmd);
+ install_element(NH_GROUP_NODE, &no_nexthop_group_resilience_cmd);
+
memset(&nhg_hooks, 0, sizeof(nhg_hooks));
if (new)
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index 1ebc84b35..ac0cdc6ff 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -261,6 +261,11 @@ static void config_add_line_uniq_end(struct list *config, const char *line)
listnode_move_to_tail(config, node);
}
+static void config_add_line_head(struct list *config, const char *line)
+{
+ listnode_add_head(config, XSTRDUP(MTYPE_VTYSH_CONFIG_LINE, line));
+}
+
void vtysh_config_parse_line(void *arg, const char *line)
{
char c;
@@ -324,12 +329,19 @@ void vtysh_config_parse_line(void *arg, const char *line)
} else if (!strncmp(line, " ip mroute",
strlen(" ip mroute"))) {
config_add_line_uniq_end(config->line, line);
- } else if (config->index == RMAP_NODE
- || config->index == INTERFACE_NODE
- || config->index == VTY_NODE
- || config->index == NH_GROUP_NODE)
+ } else if (config->index == RMAP_NODE ||
+ config->index == INTERFACE_NODE ||
+ config->index == VTY_NODE)
config_add_line_uniq(config->line, line);
- else
+ else if (config->index == NH_GROUP_NODE) {
+ if (strncmp(line, " resilient",
+ strlen(" resilient")) == 0)
+ config_add_line_head(config->line,
+ line);
+ else
+ config_add_line_uniq_end(config->line,
+ line);
+ } else
config_add_line(config->line, line);
} else
config_add_line(config_top, line);