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

route: add missing priority to route_keygen() debug print #388

Closed

Conversation

KanjiMonster
Copy link
Contributor

Route priority is part of the hash key calculation, but the debug print omitted it. This could cause seemingly identical values have different hash values.

Fix this by also printing the route priority, and reformat according to .clang-format.

Before:

DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x55fd326f7d50 key (fam 10 tos 0 table 254 addr fe80::/64) keysz 26 hash 0x18c
DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x55fd326f7fa0 key (fam 10 tos 0 table 254 addr fe80::/64) keysz 26 hash 0x278

After:

DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x558cfde91d50 key (fam 10 tos 0 table 254 prio 256 addr fe80::/64) keysz 26 hash 0x18c
DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x558cfde91fa0 key (fam 10 tos 0 table 254 prio 1024 addr fe80::/64) keysz 26 hash 0x278

I took the liberty of unbreaking the string, since breaking it can make it harder to grep for and the .clang-format says to not break strings. Even though this one is largely ungreppable with every second word being a format specifier.

Route priority is part of the hash key calculation, but the debug print
omitted it. This could cause seemingly identical values have different
hash values.

Fix this by also printing the route priority, and reformat according to
clang-format.

Before:

DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x55fd326f7d50 key (fam 10 tos 0 table 254 addr fe80::/64) keysz 26 hash 0x18c
DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x55fd326f7fa0 key (fam 10 tos 0 table 254 addr fe80::/64) keysz 26 hash 0x278

After:

DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x558cfde91d50 key (fam 10 tos 0 table 254 prio 256 addr fe80::/64) keysz 26 hash 0x18c
DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x558cfde91fa0 key (fam 10 tos 0 table 254 prio 1024 addr fe80::/64) keysz 26 hash 0x278

Signed-off-by: Jonas Gorski <[email protected]>
@KanjiMonster
Copy link
Contributor Author

This confused me quite a while why these two routes got different hashes while all values were identical, until I noticed that the prio was part of the hash, but not printed.

thom311 pushed a commit that referenced this pull request May 17, 2024
Route priority is part of the hash key calculation, but the debug print
omitted it. This could cause seemingly identical values have different
hash values.

Fix this by also printing the route priority, and reformat according to
clang-format.

Before:

DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x55fd326f7d50 key (fam 10 tos 0 table 254 addr fe80::/64) keysz 26 hash 0x18c
DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x55fd326f7fa0 key (fam 10 tos 0 table 254 addr fe80::/64) keysz 26 hash 0x278

After:

DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x558cfde91d50 key (fam 10 tos 0 table 254 prio 256 addr fe80::/64) keysz 26 hash 0x18c
DBG<5>lib/route/route_obj.c:378  route_keygen: route 0x558cfde91fa0 key (fam 10 tos 0 table 254 prio 1024 addr fe80::/64) keysz 26 hash 0x278

Signed-off-by: Jonas Gorski <[email protected]>

#388
@thom311
Copy link
Owner

thom311 commented May 17, 2024

merged as dcb9e2e. Thank you!!

@thom311 thom311 closed this May 17, 2024
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