Skip to content

Commit 15abfb1

Browse files
committed
isisd: Pack Node MSD Sub-TLV for SRv6
Extend Router Capabilities TLV pack function to pack Node MSD Sub-TLV with the infomation relevant for SRv6 (RFC 9352 section sonic-net#4). Signed-off-by: Carmine Scarpitta <[email protected]>
1 parent 8d00f27 commit 15abfb1

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

isisd/isis_tlvs.c

+53
Original file line numberDiff line numberDiff line change
@@ -4235,6 +4235,7 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap,
42354235
{
42364236
size_t tlv_len, len_pos;
42374237
uint8_t nb_algo;
4238+
size_t subtlv_len, subtlv_len_pos;
42384239
bool sr_algo_subtlv_present = false;
42394240

42404241
if (!router_cap)
@@ -4391,6 +4392,58 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap,
43914392
router_cap->algo[i]);
43924393
}
43934394
}
4395+
4396+
/* And finish with MSDs if set as per RFC 9352 section #4 */
4397+
if (router_cap->srv6_msd.max_seg_left_msd +
4398+
router_cap->srv6_msd.max_end_pop_msd +
4399+
router_cap->srv6_msd.max_h_encaps_msd +
4400+
router_cap->srv6_msd.max_end_d_msd !=
4401+
0) {
4402+
stream_putc(s, ISIS_SUBTLV_NODE_MSD);
4403+
4404+
subtlv_len_pos = stream_get_endp(s);
4405+
/* Put 0 as Sub-TLV length for now, real length will be
4406+
* adjusted later */
4407+
stream_putc(s, 0);
4408+
4409+
/* RFC 9352 section #4.1 */
4410+
if (router_cap->srv6_msd.max_seg_left_msd != 0) {
4411+
stream_putc(s, ISIS_SUBTLV_SRV6_MAX_SL_MSD);
4412+
stream_putc(
4413+
s,
4414+
router_cap->srv6_msd.max_seg_left_msd);
4415+
}
4416+
4417+
/* RFC 9352 section #4.2 */
4418+
if (router_cap->srv6_msd.max_end_pop_msd != 0) {
4419+
stream_putc(s,
4420+
ISIS_SUBTLV_SRV6_MAX_END_POP_MSD);
4421+
stream_putc(
4422+
s,
4423+
router_cap->srv6_msd.max_end_pop_msd);
4424+
}
4425+
4426+
/* RFC 9352 section #4.3 */
4427+
if (router_cap->srv6_msd.max_h_encaps_msd != 0) {
4428+
stream_putc(s,
4429+
ISIS_SUBTLV_SRV6_MAX_H_ENCAPS_MSD);
4430+
stream_putc(
4431+
s,
4432+
router_cap->srv6_msd.max_h_encaps_msd);
4433+
}
4434+
4435+
/* RFC 9352 section #4.4 */
4436+
if (router_cap->srv6_msd.max_end_d_msd != 0) {
4437+
stream_putc(s, ISIS_SUBTLV_SRV6_MAX_END_D_MSD);
4438+
stream_putc(s,
4439+
router_cap->srv6_msd.max_end_d_msd);
4440+
}
4441+
4442+
/* Adjust Node MSD Sub-TLV length which depends on MSDs
4443+
* presence */
4444+
subtlv_len = stream_get_endp(s) - subtlv_len_pos - 1;
4445+
stream_putc_at(s, subtlv_len_pos, subtlv_len);
4446+
}
43944447
}
43954448

43964449
/* Adjust TLV length which depends on subTLVs presence */

0 commit comments

Comments
 (0)