Skip to content

Commit

Permalink
isisd: Pack SR-Algorithm Sub-TLV for SRv6
Browse files Browse the repository at this point in the history
Extend Router Capabilities TLV pack function to pack SR-Algorithm
Sub-TLV with infomation relevant for SRv6 (RFC 9352 section #3).

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
  • Loading branch information
cscarpitta committed Sep 11, 2023
1 parent b85ecd3 commit c8004f7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions isisd/isis_tlvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4235,6 +4235,7 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap,
{
size_t tlv_len, len_pos;
uint8_t nb_algo;
bool sr_algo_subtlv_present = false;

if (!router_cap)
return 0;
Expand Down Expand Up @@ -4268,6 +4269,7 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap,
for (int i = 0; i < SR_ALGORITHM_COUNT; i++)
if (router_cap->algo[i] != SR_ALGORITHM_UNSET)
stream_putc(s, router_cap->algo[i]);
sr_algo_subtlv_present = true;
}

/* Local Block if defined as per RFC8667 section #3.3 */
Expand Down Expand Up @@ -4371,6 +4373,24 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap,
stream_putc(s, ISIS_SUBTLV_SRV6_CAPABILITIES);
stream_putc(s, ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE);
stream_putw(s, router_cap->srv6_cap.flags);

/*
* Then add SR Algorithm if set and if we haven't already
* added it when we processed SR-MPLS related Sub-TLVs as
* per RFC 9352 section #3
*/
if (!sr_algo_subtlv_present) {
nb_algo = isis_tlvs_sr_algo_count(router_cap);
if (nb_algo > 0) {
stream_putc(s, ISIS_SUBTLV_ALGORITHM);
stream_putc(s, nb_algo);
for (int i = 0; i < SR_ALGORITHM_COUNT; i++)
if (router_cap->algo[i] !=
SR_ALGORITHM_UNSET)
stream_putc(s,
router_cap->algo[i]);
}
}
}

/* Adjust TLV length which depends on subTLVs presence */
Expand Down

0 comments on commit c8004f7

Please sign in to comment.