Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ospfd: Correct SID check size #14962

Merged
merged 1 commit into from
Dec 10, 2023
Merged

Conversation

odd22
Copy link
Member

@odd22 odd22 commented Dec 7, 2023

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.

Copy link
Member

@donaldsharp donaldsharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small changes please

ospfd/ospf_ext.c Outdated
@@ -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");
if (CHECK_FLAG(top->flags, EXT_SUBTLV_LINK_ADJ_SID_VFLG))
check_tlv_size(EXT_SUBTLV_ADJ_SID_SIZE - 1, "Adjacency SID");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be something like EXT_SUBTLV_ADJ_SID_MPLS_LABEL_SIZE and the next one be EXT_SUBTLV_ADJ_SID_INDEX_SIZE?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This imply to add 2 new defines as there is only one define per TLV. Let me know if you prefer to leave the code as is or add these 2 new defines for ADJ, LAN_ADJ and PREFIX SID.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 new defines as needed. adding or subtracting 1 from a define just leaves people questioning why the define was not good enough

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (value_type == SID_LABEL) {
SET_FLAG(flags, EXT_SUBTLV_LINK_ADJ_SID_VFLG);
TLV_LEN(exti->adj_sid[index]) =
htons(SID_LABEL_SIZE(EXT_SUBTLV_ADJ_SID_SIZE));
exti->adj_sid[index].value = htonl(SET_LABEL(value));
} else {
UNSET_FLAG(flags, EXT_SUBTLV_LINK_ADJ_SID_VFLG);
TLV_LEN(exti->adj_sid[index]) =
htons(SID_INDEX_SIZE(EXT_SUBTLV_ADJ_SID_SIZE));
exti->adj_sid[index].value = htonl(value);
}

:I recommend the same usage as above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes of course. I forgot that I'm written these macro for this explicit usage.
Thanks for the reminder.

I just uploaded new version of the PR with these macros.

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]>
@donaldsharp donaldsharp merged commit f6864ec into FRRouting:master Dec 10, 2023
77 checks passed
@ton31337
Copy link
Member

@Mergifyio backport stable/9.1 stable/9.0

Copy link

mergify bot commented Dec 11, 2023

backport stable/9.1 stable/9.0

✅ Backports have been created

donaldsharp added a commit that referenced this pull request Dec 11, 2023
donaldsharp added a commit that referenced this pull request Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants