From 235bcb4b4aa8fdf12ef91858968e30daba492177 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Mon, 1 Mar 2021 10:48:05 -0500 Subject: [PATCH] zebra: add config control to hide backup nh events in nht Add a config that can control hiding of backup-nexthop activation changes in nexthop-tracking. Signed-off-by: Mark Stapp --- zebra/zebra_rnh.c | 18 ++++++++++++++++++ zebra/zebra_rnh.h | 4 ++++ zebra/zebra_vty.c | 17 ++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 5e2e6f6ce4..a4382441c8 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -52,6 +52,11 @@ DEFINE_MTYPE_STATIC(ZEBRA, RNH, "Nexthop tracking object"); +/* UI controls whether to notify about changes that only involve backup + * nexthops. Default is to notify all changes. + */ +static bool rnh_hide_backups; + static void free_state(vrf_id_t vrf_id, struct route_entry *re, struct route_node *rn); static void copy_state(struct rnh *rnh, const struct route_entry *re, @@ -1504,3 +1509,16 @@ int rnh_resolve_via_default(struct zebra_vrf *zvrf, int family) else return 0; } + +/* + * UI control to avoid notifications if backup nexthop status changes + */ +void rnh_set_hide_backups(bool hide_p) +{ + rnh_hide_backups = hide_p; +} + +bool rnh_get_hide_backups(void) +{ + return rnh_hide_backups; +} diff --git a/zebra/zebra_rnh.h b/zebra/zebra_rnh.h index c71a2b9cce..4897a6af30 100644 --- a/zebra/zebra_rnh.h +++ b/zebra/zebra_rnh.h @@ -64,6 +64,10 @@ extern void zebra_print_rnh_table(vrf_id_t vrfid, afi_t afi, struct vty *vty, extern int rnh_resolve_via_default(struct zebra_vrf *zvrf, int family); +/* UI control to avoid notifications if backup nexthop status changes */ +void rnh_set_hide_backups(bool hide_p); +bool rnh_get_hide_backups(void); + #ifdef __cplusplus } #endif diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 8061f34d2b..7859460e61 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1701,7 +1701,6 @@ DEFUN (no_ipv6_nht_default_route, "Filter Next Hop tracking route resolution\n" "Resolve via default route\n") { - ZEBRA_DECLVAR_CONTEXT(vrf, zvrf); if (!zvrf) @@ -1715,6 +1714,17 @@ DEFUN (no_ipv6_nht_default_route, return CMD_SUCCESS; } +DEFPY_HIDDEN(rnh_hide_backups, rnh_hide_backups_cmd, + "[no] ip nht hide-backup-events", + NO_STR + IP_STR + "Nexthop-tracking configuration\n" + "Hide notification about backup nexthops\n") +{ + rnh_set_hide_backups(!no); + return CMD_SUCCESS; +} + DEFPY (show_route, show_route_cmd, "show\ @@ -3661,6 +3671,9 @@ static int config_write_protocol(struct vty *vty) if (!zebra_nhg_recursive_use_backups()) vty_out(vty, "no zebra nexthop resolve-via-backup\n"); + if (rnh_get_hide_backups()) + vty_out(vty, "ip nht hide-backup-events\n"); + #ifdef HAVE_NETLINK /* Include netlink info */ netlink_config_write_helper(vty); @@ -4120,6 +4133,8 @@ void zebra_vty_init(void) install_element(VRF_NODE, &no_ip_nht_default_route_cmd); install_element(VRF_NODE, &ipv6_nht_default_route_cmd); install_element(VRF_NODE, &no_ipv6_nht_default_route_cmd); + install_element(CONFIG_NODE, &rnh_hide_backups_cmd); + install_element(VIEW_NODE, &show_ipv6_mroute_cmd); /* Commands for VRF */ -- 2.39.5