diff options
Diffstat (limited to 'pbrd/pbr_vty.c')
| -rw-r--r-- | pbrd/pbr_vty.c | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 7e0e8d632b..44e14c5477 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -26,8 +26,8 @@ #include "nexthop.h" #include "nexthop_group.h" #include "log.h" -#include "json.h" #include "debug.h" +#include "pbr.h" #include "pbrd/pbr_nht.h" #include "pbrd/pbr_map.h" @@ -85,6 +85,34 @@ 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; + const int minrange = 1000; + + /* validate given bounds */ + if (lb > ub) + vty_out(vty, "%% Lower bound must be less than upper bound\n"); + else if (ub - lb < minrange) + vty_out(vty, "%% Range breadth must be at least %d\n", minrange); + 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 <A.B.C.D/M|X:X::X:X/M>$prefix", NO_STR @@ -355,10 +383,9 @@ DEFPY (pbr_policy, DEFPY (show_pbr, show_pbr_cmd, - "show pbr [json$json]", + "show pbr", SHOW_STR - "Policy Based Routing\n" - JSON_STR) + PBR_STR) { pbr_nht_write_table_range(vty); pbr_nht_write_rule_range(vty); @@ -368,13 +395,12 @@ DEFPY (show_pbr, DEFPY (show_pbr_map, show_pbr_map_cmd, - "show pbr map [NAME$name] [detail$detail] [json$json]", + "show pbr map [NAME$name] [detail$detail]", SHOW_STR - "Policy Based Routing\n" + PBR_STR "PBR Map\n" "PBR Map Name\n" - "Detailed information\n" - JSON_STR) + "Detailed information\n") { struct pbr_map_sequence *pbrms; struct pbr_map *pbrm; @@ -439,7 +465,7 @@ DEFPY(show_pbr_nexthop_group, show_pbr_nexthop_group_cmd, "show pbr nexthop-groups [WORD$word]", SHOW_STR - "Policy Based Routing\n" + PBR_STR "Nexthop Groups\n" "Optional Name of the nexthop group\n") { @@ -450,12 +476,11 @@ DEFPY(show_pbr_nexthop_group, DEFPY (show_pbr_interface, show_pbr_interface_cmd, - "show pbr interface [NAME$name] [json$json]", + "show pbr interface [NAME$name]", SHOW_STR - "Policy Based Routing\n" + PBR_STR "PBR Interface\n" - "PBR Interface Name\n" - JSON_STR) + "PBR Interface Name\n") { struct interface *ifp; struct vrf *vrf; @@ -489,7 +514,6 @@ DEFPY (show_pbr_interface, } /* PBR debugging CLI ------------------------------------------------------- */ -/* clang-format off */ static struct cmd_node debug_node = {DEBUG_NODE, "", 1}; @@ -498,7 +522,7 @@ DEFPY(debug_pbr, "[no] debug pbr [{map$map|zebra$zebra|nht$nht|events$events}]", NO_STR DEBUG_STR - "Policy Based Routing\n" + PBR_STR "Policy maps\n" "PBRD <-> Zebra communications\n" "Nexthop tracking\n" @@ -527,7 +551,7 @@ DEFUN_NOSH(show_debugging_pbr, "show debugging [pbr]", SHOW_STR DEBUG_STR - "Policy Based Routing\n") + PBR_STR) { vty_out(vty, "PBR debugging status:\n"); @@ -536,7 +560,6 @@ DEFUN_NOSH(show_debugging_pbr, return CMD_SUCCESS; } -/* clang-format on */ /* ------------------------------------------------------------------------- */ @@ -634,6 +657,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); |
