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

bgp: turn RouteFamily into uint32 #2577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vincentbernat
Copy link
Contributor

  1. On 64-bit platform, it takes less space to store an uint32 because an int is equivalent to int64. An uint32 is enough as AFI is 16-bit and SAFI is 8-bit.

  2. On 32-bit platform, int is int32 and it is not big enough to encode all route families, notably the ones with AFI > 2**15. At runtime, this is not a problem, however, at compile time, we get an error.

1. On 64-bit platform, it takes less space to store an uint32 because
   an int is equivalent to int64. An uint32 is enough as AFI is 16-bit
   and SAFI is 8-bit.

2. On 32-bit platform, int is int32 and it is not big enough to encode
   all route families, notably the ones with AFI > 2**15. At runtime,
   this is not a problem, however, at compile time, we get an error.
@vincentbernat vincentbernat marked this pull request as ready for review September 20, 2022 18:13
@fujita
Copy link
Member

fujita commented Sep 20, 2022

makes sense but is it possible that this breaks the existing code?

@vincentbernat
Copy link
Contributor Author

I am unsure. You cannot store to an int without casting. I am unable to find a case where it would break.

@fujita
Copy link
Member

fujita commented Sep 23, 2022

I prefer keep this open until the next major release because I'm not completely sure that this doesn't break anything.

@vincentbernat
Copy link
Contributor Author

vincentbernat commented Sep 23, 2022 via email

vincentbernat added a commit to akvorado/akvorado that referenced this pull request Nov 11, 2022
1. Coerce `bgp.RouteFamily` to an uint32. See
   osrg/gobgp#2577.

2. Order structure members in descending order of their sizes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants