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

Add support for SRv6 SID Manager #15604

Merged
merged 25 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
021386a
lib: Add support for SRv6 SID formats
cscarpitta Mar 22, 2024
1298867
zebra: Add support for SRv6 SID formats
cscarpitta Jun 6, 2024
35f4bed
lib: Add CLI nodes to support SRv6 SID format
cscarpitta Mar 22, 2024
b3ca230
vtysh: CLI to override default SID format config
cscarpitta Mar 26, 2024
51d3cd8
zebra: CLI to override default SID format config
cscarpitta Mar 26, 2024
bf10e44
zebra: Add support for SRv6 SID blocks
cscarpitta Mar 22, 2024
f00554e
lib: Add function to copy an SRv6 locator
cscarpitta May 8, 2024
779d4c2
zebra: CLI to specify format of an SRv6 locator
cscarpitta Mar 22, 2024
3cb88e6
lib: Add support for SRv6 SIDs
cscarpitta May 6, 2024
8b3f378
zebra: Add support for SRv6 SIDs
cscarpitta Mar 23, 2024
ded79d7
lib: Add ZAPI operation get SRv6 locator
cscarpitta Mar 23, 2024
ee1d208
lib: Add ZAPI operations to get/release SRv6 SIDs
cscarpitta Mar 23, 2024
164117f
lib: Add missing info to locator encode/decode
cscarpitta May 6, 2024
f8da4a2
zebra: Repond to `GET_LOCATOR` ZAPI request
cscarpitta Mar 23, 2024
c570d2b
zebra: Add functions to alloc/release SRv6 SIDs
cscarpitta Mar 23, 2024
84dd482
zebra: Alloc/Release SIDs to daemons upon request
cscarpitta Mar 23, 2024
b90cb00
lib: Add ZAPI command `ZEBRA_SRV6_SID_NOTIFY`
cscarpitta May 6, 2024
efa830e
zebra: Notify daemons about SIDs
cscarpitta May 2, 2024
5365c56
zebra: Notify all daemons about locator delete
cscarpitta May 2, 2024
33bd67a
doc: Add documentation for SRv6 SID formats CLI
cscarpitta May 2, 2024
4dcb69e
zebra: Fix checkpatch warning
cscarpitta May 3, 2024
708f20e
zebra: fix display srv6 address only for explicit-sid
pguibert6WIND Jun 7, 2024
35a87b6
zebra: fix display explicit sid refused
pguibert6WIND Jun 7, 2024
209223d
zebra: fix sid allocation should be different with 2 isis instances
pguibert6WIND Jun 11, 2024
36a310c
zebra, lib: add locator name in sid notify messages
pguibert6WIND Jun 8, 2024
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
84 changes: 84 additions & 0 deletions doc/user/zebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,35 @@ and this section also helps that case.
!
...

.. clicmd:: format NAME

Specify the SID allocation schema for the SIDs allocated from this locator. Currently,
FRR supports supports the following allocation schemas:

- `usid-f3216`
- `uncompressed`

::

router# configure terminal
router(config)# segment-routinig
router(config-sr)# srv6
router(config-srv6)# locators
router(config-srv6-locators)# locator loc1
router(config-srv6-locator)# prefix fc00:0:1::/48
router(config-srv6-locator)# format usid-f3216

router(config-srv6-locator)# show run
...
segment-routing
srv6
locators
locator loc1
prefix fc00:0:1::/48
format usid-f3216
!
...

.. clicmd:: encapsulation

Configure parameters for SRv6 encapsulation.
Expand All @@ -1029,6 +1058,61 @@ and this section also helps that case.

Configure the source address of the outer encapsulating IPv6 header.

.. clicmd:: formats

Configure SRv6 SID formats.

.. clicmd:: format NAME

Configure SRv6 SID format.

.. clicmd:: compressed usid

Enable SRv6 uSID compression and configure SRv6 uSID compression parameters.

.. clicmd:: local-id-block start START

Configure the start value for the Local ID Block (LIB).

.. clicmd:: local-id-block explicit start START end END

Configure the start/end values for the Explicit LIB (ELIB).

.. clicmd:: wide-local-id-block start START end END

Configure the start/end values for the Wide LIB (W-LIB).

.. clicmd:: wide-local-id-block explicit start START

Configure the start value for the Explicit Wide LIB (EW-LIB).

::

router# configure terminal
router(config)# segment-routinig
router(config-sr)# srv6
router(config-srv6)# formats
router(config-srv6-formats)# format usid-f3216
router(config-srv6-format)# compressed usid
router(config-srv6-format-usid)# local-id-block start 0xD000
router(config-srv6-format-usid)# local-id-block explicit start 0xF000 end 0xFDFF
router(config-srv6-format-usid)# wide-local-id-block start 0xFFF4 end 0xFFF5
router(config-srv6-format-usid)# wide-local-id-block explicit start 0xFFF4

router(config-srv6-locator)# show run
...
segment-routing
srv6
formats
format usid-f3216
compressed usid
local-id-block start 0xD000
local-id-block explicit start 0xF000 end 0xFDFF
wide-local-id-block start 0xFFF4 end 0xFFF5
wide-local-id-block explicit start 0xFFF4
!
...

.. _multicast-rib-commands:

Multicast RIB Commands
Expand Down
3 changes: 3 additions & 0 deletions lib/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ enum node_type {
SRV6_LOCS_NODE, /* SRv6 locators node */
SRV6_LOC_NODE, /* SRv6 locator node */
SRV6_ENCAP_NODE, /* SRv6 encapsulation node */
SRV6_SID_FORMATS_NODE, /* SRv6 SID formats config node */
SRV6_SID_FORMAT_USID_F3216_NODE, /* SRv6 uSID f3216 format config node */
SRV6_SID_FORMAT_UNCOMPRESSED_F4024_NODE, /* SRv6 uncompressed f4024 format config node */
VTY_NODE, /* Vty node. */
FPM_NODE, /* Dataplane FPM node. */
LINK_PARAMS_NODE, /* Link-parameters node */
Expand Down
6 changes: 5 additions & 1 deletion lib/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY(ZEBRA_SRV6_LOCATOR_DELETE),
DESC_ENTRY(ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK),
DESC_ENTRY(ZEBRA_SRV6_MANAGER_RELEASE_LOCATOR_CHUNK),
DESC_ENTRY(ZEBRA_SRV6_MANAGER_GET_LOCATOR),
DESC_ENTRY(ZEBRA_SRV6_MANAGER_GET_SRV6_SID),
DESC_ENTRY(ZEBRA_SRV6_MANAGER_RELEASE_SRV6_SID),
DESC_ENTRY(ZEBRA_ERROR),
DESC_ENTRY(ZEBRA_CLIENT_CAPABILITIES),
DESC_ENTRY(ZEBRA_OPAQUE_MESSAGE),
Expand All @@ -461,7 +464,8 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY(ZEBRA_TC_CLASS_DELETE),
DESC_ENTRY(ZEBRA_TC_FILTER_ADD),
DESC_ENTRY(ZEBRA_TC_FILTER_DELETE),
DESC_ENTRY(ZEBRA_OPAQUE_NOTIFY)
DESC_ENTRY(ZEBRA_OPAQUE_NOTIFY),
DESC_ENTRY(ZEBRA_SRV6_SID_NOTIFY)
};
#undef DESC_ENTRY

Expand Down
187 changes: 153 additions & 34 deletions lib/srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
#include "log.h"

DEFINE_QOBJ_TYPE(srv6_locator);
DEFINE_QOBJ_TYPE(srv6_sid_format);
DEFINE_MTYPE_STATIC(LIB, SRV6_LOCATOR, "SRV6 locator");
DEFINE_MTYPE_STATIC(LIB, SRV6_LOCATOR_CHUNK, "SRV6 locator chunk");
DEFINE_MTYPE_STATIC(LIB, SRV6_SID_FORMAT, "SRv6 SID format");
DEFINE_MTYPE_STATIC(LIB, SRV6_SID_CTX, "SRv6 SID context");

const char *seg6local_action2str(uint32_t action)
{
Expand Down Expand Up @@ -139,6 +142,21 @@ struct srv6_locator_chunk *srv6_locator_chunk_alloc(void)
return chunk;
}

void srv6_locator_copy(struct srv6_locator *copy,
const struct srv6_locator *locator)
{
strlcpy(copy->name, locator->name, sizeof(locator->name));
copy->prefix = locator->prefix;
copy->block_bits_length = locator->block_bits_length;
copy->node_bits_length = locator->node_bits_length;
copy->function_bits_length = locator->function_bits_length;
copy->argument_bits_length = locator->argument_bits_length;
copy->algonum = locator->algonum;
copy->current = locator->current;
copy->status_up = locator->status_up;
copy->flags = locator->flags;
}

void srv6_locator_free(struct srv6_locator *locator)
{
if (locator) {
Expand All @@ -154,6 +172,59 @@ void srv6_locator_chunk_free(struct srv6_locator_chunk **chunk)
XFREE(MTYPE_SRV6_LOCATOR_CHUNK, *chunk);
}

struct srv6_sid_format *srv6_sid_format_alloc(const char *name)
{
struct srv6_sid_format *format = NULL;

format = XCALLOC(MTYPE_SRV6_SID_FORMAT, sizeof(struct srv6_sid_format));
strlcpy(format->name, name, sizeof(format->name));

QOBJ_REG(format, srv6_sid_format);
return format;
}

void srv6_sid_format_free(struct srv6_sid_format *format)
{
if (!format)
return;

QOBJ_UNREG(format);
XFREE(MTYPE_SRV6_SID_FORMAT, format);
}

/**
* Free an SRv6 SID format.
*
* @param val SRv6 SID format to be freed
*/
void delete_srv6_sid_format(void *val)
{
srv6_sid_format_free((struct srv6_sid_format *)val);
}

struct srv6_sid_ctx *srv6_sid_ctx_alloc(enum seg6local_action_t behavior,
struct in_addr *nh4,
struct in6_addr *nh6, vrf_id_t vrf_id)
{
struct srv6_sid_ctx *ctx = NULL;

ctx = XCALLOC(MTYPE_SRV6_SID_CTX, sizeof(struct srv6_sid_ctx));
ctx->behavior = behavior;
if (nh4)
ctx->nh4 = *nh4;
if (nh6)
ctx->nh6 = *nh6;
if (vrf_id)
ctx->vrf_id = vrf_id;

return ctx;
}

void srv6_sid_ctx_free(struct srv6_sid_ctx *ctx)
{
XFREE(MTYPE_SRV6_SID_CTX, ctx);
}

json_object *srv6_locator_chunk_json(const struct srv6_locator_chunk *chunk)
{
json_object *jo_root = NULL;
Expand Down Expand Up @@ -223,23 +294,47 @@ json_object *srv6_locator_json(const struct srv6_locator *loc)
/* set prefix */
json_object_string_addf(jo_root, "prefix", "%pFX", &loc->prefix);

/* set block_bits_length */
json_object_int_add(jo_root, "blockBitsLength", loc->block_bits_length);

/* set node_bits_length */
json_object_int_add(jo_root, "nodeBitsLength", loc->node_bits_length);

/* set function_bits_length */
json_object_int_add(jo_root, "functionBitsLength",
loc->function_bits_length);

/* set argument_bits_length */
json_object_int_add(jo_root, "argumentBitsLength",
loc->argument_bits_length);

/* set true if the locator is a Micro-segment (uSID) locator */
if (CHECK_FLAG(loc->flags, SRV6_LOCATOR_USID))
json_object_string_add(jo_root, "behavior", "usid");
if (loc->sid_format) {
/* set block_bits_length */
json_object_int_add(jo_root, "blockBitsLength",
loc->sid_format->block_len);

/* set node_bits_length */
json_object_int_add(jo_root, "nodeBitsLength",
loc->sid_format->node_len);

/* set function_bits_length */
json_object_int_add(jo_root, "functionBitsLength",
loc->sid_format->function_len);

/* set argument_bits_length */
json_object_int_add(jo_root, "argumentBitsLength",
loc->sid_format->argument_len);

/* set true if the locator is a Micro-segment (uSID) locator */
if (loc->sid_format->type == SRV6_SID_FORMAT_TYPE_USID)
json_object_string_add(jo_root, "behavior", "usid");
} else {
/* set block_bits_length */
json_object_int_add(jo_root, "blockBitsLength",
loc->block_bits_length);

/* set node_bits_length */
json_object_int_add(jo_root, "nodeBitsLength",
loc->node_bits_length);

/* set function_bits_length */
json_object_int_add(jo_root, "functionBitsLength",
loc->function_bits_length);

/* set argument_bits_length */
json_object_int_add(jo_root, "argumentBitsLength",
loc->argument_bits_length);

/* set true if the locator is a Micro-segment (uSID) locator */
if (CHECK_FLAG(loc->flags, SRV6_LOCATOR_USID))
json_object_string_add(jo_root, "behavior", "usid");
}

/* set status_up */
json_object_boolean_add(jo_root, "statusUp",
Expand Down Expand Up @@ -272,23 +367,47 @@ json_object *srv6_locator_detailed_json(const struct srv6_locator *loc)
/* set prefix */
json_object_string_addf(jo_root, "prefix", "%pFX", &loc->prefix);

/* set block_bits_length */
json_object_int_add(jo_root, "blockBitsLength", loc->block_bits_length);

/* set node_bits_length */
json_object_int_add(jo_root, "nodeBitsLength", loc->node_bits_length);

/* set function_bits_length */
json_object_int_add(jo_root, "functionBitsLength",
loc->function_bits_length);

/* set argument_bits_length */
json_object_int_add(jo_root, "argumentBitsLength",
loc->argument_bits_length);

/* set true if the locator is a Micro-segment (uSID) locator */
if (CHECK_FLAG(loc->flags, SRV6_LOCATOR_USID))
json_object_string_add(jo_root, "behavior", "usid");
if (loc->sid_format) {
/* set block_bits_length */
json_object_int_add(jo_root, "blockBitsLength",
loc->sid_format->block_len);

/* set node_bits_length */
json_object_int_add(jo_root, "nodeBitsLength",
loc->sid_format->node_len);

/* set function_bits_length */
json_object_int_add(jo_root, "functionBitsLength",
loc->sid_format->function_len);

/* set argument_bits_length */
json_object_int_add(jo_root, "argumentBitsLength",
loc->sid_format->argument_len);

/* set true if the locator is a Micro-segment (uSID) locator */
if (loc->sid_format->type == SRV6_SID_FORMAT_TYPE_USID)
json_object_string_add(jo_root, "behavior", "usid");
} else {
/* set block_bits_length */
json_object_int_add(jo_root, "blockBitsLength",
loc->block_bits_length);

/* set node_bits_length */
json_object_int_add(jo_root, "nodeBitsLength",
loc->node_bits_length);

/* set function_bits_length */
json_object_int_add(jo_root, "functionBitsLength",
loc->function_bits_length);

/* set argument_bits_length */
json_object_int_add(jo_root, "argumentBitsLength",
loc->argument_bits_length);

/* set true if the locator is a Micro-segment (uSID) locator */
if (CHECK_FLAG(loc->flags, SRV6_LOCATOR_USID))
json_object_string_add(jo_root, "behavior", "usid");
}

/* set algonum */
json_object_int_add(jo_root, "algoNum", loc->algonum);
Expand Down
Loading
Loading