From 1804d70cbd975ef8a014719df5833a9233663811 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Wed, 15 Feb 2023 12:15:45 +0100 Subject: [PATCH] isisd: Add func to build Sub-TLV from SRv6 End SID Add a function to build an SRv6 End SID TLV (RFC 9352 section #7.2) to advertise a specific SRv6 End SID passed as an argument. Signed-off-by: Carmine Scarpitta --- isisd/isis_tlvs.c | 34 ++++++++++++++++++++++++++++++++++ isisd/isis_tlvs.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index 8d0047de76..da62725311 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -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) diff --git a/isisd/isis_tlvs.h b/isisd/isis_tlvs.h index 552ffc151b..a03f9285c1 100644 --- a/isisd/isis_tlvs.h +++ b/isisd/isis_tlvs.h @@ -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 { @@ -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