pfroute: parse routing messages on NetBSD correctly - #5073
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5073 +/- ##
=======================================
Coverage 80.51% 80.51%
=======================================
Files 390 390
Lines 96785 96785
=======================================
+ Hits 77925 77927 +2
+ Misses 18860 18858 -2
🚀 New features to boost your workflow:
|
7a49dce to
00a3ba4
Compare
NetBSD switched to 64-bit time_t in https://www.netbsd.org/releases/formal-6/NetBSD-6.0.html so the size of struct timespec is (8+4) bytes. Closes: secdev#5054 AI-Assisted: no
NetBSD switched to uint64_t in NetBSD/src@23cb540 to make the routing socket interface act identically for both 32 and 64 bit programs. AI-Assisted: no
00a3ba4 to
2c78fce
Compare
| def __init__(self, name): | ||
| if not IS_64BITS or DARWIN: | ||
| if (not IS_64BITS and not NETBSD) or DARWIN: | ||
| align = 4 |
There was a problem hiding this comment.
Apart from fixing the issue where the default route was missing it also brings IPv6 addresses/routes to conf.ifaces and conf.route6. Without this only the IPv4 stack is visible (even though sniff captures IPv6 packets just fine). I'll add a test for read_routes6 too and double-check it.
Fun fact: it turns out avahi doesn't parse those things on 32-bit NetBSD machines either due to basically the same bug where it uses sizeof(long) to round up sockaddrs in https://github.com/avahi/avahi/blob/da2c583bb14299d9c53fd03056f8befb8f147078/avahi-core/iface-pfroute.c#L136-L137 so it only advertises IPv4 addresses.
There was a problem hiding this comment.
This PR looks pretty good. Is there a reason why it's in draft?
There was a problem hiding this comment.
When I opened the PR there were no unit tests. I added the read_routes test but the read_routes6 test is still missing (and I haven't tested the IPv6 part extensively locally yet either).
There was a problem hiding this comment.
I added the read_routes6 test as well and undrafted the PR.
with routing messages from NetBSD 11.0 i386 AI-Assisted: no
2c78fce to
11dcd61
Compare
|
Thanks a lot for the PR ! |
* pfroute: adjust the size of ifi_lastchange on NetBSD NetBSD switched to 64-bit time_t in https://www.netbsd.org/releases/formal-6/NetBSD-6.0.html so the size of struct timespec is (8+4) bytes. Closes: secdev#5054 AI-Assisted: no * pfroute: round up sockaddrs on NetBSD correctly NetBSD switched to uint64_t in NetBSD/src@23cb540 to make the routing socket interface act identically for both 32 and 64 bit programs. AI-Assisted: no * tests: exercise read_routes/read_routes6 with routing messages from NetBSD 11.0 i386 AI-Assisted: no
pfroute: adjust the size of ifi_lastchange on NetBSD
NetBSD switched to 64-bit time_t in
https://www.netbsd.org/releases/formal-6/NetBSD-6.0.html so the size of
struct timespec is (8+4) bytes.
Closes: #5054
pfroute: round up sockaddrs on NetBSD correctly
NetBSD switched to uint64_t in
NetBSD/src@23cb540
to make the routing socket interface act identically for both 32 and 64
bit programs.
It's a draft because it needs tests and more testing in general but with this PR applied scapy no longer fails to start,
conf.ifacesandconf.routelook correct,conf.route.routeno longer complains about the missing default route and so on.