-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
There was a problem hiding this 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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes for sure.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
@Mergifyio backport stable/9.1 stable/9.0 |
✅ Backports have been created
|
ospfd: Correct SID check size (backport #14962)
ospfd: Correct SID check size (backport #14962)
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.