summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
authorOlivier Dugeon <olivier.dugeon@orange.com>2023-12-07 14:53:16 +0100
committerOlivier Dugeon <olivier.dugeon@orange.com>2023-12-08 13:47:34 +0100
commit397dbbcae6083a00f30ad8310160650ec7ac7a87 (patch)
tree67420b51cb458090ffdc2b8415503eac4a1e8d39 /ospfd
parentMerge pull request #14922 from louis-6wind/fix-bfd-static-source (diff)
downloadfrr-397dbbcae6083a00f30ad8310160650ec7ac7a87.tar.xz
frr-397dbbcae6083a00f30ad8310160650ec7ac7a87.zip
ospfd: Correct SID check size
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 <olivier.dugeon@orange.com>
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_ext.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c
index 75b58035a..d82c2146c 100644
--- a/ospfd/ospf_ext.c
+++ b/ospfd/ospf_ext.c
@@ -1734,8 +1734,12 @@ static uint16_t show_vty_ext_link_adj_sid(struct vty *vty,
struct tlv_header *tlvh)
{
struct ext_subtlv_adj_sid *top = (struct ext_subtlv_adj_sid *)tlvh;
+ uint8_t tlv_size;
- check_tlv_size(EXT_SUBTLV_ADJ_SID_SIZE, "Adjacency SID");
+ 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);
+ check_tlv_size(tlv_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",
@@ -1755,8 +1759,12 @@ 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;
+ uint8_t tlv_size;
- check_tlv_size(EXT_SUBTLV_LAN_ADJ_SID_SIZE, "Lan-Adjacency SID");
+ 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);
+ check_tlv_size(tlv_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",
@@ -1867,8 +1875,12 @@ static uint16_t show_vty_ext_pref_pref_sid(struct vty *vty,
{
struct ext_subtlv_prefix_sid *top =
(struct ext_subtlv_prefix_sid *)tlvh;
+ uint8_t tlv_size;
- check_tlv_size(EXT_SUBTLV_PREFIX_SID_SIZE, "Prefix SID");
+ 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);
+ check_tlv_size(tlv_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",