diff options
| author | Carmine Scarpitta <cscarpit@cisco.com> | 2024-03-23 21:43:17 +0100 |
|---|---|---|
| committer | Carmine Scarpitta <cscarpit@cisco.com> | 2024-06-18 18:33:29 +0200 |
| commit | a2b83a9dec6a9c1021ccbc368c55b2cd6b362d42 (patch) | |
| tree | 1bfac7e94f4f0e7ac90f007a4ce350c59f2b6834 /isisd/isis_srv6.c | |
| parent | 0af0f4616d32879b8114386e2c44fc6b3250cb14 (diff) | |
isisd: Cleanup related to SRv6
Remove unused SRv6 code.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
Diffstat (limited to 'isisd/isis_srv6.c')
| -rw-r--r-- | isisd/isis_srv6.c | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/isisd/isis_srv6.c b/isisd/isis_srv6.c index c7bc7f0692..b5974b1a62 100644 --- a/isisd/isis_srv6.c +++ b/isisd/isis_srv6.c @@ -221,117 +221,6 @@ void isis_srv6_interface_set(struct isis_area *area, const char *ifname) } /** - * Encode SID function in the SRv6 SID. - * - * @param sid - * @param func - * @param offset - * @param len - */ -static void encode_sid_func(struct in6_addr *sid, uint32_t func, uint8_t offset, - uint8_t len) -{ - for (uint8_t idx = 0; idx < len; idx++) { - uint8_t tidx = offset + idx; - sid->s6_addr[tidx / 8] &= ~(0x1 << (7 - tidx % 8)); - if (func >> (len - 1 - idx) & 0x1) - sid->s6_addr[tidx / 8] |= 0x1 << (7 - tidx % 8); - } -} - -static bool sid_exist(struct isis_area *area, const struct in6_addr *sid) -{ - struct listnode *node; - struct isis_srv6_sid *s; - struct srv6_adjacency *sra; - - for (ALL_LIST_ELEMENTS_RO(area->srv6db.srv6_sids, node, s)) - if (sid_same(&s->sid, sid)) - return true; - for (ALL_LIST_ELEMENTS_RO(area->srv6db.srv6_endx_sids, node, sra)) - if (sid_same(&sra->sid, sid)) - return true; - return false; -} - -/** - * Request a SID from the SRv6 locator. - * - * @param area IS-IS area - * @param locator SRv6 locator - * @param sid_func The FUNCTION part of the SID to be allocated (a negative - * number will allocate the first available SID) - * - * @return First available SID on success or in6addr_any if the SRv6 - * locator is full - */ -static struct in6_addr srv6_locator_request_sid(struct isis_area *area, - struct srv6_locator *locator, - int sid_func) -{ - struct in6_addr sid; - uint8_t offset = 0; - uint8_t func_len = 0; - uint32_t func_max; - bool allocated = false; - - if (!area || !locator) - return in6addr_any; - - sr_debug("ISIS-SRv6 (%s): requested new SID from locator %s", - area->area_tag, locator->name); - - /* Let's build the SID, step by step. A SID has the following structure - (defined in RFC 8986): LOCATOR:FUNCTION:ARGUMENT.*/ - - /* First, we encode the LOCATOR in the L most significant bits. */ - sid = locator->prefix.prefix; - - /* The next part of the SID is the FUNCTION. Let's compute the length - * and the offset of the FUNCTION in the SID */ - func_len = locator->function_bits_length; - offset = locator->block_bits_length + locator->node_bits_length; - - /* Then, encode the FUNCTION */ - if (sid_func >= 0) { - /* SID FUNCTION has been specified. We need to allocate a SID - * with the requested FUNCTION. */ - encode_sid_func(&sid, sid_func, offset, func_len); - if (sid_exist(area, &sid)) { - zlog_warn( - "ISIS-SRv6 (%s): the requested SID %pI6 is already used", - area->area_tag, &sid); - return sid; - } - allocated = true; - } else { - /* SID FUNCTION not specified. We need to choose a FUNCTION that - * is not already used. So let's iterate through all possible - * functions and get the first available one. */ - func_max = (1 << func_len) - 1; - for (uint32_t func = 1; func < func_max; func++) { - encode_sid_func(&sid, func, offset, func_len); - if (sid_exist(area, &sid)) - continue; - allocated = true; - break; - } - } - - if (!allocated) { - /* We ran out of available SIDs */ - zlog_warn("ISIS-SRv6 (%s): no SIDs available in locator %s", - area->area_tag, locator->name); - return in6addr_any; - } - - sr_debug("ISIS-SRv6 (%s): allocating new SID %pI6", area->area_tag, - &sid); - - return sid; -} - -/** * Allocate an SRv6 SID from an SRv6 locator. * * @param area IS-IS area |
