Skip to content

Commit

Permalink
ospfd: Correct SID check size
Browse files Browse the repository at this point in the history
Segment Router Identifier (SID) could be an index (4 bytes) within a range
(SRGB or SRLB) or an MPLS label (3 bytes). Thus, before calling check_size
macro to verify SID TLVs size, it is mandatory to determine the SID type to
avoid wrong assert.

Signed-off-by: Olivier Dugeon <[email protected]>
  • Loading branch information
odd22 committed Dec 8, 2023
1 parent cad5ee5 commit 2a821bb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ospfd/ospf_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,10 @@ static uint16_t show_vty_ext_link_adj_sid(struct vty *vty,
{
struct ext_subtlv_adj_sid *top = (struct ext_subtlv_adj_sid *)tlvh;

check_tlv_size(EXT_SUBTLV_ADJ_SID_SIZE, "Adjacency SID");
check_tlv_size(CHECK_FLAG(top->flags, EXT_SUBTLV_LINK_ADJ_SID_VFLG)
? SID_LABEL_SIZE(EXT_SUBTLV_ADJ_SID_SIZE)
: SID_INDEX_SIZE(EXT_SUBTLV_ADJ_SID_SIZE),
"Adjacency SID");

vty_out(vty,
" Adj-SID Sub-TLV: Length %u\n\tFlags: 0x%x\n\tMT-ID:0x%x\n\tWeight: 0x%x\n\t%s: %u\n",
Expand All @@ -1756,7 +1759,10 @@ static uint16_t show_vty_ext_link_lan_adj_sid(struct vty *vty,
struct ext_subtlv_lan_adj_sid *top =
(struct ext_subtlv_lan_adj_sid *)tlvh;

check_tlv_size(EXT_SUBTLV_LAN_ADJ_SID_SIZE, "Lan-Adjacency SID");
check_tlv_size(CHECK_FLAG(top->flags, EXT_SUBTLV_LINK_ADJ_SID_VFLG)
? SID_LABEL_SIZE(EXT_SUBTLV_LAN_ADJ_SID_SIZE)
: SID_INDEX_SIZE(EXT_SUBTLV_LAN_ADJ_SID_SIZE),
"LAN-Adjacency SID");

vty_out(vty,
" LAN-Adj-SID Sub-TLV: Length %u\n\tFlags: 0x%x\n\tMT-ID:0x%x\n\tWeight: 0x%x\n\tNeighbor ID: %pI4\n\t%s: %u\n",
Expand Down Expand Up @@ -1868,7 +1874,10 @@ static uint16_t show_vty_ext_pref_pref_sid(struct vty *vty,
struct ext_subtlv_prefix_sid *top =
(struct ext_subtlv_prefix_sid *)tlvh;

check_tlv_size(EXT_SUBTLV_PREFIX_SID_SIZE, "Prefix SID");
check_tlv_size(CHECK_FLAG(top->flags, EXT_SUBTLV_PREFIX_SID_VFLG)
? SID_LABEL_SIZE(EXT_SUBTLV_PREFIX_SID_SIZE)
: SID_INDEX_SIZE(EXT_SUBTLV_PREFIX_SID_SIZE),
"Prefix SID");

vty_out(vty,
" Prefix SID Sub-TLV: Length %u\n\tAlgorithm: %u\n\tFlags: 0x%x\n\tMT-ID:0x%x\n\t%s: %u\n",
Expand Down

0 comments on commit 2a821bb

Please sign in to comment.