Skip to content

Commit

Permalink
isisd: Add func to build Sub-TLV from SRv6 End SID
Browse files Browse the repository at this point in the history
Add a function to build an SRv6 End SID TLV (RFC 9352 section sonic-net#7.2) to
advertise a specific SRv6 End SID passed as an argument.

Signed-off-by: Carmine Scarpitta <[email protected]>
  • Loading branch information
cscarpitta committed Sep 11, 2023
1 parent 2aaa75a commit 1804d70
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
34 changes: 34 additions & 0 deletions isisd/isis_tlvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7732,6 +7732,40 @@ void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs,
}
}

/* Add an SRv6 End SID to the SRv6 End SID Sub-TLV */
void isis_subtlvs_add_srv6_end_sid(struct isis_subtlvs *subtlvs,
struct isis_srv6_sid *sid)
{
struct isis_srv6_end_sid_subtlv *sid_subtlv;

if (!sid)
return;

/* The SRv6 End SID Sub-TLV advertises SRv6 SIDs with Endpoint behaviors
* that do not require a particular neighbor in order to be correctly
* applied (e.g. End, End.DT6, ...). Before proceeding, let's make sure
* we are encoding one of the supported behaviors. */
if (sid->behavior != SRV6_ENDPOINT_BEHAVIOR_END &&
sid->behavior != SRV6_ENDPOINT_BEHAVIOR_END_NEXT_CSID &&
sid->behavior != SRV6_ENDPOINT_BEHAVIOR_END_DT6 &&
sid->behavior != SRV6_ENDPOINT_BEHAVIOR_END_DT6_USID &&
sid->behavior != SRV6_ENDPOINT_BEHAVIOR_END_DT4 &&
sid->behavior != SRV6_ENDPOINT_BEHAVIOR_END_DT4_USID &&
sid->behavior != SRV6_ENDPOINT_BEHAVIOR_END_DT46 &&
sid->behavior != SRV6_ENDPOINT_BEHAVIOR_END_DT46_USID)
return;

/* Allocate memory for the Sub-TLV */
sid_subtlv = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(*sid_subtlv));

/* Fill in the SRv6 End SID Sub-TLV according to the SRv6 SID
* configuration */
isis_srv6_end_sid2subtlv(sid, sid_subtlv);

/* Append the SRv6 End SID Sub-TLV to the Sub-TLVs list */
append_item(&subtlvs->srv6_end_sids, (struct isis_item *)sid_subtlv);
}

/* Add an SRv6 Locator to the SRv6 Locator TLV */
void isis_tlvs_add_srv6_locator(struct isis_tlvs *tlvs, uint16_t mtid,
struct isis_srv6_locator *loc)
Expand Down
3 changes: 3 additions & 0 deletions isisd/isis_tlvs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ DECLARE_MTYPE(ISIS_SUBTLV);

struct lspdb_head;
struct sr_prefix_cfg;
struct isis_srv6_sid;
struct isis_srv6_locator;

struct isis_area_address {
Expand Down Expand Up @@ -834,6 +835,8 @@ void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs,
const uint8_t *generator,
const uint8_t *sender);

void isis_subtlvs_add_srv6_end_sid(struct isis_subtlvs *subtlvs,
struct isis_srv6_sid *sid);
void isis_tlvs_add_srv6_locator(struct isis_tlvs *tlvs, uint16_t mtid,
struct isis_srv6_locator *loc);
#endif

0 comments on commit 1804d70

Please sign in to comment.