thom311 / libnl

Netlink Library Suite
GNU Lesser General Public License v2.1
419 stars 311 forks source link

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

Closed KanjiMonster closed 3 months ago

KanjiMonster commented 3 months ago

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.

KanjiMonster commented 3 months ago

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 commented 3 months ago

merged as dcb9e2ef8c625aaa029915cd41705d0713f53332. Thank you!!