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

bgpd: fix mpls label pointer comparison #15236

Merged
merged 2 commits into from
Jan 28, 2024

Conversation

louis-6wind
Copy link
Contributor

Comparing pointers is not the appropriate way to know if the label values are the same or not. Perform a memcmp call instead is better.

Fixes: 8ba7105 ("bgpd: fix valgrind flagged errors")

bgpd/bgp_route.c Outdated
@@ -4710,7 +4710,8 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* Update MPLS label */
if (has_valid_label) {
extra = bgp_path_info_extra_get(pi);
if (extra->label != label) {
if (memcmp(&extra->label[0], &label[0],
Copy link
Member

Choose a reason for hiding this comment

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

why is bgp_labels_same insufficient?

Copy link
Member

Choose a reason for hiding this comment

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

I even think this is wrong now that I look at it some more. if label( that is passed in ) has 1 label in the array and extra->label has 2, we are not comparing anything of value here at all. Look at num_labels passed in as well as extra->num_labels they should be taken into account.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done - I had put it in draft form while I fixed it

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.

I believe BGP should be using bgp_labels_same() instead of this. Please adjust.

@louis-6wind louis-6wind marked this pull request as ready for review January 25, 2024 17:43
@donaldsharp
Copy link
Member

do you ahve a specific scenario where this failed? In other words how did you find it?

@ton31337
Copy link
Member

Oh, this seems not finished yet, compile issues.

Comparing pointers is not the appropriate way to know
if the label values are the same or not. Perform a
memcmp call instead is better.

Fixes: 8ba7105 ("bgpd: fix valgrind flagged errors")
Signed-off-by: Philippe Guibert <[email protected]>
Signed-off-by: Louis Scalbert <[email protected]>
@louis-6wind
Copy link
Contributor Author

do you ahve a specific scenario where this failed? In other words how did you find it?

No specific scenario. Just by working on extra->label to attr->label move

Use bgp_labels_same() for all label comparisons in bgpd.

Signed-off-by: Louis Scalbert <[email protected]>
@github-actions github-actions bot added size/S and removed size/XS labels Jan 26, 2024
@donaldsharp donaldsharp merged commit 4d92bad into FRRouting:master Jan 28, 2024
9 checks passed
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