Skip to content

Commit

Permalink
isisd: Unpack Node MSD Sub-TLV with SRv6 MSDs
Browse files Browse the repository at this point in the history
The Router Capabilities TLV unpack function already unpacks the Node MSD
Sub-TLV.

This commit extends Router Capabilities TLV unpack function to extract
SRv6 MSDs from the Node MSD Sub-TLV (RFC 9352 section #4).

Signed-off-by: Carmine Scarpitta <[email protected]>
  • Loading branch information
cscarpitta committed Sep 11, 2023
1 parent 15abfb1 commit e417c2f
Showing 1 changed file with 57 additions and 9 deletions.
66 changes: 57 additions & 9 deletions isisd/isis_tlvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4464,6 +4464,7 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context,
uint8_t length;
uint8_t subtlv_len;
uint8_t size;
int num_msd;

sbuf_push(log, indent, "Unpacking Router Capability TLV...\n");
if (tlv_len < ISIS_ROUTER_CAP_SIZE) {
Expand Down Expand Up @@ -4632,19 +4633,66 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context,

break;
case ISIS_SUBTLV_NODE_MSD:
sbuf_push(log, indent,
"Unpacking Node MSD sub-TLV...\n");

/* Check that MSD is correctly formated */
if (length < MSD_TLV_SIZE) {
if (length % 2) {
sbuf_push(
log, indent,
"WARNING: Unexpected MSD sub-TLV length\n");
stream_forward_getp(s, length);
break;
}
msd_type = stream_getc(s);
rcap->msd = stream_getc(s);
/* Only BMI-MSD type has been defined in RFC 8491 */
if (msd_type != MSD_TYPE_BASE_MPLS_IMPOSITION)
rcap->msd = 0;
/* Only one MSD is standardized. Skip others */
if (length > MSD_TLV_SIZE)
stream_forward_getp(s, length - MSD_TLV_SIZE);

/* Get the number of MSDs carried in the value field of
* the Node MSD sub-TLV. The value field consists of one
* or more pairs of a 1-octet MSD-Type and 1-octet
* MSD-Value */
num_msd = length / 2;

/* Unpack MSDs */
for (int i = 0; i < num_msd; i++) {
msd_type = stream_getc(s);

switch (msd_type) {
case MSD_TYPE_BASE_MPLS_IMPOSITION:
/* BMI-MSD type as per RFC 8491 */
rcap->msd = stream_getc(s);
break;
case ISIS_SUBTLV_SRV6_MAX_SL_MSD:
/* SRv6 Maximum Segments Left MSD Type
* as per RFC 9352 section #4.1 */
rcap->srv6_msd.max_seg_left_msd =
stream_getc(s);
break;
case ISIS_SUBTLV_SRV6_MAX_END_POP_MSD:
/* SRv6 Maximum End Pop MSD Type as per
* RFC 9352 section #4.2 */
rcap->srv6_msd.max_end_pop_msd =
stream_getc(s);
break;
case ISIS_SUBTLV_SRV6_MAX_H_ENCAPS_MSD:
/* SRv6 Maximum H.Encaps MSD Type as per
* RFC 9352 section #4.3 */
rcap->srv6_msd.max_h_encaps_msd =
stream_getc(s);
break;
case ISIS_SUBTLV_SRV6_MAX_END_D_MSD:
/* SRv6 Maximum End D MSD Type as per
* RFC 9352 section #4.4 */
rcap->srv6_msd.max_end_d_msd =
stream_getc(s);
break;
default:
/* Unknown MSD, let's skip it */
sbuf_push(
log, indent,
"WARNING: Skipping unknown MSD Type %hhu (1 byte)\n",
msd_type);
stream_forward_getp(s, 1);
}
}
break;
#ifndef FABRICD
case ISIS_SUBTLV_FAD:
Expand Down

0 comments on commit e417c2f

Please sign in to comment.