summaryrefslogtreecommitdiff
path: root/zebra/zebra_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_vty.c')
-rw-r--r--zebra/zebra_vty.c72
1 files changed, 56 insertions, 16 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 78001da170..86ec2ffef3 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -1123,9 +1123,11 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
vty_out(vty, " RefCnt: %d\n", nhe->refcnt);
if (nhe_vrf)
- vty_out(vty, " VRF: %s\n", nhe_vrf->name);
+ vty_out(vty, " VRF: %s AFI: %s\n", nhe_vrf->name,
+ afi2str(nhe->afi));
else
- vty_out(vty, " VRF: UNKNOWN\n");
+ vty_out(vty, " VRF: UNKNOWN AFI: %s\n",
+ afi2str(nhe->afi));
if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_UNHASHABLE))
vty_out(vty, " Duplicate - from kernel not hashable\n");
@@ -1276,25 +1278,44 @@ static int show_nexthop_group_id_cmd_helper(struct vty *vty, uint32_t id)
return CMD_SUCCESS;
}
-static void show_nexthop_group_cmd_helper(struct vty *vty,
- struct zebra_vrf *zvrf, afi_t afi)
+/* Helper function for iteration through the hash of nexthop-groups/nhe-s */
+
+struct nhe_show_context {
+ struct vty *vty;
+ vrf_id_t vrf_id;
+ afi_t afi;
+};
+
+static int nhe_show_walker(struct hash_bucket *bucket, void *arg)
{
- struct list *list = hash_to_list(zrouter.nhgs);
- struct nhg_hash_entry *nhe = NULL;
- struct listnode *node = NULL;
+ struct nhe_show_context *ctx = arg;
+ struct nhg_hash_entry *nhe;
- for (ALL_LIST_ELEMENTS_RO(list, node, nhe)) {
+ nhe = bucket->data; /* We won't be offered NULL buckets */
- if (afi && nhe->afi != afi)
- continue;
+ if (ctx->afi && nhe->afi != ctx->afi)
+ goto done;
- if (nhe->vrf_id != zvrf->vrf->vrf_id)
- continue;
+ if (ctx->vrf_id && nhe->vrf_id != ctx->vrf_id)
+ goto done;
- show_nexthop_group_out(vty, nhe);
- }
+ show_nexthop_group_out(ctx->vty, nhe);
- list_delete(&list);
+done:
+ return HASHWALK_CONTINUE;
+}
+
+static void show_nexthop_group_cmd_helper(struct vty *vty,
+ struct zebra_vrf *zvrf,
+ afi_t afi)
+{
+ struct nhe_show_context ctx;
+
+ ctx.vty = vty;
+ ctx.afi = afi;
+ ctx.vrf_id = zvrf->vrf->vrf_id;
+
+ hash_walk(zrouter.nhgs_id, nhe_show_walker, &ctx);
}
static void if_nexthop_group_dump_vty(struct vty *vty, struct interface *ifp)
@@ -1401,7 +1422,8 @@ DEFPY (show_nexthop_group,
zvrf = zebra_vrf_lookup_by_name(VRF_DEFAULT_NAME);
if (!zvrf) {
- vty_out(vty, "VRF %s specified does not exist", vrf_name);
+ vty_out(vty, "%% VRF '%s' specified does not exist\n",
+ vrf_name);
return CMD_WARNING;
}
@@ -1410,6 +1432,19 @@ DEFPY (show_nexthop_group,
return CMD_SUCCESS;
}
+DEFPY_HIDDEN(nexthop_group_use_enable,
+ nexthop_group_use_enable_cmd,
+ "[no] zebra nexthop kernel enable",
+ NO_STR
+ ZEBRA_STR
+ "Nexthop configuration \n"
+ "Configure use of kernel nexthops\n"
+ "Enable kernel nexthops\n")
+{
+ zebra_nhg_enable_kernel_nexthops(!no);
+ return CMD_SUCCESS;
+}
+
DEFUN (no_ip_nht_default_route,
no_ip_nht_default_route_cmd,
"no ip nht resolve-via-default",
@@ -3121,6 +3156,10 @@ static int config_write_protocol(struct vty *vty)
/* Include dataplane info */
dplane_config_write_helper(vty);
+ /* Include nexthop-group config */
+ if (!zebra_nhg_kernel_nexthops_enabled())
+ vty_out(vty, "no zebra nexthop kernel enable\n");
+
return 1;
}
@@ -3492,6 +3531,7 @@ void zebra_vty_init(void)
install_element(CONFIG_NODE, &no_zebra_workqueue_timer_cmd);
install_element(CONFIG_NODE, &zebra_packet_process_cmd);
install_element(CONFIG_NODE, &no_zebra_packet_process_cmd);
+ install_element(CONFIG_NODE, &nexthop_group_use_enable_cmd);
install_element(VIEW_NODE, &show_nexthop_group_cmd);
install_element(VIEW_NODE, &show_interface_nexthop_group_cmd);