From a3ff3dff3fcf3e264d4484a1ce5bbe40db3edcb7 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Thu, 27 Oct 2022 20:01:24 +0200 Subject: lib,zebra: Add SRv6 uSID info to VTY output In this commit, we extend to print the `SRV6_LOCATOR_USID` flag. The output appears as follows: ``` { "locators":[ { "name":"loc1", "prefix":"fc00:0:1::/48", "blockBitsLength":32, "nodeBitsLength":16, "functionBitsLength":16, "argumentBitsLength":0, "uSID":true, "statusUp":true, "chunks":[ { "prefix":"fc00:0:1::/48", "proto":"bgp" } ] } ] } ``` Signed-off-by: Carmine Scarpitta --- zebra/zebra_srv6_vty.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'zebra/zebra_srv6_vty.c') diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index 9adfc6550a..956669af56 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -174,6 +174,9 @@ DEFUN (show_srv6_locator_detail, vty_out(vty, "Argument-Bit-Len: %u\n", locator->argument_bits_length); + if (CHECK_FLAG(locator->flags, SRV6_LOCATOR_USID)) + vty_out(vty, "Behavior: uSID\n"); + vty_out(vty, "Chunks:\n"); for (ALL_LIST_ELEMENTS_RO((struct list *)locator->chunks, node, chunk)) { -- cgit v1.2.3 From 3a7e1f656e1888079231b4a18c8dd78a946f5ff1 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Thu, 27 Oct 2022 20:08:40 +0200 Subject: zebra: Add `behavior usid` command to VTY Install a new command `behavior usid` into the `SRV6_LOC_NODE` CLI node. This command allows the user to set/unset the `SRV6_LOCATOR_USID` flag for an SRv6 locator. The `SRV6_LOCATOR_USID` flag indicates whether a locator is a uSID locator or not. When the flag is set, the routing daemons (e.g., bgpd) will install SRv6 behaviors with the uSID in the dataplane. Signed-off-by: Carmine Scarpitta --- zebra/zebra_srv6_vty.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'zebra/zebra_srv6_vty.c') diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index 956669af56..88922607e8 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -374,6 +374,38 @@ DEFPY (locator_prefix, return CMD_SUCCESS; } +DEFPY (locator_behavior, + locator_behavior_cmd, + "[no] behavior usid", + NO_STR + "Configure SRv6 behavior\n" + "Specify SRv6 behavior uSID\n") +{ + VTY_DECLVAR_CONTEXT(srv6_locator, locator); + + if (no && !CHECK_FLAG(locator->flags, SRV6_LOCATOR_USID)) + /* SRv6 locator uSID flag already unset, nothing to do */ + return CMD_SUCCESS; + + if (!no && CHECK_FLAG(locator->flags, SRV6_LOCATOR_USID)) + /* SRv6 locator uSID flag already set, nothing to do */ + return CMD_SUCCESS; + + /* Remove old locator from zclients */ + zebra_notify_srv6_locator_delete(locator); + + /* Set/Unset the SRV6_LOCATOR_USID */ + if (no) + UNSET_FLAG(locator->flags, SRV6_LOCATOR_USID); + else + SET_FLAG(locator->flags, SRV6_LOCATOR_USID); + + /* Notify the new locator to zclients */ + zebra_notify_srv6_locator_add(locator); + + return CMD_SUCCESS; +} + static int zebra_sr_config(struct vty *vty) { struct zebra_srv6 *srv6 = zebra_srv6_get_default(); @@ -404,6 +436,8 @@ static int zebra_sr_config(struct vty *vty) if (locator->argument_bits_length) vty_out(vty, " arg-len %u", locator->argument_bits_length); + if (CHECK_FLAG(locator->flags, SRV6_LOCATOR_USID)) + vty_out(vty, " behavior usid"); vty_out(vty, "\n"); vty_out(vty, " exit\n"); vty_out(vty, " !\n"); @@ -440,6 +474,7 @@ void zebra_srv6_vty_init(void) /* Command for configuration */ install_element(SRV6_LOC_NODE, &locator_prefix_cmd); + install_element(SRV6_LOC_NODE, &locator_behavior_cmd); /* Command for operation */ install_element(VIEW_NODE, &show_srv6_locator_cmd); -- cgit v1.2.3