Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staticd: Add support for SRv6 Static SIDs #16894

Merged
merged 15 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions doc/user/static.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,52 @@ multiple segments instructions.
router# show ipv6 route
[..]
S>* 2005::/64 [1/0] is directly connected, ens3, seg6 2001:db8:aaaa::7,2002::4,2002::3,2002::2, weight 1, 00:00:06

SRv6 Static SIDs Commands
=========================

.. clicmd:: segment-routing

Move from configure mode to segment-routing node.

.. clicmd:: srv6

Move from segment-routing node to srv6 node.

.. clicmd:: static-sids

Move from srv6 node to static-sids node. In this static-sids node, user can
configure static SRv6 SIDs.

.. clicmd:: sid X:X::X:X/M locator NAME behavior <uN|uDT4|uDT6|uDT46> [vrf VRF]

Specify the locator sid manually. Configuring a local sid in a purely static mode
by specifying the sid value would generate a unique SID.
This feature will support the configuration of static SRv6 decapsulation on the system.

It supports four parameter options, corresponding to the following functions:
uN, uDT4, uDT6, uDT46

When configuring the local sid, if the action is set to 'uN', no vrf should be set.
While for any other action, it is necessary to specify a specific vrf.

::

router# configure terminal
router(config)# segment-routing
router(config-sr)# srv6
router(config-srv6)# static-sids
router(config-srv6-sids)# sid fcbb:bbbb:1:fe01::/64 locator LOC1 behavior uDT6 vrf Vrf1
router(config-srv6-sids)# sid fcbb:bbbb:1:fe02::/64 locator LOC1 behavior uDT4 vrf Vrf1
router(config-srv6-sids)# sid fcbb:bbbb:1:fe03::/64 locator LOC1 behavior uDT46 vrf Vrf2

router(config-srv6-locator)# show run
...
segment-routing
srv6
static-sids
sid fcbb:bbbb:1:fe01::/64 locator LOC1 behavior uDT6 vrf Vrf1
sid fcbb:bbbb:1:fe02::/64 locator LOC1 behavior uDT4 vrf Vrf1
sid fcbb:bbbb:1:fe03::/64 locator LOC1 behavior uDT46 vrf Vrf2
!
...
2 changes: 1 addition & 1 deletion isisd/isis_srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ void isis_srv6_area_init(struct isis_area *area)
srv6db->config.max_end_pop_msd = ISIS_DEFAULT_SRV6_MAX_END_POP_MSD;
srv6db->config.max_h_encaps_msd = ISIS_DEFAULT_SRV6_MAX_H_ENCAPS_MSD;
srv6db->config.max_end_d_msd = ISIS_DEFAULT_SRV6_MAX_END_D_MSD;
strlcpy(srv6db->config.srv6_ifname, ISIS_DEFAULT_SRV6_IFNAME, sizeof(srv6db->config.srv6_ifname));
strlcpy(srv6db->config.srv6_ifname, DEFAULT_SRV6_IFNAME, sizeof(srv6db->config.srv6_ifname));
#endif

/* Initialize SRv6 Locator chunks list */
Expand Down
3 changes: 1 addition & 2 deletions isisd/isis_srv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
#define ISIS_DEFAULT_SRV6_MAX_SEG_LEFT_MSD 3
#define ISIS_DEFAULT_SRV6_MAX_END_POP_MSD 3
#define ISIS_DEFAULT_SRV6_MAX_H_ENCAPS_MSD 2
#define ISIS_DEFAULT_SRV6_MAX_END_D_MSD 5
#define ISIS_DEFAULT_SRV6_IFNAME "sr0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you remove the define, you will break the compilation.
it is highly recommended to avoid breaking compilation.
I recommend you to squash this commit with the commit next to this commit that adds the define in lib/srv6.h file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#define ISIS_DEFAULT_SRV6_MAX_END_D_MSD 5

/* SRv6 SID structure */
struct isis_srv6_sid_structure {
Expand Down
1 change: 1 addition & 0 deletions lib/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ enum node_type {
PCEP_PCE_NODE, /* PCE configuration node */
PCEP_PCC_NODE, /* PCC configuration node */
SRV6_NODE, /* SRv6 node */
SRV6_SIDS_NODE, /* SRv6 SIDs node */
SRV6_LOCS_NODE, /* SRv6 locators node */
SRV6_LOC_NODE, /* SRv6 locator node */
SRV6_ENCAP_NODE, /* SRv6 encapsulation node */
Expand Down
38 changes: 38 additions & 0 deletions lib/srv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#define SRV6_SID_FORMAT_NAME_SIZE 512

#define DEFAULT_SRV6_IFNAME "sr0"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -186,6 +188,42 @@ enum srv6_endpoint_behavior_codepoint {
SRV6_ENDPOINT_BEHAVIOR_OPAQUE = 0xFFFF,
};

/*
* Convert SRv6 endpoint behavior codepoints to human-friendly string.
*/
static inline const char *
srv6_endpoint_behavior_codepoint2str(enum srv6_endpoint_behavior_codepoint behavior)
{
switch (behavior) {
case SRV6_ENDPOINT_BEHAVIOR_RESERVED:
return "Reserved";
case SRV6_ENDPOINT_BEHAVIOR_END:
return "End";
case SRV6_ENDPOINT_BEHAVIOR_END_X:
return "End.X";
case SRV6_ENDPOINT_BEHAVIOR_END_DT6:
return "End.DT6";
case SRV6_ENDPOINT_BEHAVIOR_END_DT4:
return "End.DT4";
case SRV6_ENDPOINT_BEHAVIOR_END_DT46:
return "End.DT46";
case SRV6_ENDPOINT_BEHAVIOR_END_NEXT_CSID:
return "uN";
case SRV6_ENDPOINT_BEHAVIOR_END_X_NEXT_CSID:
return "uA";
case SRV6_ENDPOINT_BEHAVIOR_END_DT6_USID:
return "uDT6";
case SRV6_ENDPOINT_BEHAVIOR_END_DT4_USID:
return "uDT4";
case SRV6_ENDPOINT_BEHAVIOR_END_DT46_USID:
return "uDT46";
case SRV6_ENDPOINT_BEHAVIOR_OPAQUE:
return "Opaque";
}

return "Unspec";
}

struct nexthop_srv6 {
/* SRv6 localsid info for Endpoint-behaviour */
enum seg6local_action_t seg6local_action;
Expand Down
7 changes: 5 additions & 2 deletions staticd/static_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
struct debug static_dbg_events = {0, "debug static events", "Staticd events"};
struct debug static_dbg_route = {0, "debug static route", "Staticd route"};
struct debug static_dbg_bfd = {0, "debug static bfd", "Staticd bfd"};
struct debug static_dbg_srv6 = {0, "debug static srv6", "Staticd srv6"};
/* clang-format on */

/*
Expand All @@ -37,8 +38,7 @@ struct debug static_dbg_bfd = {0, "debug static bfd", "Staticd bfd"};
* Debug general internal events
*
*/
void static_debug_set(int vtynode, bool onoff, bool events, bool route,
bool bfd)
void static_debug_set(int vtynode, bool onoff, bool events, bool route, bool bfd, bool srv6)
{
uint32_t mode = DEBUG_NODE2MODE(vtynode);

Expand All @@ -50,6 +50,8 @@ void static_debug_set(int vtynode, bool onoff, bool events, bool route,
DEBUG_MODE_SET(&static_dbg_bfd, mode, onoff);
bfd_protocol_integration_set_debug(onoff);
}
if (srv6)
DEBUG_MODE_SET(&static_dbg_srv6, mode, onoff);
}

/*
Expand All @@ -61,4 +63,5 @@ void static_debug_init(void)
debug_install(&static_dbg_events);
debug_install(&static_dbg_route);
debug_install(&static_dbg_bfd);
debug_install(&static_dbg_srv6);
}
4 changes: 2 additions & 2 deletions staticd/static_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern "C" {
extern struct debug static_dbg_events;
extern struct debug static_dbg_route;
extern struct debug static_dbg_bfd;
extern struct debug static_dbg_srv6;

/*
* Initialize staticd debugging.
Expand All @@ -41,8 +42,7 @@ void static_debug_init(void);
* Debug general internal events
*
*/
void static_debug_set(int vtynode, bool onoff, bool events, bool route,
bool bfd);
void static_debug_set(int vtynode, bool onoff, bool events, bool route, bool bfd, bool srv6);

#ifdef __cplusplus
}
Expand Down
8 changes: 8 additions & 0 deletions staticd/static_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "static_zebra.h"
#include "static_debug.h"
#include "static_nb.h"
#include "static_srv6.h"

#include "mgmt_be_client.h"

Expand Down Expand Up @@ -76,6 +77,10 @@ static void sigint(void)
static_vrf_terminate();

static_zebra_stop();

/* clean up SRv6 data structures */
static_srv6_cleanup();

frr_fini();

exit(0);
Expand Down Expand Up @@ -161,6 +166,9 @@ int main(int argc, char **argv, char **envp)
static_debug_init();
static_vrf_init();

/* initialize SRv6 data structures */
static_srv6_init();

static_zebra_init();
static_vty_init();

Expand Down
29 changes: 29 additions & 0 deletions staticd/static_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,35 @@ const struct frr_yang_module_info frr_staticd_info = {
.destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy,
}
},
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/segment-routing/srv6/static-sids/sid",
.cbs = {
.apply_finish = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_apply_finish,
.create = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_create,
.destroy = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_destroy,
}
},
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/segment-routing/srv6/static-sids/sid/behavior",
.cbs = {
.modify = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_behavior_modify,
.destroy = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_behavior_destroy,
}
},
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/segment-routing/srv6/static-sids/sid/vrf-name",
.cbs = {
.modify = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_vrf_name_modify,
.destroy = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_vrf_name_destroy,
}
},
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/segment-routing/srv6/static-sids/sid/locator-name",
.cbs = {
.modify = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_locator_name_modify,
.destroy = routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_locator_name_destroy,
}
},
{
.xpath = NULL,
},
Expand Down
48 changes: 48 additions & 0 deletions staticd/static_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,43 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
struct nb_cb_modify_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_create(
struct nb_cb_create_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_destroy(
struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_create(
struct nb_cb_create_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_destroy(
struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_create(
struct nb_cb_create_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_destroy(
struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_create(
struct nb_cb_create_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_destroy(
struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_behavior_modify(
struct nb_cb_modify_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_behavior_destroy(
struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_vrf_name_modify(
struct nb_cb_modify_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_vrf_name_destroy(
struct nb_cb_destroy_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_locator_name_modify(
struct nb_cb_modify_args *args);
int routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_locator_name_destroy(
struct nb_cb_destroy_args *args);

/* Optional 'apply_finish' callbacks. */

void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
struct nb_cb_apply_finish_args *args);
void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
struct nb_cb_apply_finish_args *args);
void routing_control_plane_protocols_control_plane_protocol_staticd_segment_routing_srv6_local_sids_sid_apply_finish(
struct nb_cb_apply_finish_args *args);

/* Optional 'pre_validate' callbacks. */
int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
Expand Down Expand Up @@ -206,6 +236,24 @@ int routing_control_plane_protocols_name_validate(
FRR_S_ROUTE_SRC_INFO_KEY_NO_DISTANCE_XPATH \
FRR_STATIC_ROUTE_NH_KEY_XPATH

/* srv6 */
#define FRR_STATIC_SRV6_INFO_KEY_XPATH \
"/frr-routing:routing/control-plane-protocols/" \
"control-plane-protocol[type='%s'][name='%s'][vrf='%s']/" \
"frr-staticd:staticd/segment-routing/srv6"

/* srv6/static-sids */
#define FRR_STATIC_SRV6_SID_KEY_XPATH \
FRR_STATIC_SRV6_INFO_KEY_XPATH \
"/static-sids/" \
"sid[sid='%s']"

#define FRR_STATIC_SRV6_SID_BEHAVIOR_XPATH "/behavior"

#define FRR_STATIC_SRV6_SID_VRF_NAME_XPATH "/vrf-name"

#define FRR_STATIC_SRV6_SID_LOCATOR_NAME_XPATH "/locator-name"

#ifdef __cplusplus
}
#endif
Expand Down
Loading
Loading