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: When calling bgp_process, prevent infinite loop #17641

Merged

Conversation

donaldsharp
Copy link
Member

If we have this construct:

for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
...
bgp_process();
}

This can induce an infinite loop. This happens because bgp_process will move the unsorted items to the top of the list for handling, as such it is necessary to hold the next pointer to the side to actually look at each possible bgp_path_info.

If we have this construct:

for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
     ...
     bgp_process();
}

This can induce an infinite loop.  This happens because bgp_process
will move the unsorted items to the top of the list for handling,
as such it is necessary to hold the next pointer to the side
to actually look at each possible bgp_path_info.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
@ton31337
Copy link
Member

How can we prevent from happening/using this pattern in the future?

@donaldsharp
Copy link
Member Author

I already went down that path and didn't have a great answer other than watching it. It will become evident when we get in a infinite loop real quick though.

@Jafaral
Copy link
Member

Jafaral commented Dec 13, 2024

@Mergifyio backport stable/10.2

Copy link

mergify bot commented Dec 13, 2024

backport stable/10.2

✅ Backports have been created

@Jafaral Jafaral merged commit 38c2505 into FRRouting:master Dec 13, 2024
14 checks passed
ton31337 added a commit that referenced this pull request Dec 13, 2024
bgpd: When calling bgp_process, prevent infinite loop (backport #17641)
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.

3 participants