From 7bec514c7e42649b0c153fda9f66b5b52ce1de43 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 12 Jun 2018 17:49:29 +0000 Subject: [PATCH] pbrd: allow configurable table id range Signed-off-by: Quentin Young --- pbrd/pbr_vty.c | 30 ++++++++++++++++++++++++++++-- pbrd/pbr_vty.h | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 7e0e8d632..79d42a42c 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -85,6 +85,33 @@ DEFUN_NOSH(no_pbr_map, no_pbr_map_cmd, "no pbr-map WORD [seq (1-700)]", return CMD_SUCCESS; } +DEFPY(pbr_set_table_range, + pbr_set_table_range_cmd, + "[no] pbr table range (10000-4294966272)$lb (10000-4294966272)$ub", + NO_STR + PBR_STR + "Set table ID range\n" + "Set table ID range\n" + "Lower bound for table ID range\n" + "Upper bound for table ID range\n") +{ + /* upper bound is 2^32 - 2^10 */ + int ret = CMD_WARNING; + + /* validate given bounds */ + if (lb > ub) + vty_out(vty, "%% Lower bound must be less than upper bound\n"); + else if (ub - lb < 10) + vty_out(vty, "%% Range breadth must be at least 10\n"); + else { + ret = CMD_SUCCESS; + pbr_nht_set_tableid_range((uint32_t) lb, (uint32_t) ub); + } + + return ret; +} + + DEFPY(pbr_map_match_src, pbr_map_match_src_cmd, "[no] match src-ip $prefix", NO_STR @@ -489,7 +516,6 @@ DEFPY (show_pbr_interface, } /* PBR debugging CLI ------------------------------------------------------- */ -/* clang-format off */ static struct cmd_node debug_node = {DEBUG_NODE, "", 1}; @@ -536,7 +562,6 @@ DEFUN_NOSH(show_debugging_pbr, return CMD_SUCCESS; } -/* clang-format on */ /* ------------------------------------------------------------------------- */ @@ -634,6 +659,7 @@ void pbr_vty_init(void) install_element(CONFIG_NODE, &pbr_map_cmd); install_element(CONFIG_NODE, &no_pbr_map_cmd); + install_element(CONFIG_NODE, &pbr_set_table_range_cmd); install_element(INTERFACE_NODE, &pbr_policy_cmd); install_element(PBRMAP_NODE, &pbr_map_match_src_cmd); install_element(PBRMAP_NODE, &pbr_map_match_dst_cmd); diff --git a/pbrd/pbr_vty.h b/pbrd/pbr_vty.h index 6e345fd7e..5a1d606e5 100644 --- a/pbrd/pbr_vty.h +++ b/pbrd/pbr_vty.h @@ -20,5 +20,7 @@ #ifndef __PBR_VTY_H__ #define __PBR_VTY_H__ +#define PBR_STR "Policy based routing\n" + extern void pbr_vty_init(void); #endif -- 2.39.2