From 9b36dd0e46d2af5262fe5f734229f78ef2a60f00 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Fri, 4 Nov 2022 19:28:04 +0100 Subject: [PATCH] zebra: Add CLI command to verify SRv6 Manager Add a new CLI command `show segment-routing srv6 manager [json]` to verify the overall SRv6 state. The current output displays only the configured source address of outer encapsulating IPv6 header. The output can be extended in the future to show more information, including summary SRv6 information and supported capabilities. Example: ``` r1# show segment-routing srv6 manager Parameters: Encapsulation: Source Address: Configured: fc00:0:1::1 r1# show segment-routing srv6 manager json { "parameters":{ "encapsulation":{ "sourceAddress":{ "configured":"fc00:0:1::1" } } } } ``` Signed-off-by: Carmine Scarpitta --- zebra/zebra_srv6_vty.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index ffc67fc8a1e3..417489fbcf50 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -68,6 +68,45 @@ static struct cmd_node srv6_encap_node = { .prompt = "%s(config-srv6-encap)# " }; +DEFPY (show_srv6_manager, + show_srv6_manager_cmd, + "show segment-routing srv6 manager [json]", + SHOW_STR + "Segment Routing\n" + "Segment Routing SRv6\n" + "Verify SRv6 Manager\n" + JSON_STR) +{ + const bool uj = use_json(argc, argv); + struct zebra_srv6 *srv6 = zebra_srv6_get_default(); + json_object *json = NULL; + json_object *json_parameters = NULL; + json_object *json_encapsulation = NULL; + json_object *json_source_address = NULL; + + if (uj) { + json = json_object_new_object(); + json_parameters = json_object_new_object(); + json_object_object_add(json, "parameters", json_parameters); + json_encapsulation = json_object_new_object(); + json_object_object_add(json_parameters, "encapsulation", + json_encapsulation); + json_source_address = json_object_new_object(); + json_object_object_add(json_encapsulation, "sourceAddress", + json_source_address); + json_object_string_addf(json_source_address, "configured", + "%pI6", &srv6->encap_src_addr); + vty_json(vty, json); + } else { + vty_out(vty, "Parameters:\n"); + vty_out(vty, " Encapsulation:\n"); + vty_out(vty, " Source Address:\n"); + vty_out(vty, " Configured: %pI6\n", &srv6->encap_src_addr); + } + + return CMD_SUCCESS; +} + DEFUN (show_srv6_locator, show_srv6_locator_cmd, "show segment-routing srv6 locator [json]", @@ -508,4 +547,5 @@ void zebra_srv6_vty_init(void) /* Command for operation */ install_element(VIEW_NODE, &show_srv6_locator_cmd); install_element(VIEW_NODE, &show_srv6_locator_detail_cmd); + install_element(VIEW_NODE, &show_srv6_manager_cmd); }