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

lib.poptrie: fix bug where address bits where interpreted in reverse order #1495

Merged
merged 2 commits into from
Apr 7, 2023

Conversation

eugeneia
Copy link
Member

We used to shift in bits from right to left, thinking that since we are on little endian the addresses are strictly in reverse order. That is not the case! The bytes are swapped but the bits are not! :-)

In the x86 assembly routines we now do bswap and then shift down bits from right to left.

@eugeneia eugeneia added the bug label Feb 27, 2023
@eugeneia eugeneia self-assigned this Feb 27, 2023
Copy link
Contributor

@alexandergall alexandergall left a comment

Choose a reason for hiding this comment

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

Independently verified with Prefix->ASN mappings from the GeoLite2 ASN Maxmind database.

Do not maintain offset counter and repeatedly load key
and then shift it by offset.

Instead load key at beginning and shift it further
for each iteration.

This way we only have to do load/bswap once.
@eugeneia eugeneia added the release-caspar March 2023 release label Mar 15, 2023
@eugeneia eugeneia merged commit b223015 into snabbco:master Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug release-caspar March 2023 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants