diff options
| author | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2022-11-03 08:40:23 +0100 | 
|---|---|---|
| committer | Carmine Scarpitta <cscarpit@cisco.com> | 2023-12-14 14:58:33 +0100 | 
| commit | 69bff19c43c8f263aeb0fb3211ee0e3faf37ec5c (patch) | |
| tree | edf4dc0473e770e6927e27db93c1168326678caa /zebra/zebra_srv6_vty.c | |
| parent | 8d0b4745a1acd5e363159a1b9732a0fd596413e5 (diff) | |
zebra, lib, vtysh: Add CLI cmd to set/unset SRv6 encap source address
- Add a new node `SRV6_ENCAP_NODE` to the CLI graph. This node allows
users to configure encapsulation parameters for SRv6, including the
source address of the outer encapsulating IPv6 header.
- Install a new CLI command `source-address` under the
`SRV6_ENCAP_NODE` node. This command is used to configure the source
address of the outer encapsulating IPv6 header.
- Install a new CLI command `no source-address` under the
`SRV6_ENCAP_NODE` node. This command is used to unset the
source address of the outer encapsulating IPv6 header and restore the
default source address.
Examples:
```
router# segment-routing
router(sr)# srv6
router(srv6)# encapsulation
router(srv6-encap)# source-address fc00:0:1::1
```
```
router# segment-routing
router(sr)# srv6
router(srv6)# encapsulation
router(srv6-encap)# no source-address
```
Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Diffstat (limited to 'zebra/zebra_srv6_vty.c')
| -rw-r--r-- | zebra/zebra_srv6_vty.c | 44 | 
1 files changed, 44 insertions, 0 deletions
diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index 3775d3dcdf..ffc67fc8a1 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -61,6 +61,13 @@ static struct cmd_node srv6_loc_node = {  	.prompt = "%s(config-srv6-locator)# "  }; +static struct cmd_node srv6_encap_node = { +	.name = "srv6-encap", +	.node = SRV6_ENCAP_NODE, +	.parent_node = SRV6_NODE, +	.prompt = "%s(config-srv6-encap)# " +}; +  DEFUN (show_srv6_locator,         show_srv6_locator_cmd,         "show segment-routing srv6 locator [json]", @@ -391,6 +398,38 @@ DEFPY (locator_behavior,  	return CMD_SUCCESS;  } +DEFUN_NOSH (srv6_encap, +            srv6_encap_cmd, +            "encapsulation", +            "Segment Routing SRv6 encapsulation\n") +{ +	vty->node = SRV6_ENCAP_NODE; +	return CMD_SUCCESS; +} + +DEFPY (srv6_src_addr, +       srv6_src_addr_cmd, +       "source-address X:X::X:X$encap_src_addr", +       "Segment Routing SRv6 source address\n" +       "Specify source address for SRv6 encapsulation\n") +{ +	zebra_srv6_encap_src_addr_set(&encap_src_addr); +	dplane_srv6_encap_srcaddr_set(&encap_src_addr, NS_DEFAULT); +	return CMD_SUCCESS; +} + +DEFPY (no_srv6_src_addr, +       no_srv6_src_addr_cmd, +       "no source-address [X:X::X:X$encap_src_addr]", +       NO_STR +       "Segment Routing SRv6 source address\n" +       "Specify source address for SRv6 encapsulation\n") +{ +	zebra_srv6_encap_src_addr_unset(); +	dplane_srv6_encap_srcaddr_set(&in6addr_any, NS_DEFAULT); +	return CMD_SUCCESS; +} +  static int zebra_sr_config(struct vty *vty)  {  	struct zebra_srv6 *srv6 = zebra_srv6_get_default(); @@ -444,22 +483,27 @@ void zebra_srv6_vty_init(void)  	install_node(&srv6_node);  	install_node(&srv6_locs_node);  	install_node(&srv6_loc_node); +	install_node(&srv6_encap_node);  	install_default(SEGMENT_ROUTING_NODE);  	install_default(SRV6_NODE);  	install_default(SRV6_LOCS_NODE);  	install_default(SRV6_LOC_NODE); +	install_default(SRV6_ENCAP_NODE);  	/* Command for change node */  	install_element(CONFIG_NODE, &segment_routing_cmd);  	install_element(SEGMENT_ROUTING_NODE, &srv6_cmd);  	install_element(SEGMENT_ROUTING_NODE, &no_srv6_cmd);  	install_element(SRV6_NODE, &srv6_locators_cmd); +	install_element(SRV6_NODE, &srv6_encap_cmd);  	install_element(SRV6_LOCS_NODE, &srv6_locator_cmd);  	install_element(SRV6_LOCS_NODE, &no_srv6_locator_cmd);  	/* Command for configuration */  	install_element(SRV6_LOC_NODE, &locator_prefix_cmd);  	install_element(SRV6_LOC_NODE, &locator_behavior_cmd); +	install_element(SRV6_ENCAP_NODE, &srv6_src_addr_cmd); +	install_element(SRV6_ENCAP_NODE, &no_srv6_src_addr_cmd);  	/* Command for operation */  	install_element(VIEW_NODE, &show_srv6_locator_cmd);  | 
