Skip to content

pfroute: parse routing messages on NetBSD correctly - #5073

Merged
gpotter2 merged 3 commits into
secdev:masterfrom
evverx:netbsd-followups
Aug 6, 2026
Merged

pfroute: parse routing messages on NetBSD correctly#5073
gpotter2 merged 3 commits into
secdev:masterfrom
evverx:netbsd-followups

Conversation

@evverx

@evverx evverx commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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.ifaces and conf.route look correct, conf.route.route no longer complains about the missing default route and so on.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.51%. Comparing base (c5e3b35) to head (11dcd61).

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     
Files with missing lines Coverage Δ
scapy/arch/bpf/pfroute.py 92.64% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@evverx
evverx force-pushed the netbsd-followups branch 2 times, most recently from 7a49dce to 00a3ba4 Compare August 3, 2026 14:54
Comment thread test/regression.uts Outdated
evverx added 2 commits August 5, 2026 12:39
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
@evverx
evverx force-pushed the netbsd-followups branch from 00a3ba4 to 2c78fce Compare August 5, 2026 12:52
Comment thread scapy/arch/bpf/pfroute.py
def __init__(self, name):
if not IS_64BITS or DARWIN:
if (not IS_64BITS and not NETBSD) or DARWIN:
align = 4

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR looks pretty good. Is there a reason why it's in draft?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added the read_routes6 test as well and undrafted the PR.

with routing messages from NetBSD 11.0 i386

AI-Assisted: no
@evverx
evverx force-pushed the netbsd-followups branch from 2c78fce to 11dcd61 Compare August 5, 2026 17:58
@evverx
evverx marked this pull request as ready for review August 5, 2026 18:45
@gpotter2
gpotter2 merged commit 30b872b into secdev:master Aug 6, 2026
23 of 25 checks passed
@gpotter2

gpotter2 commented Aug 6, 2026

Copy link
Copy Markdown
Member

Thanks a lot for the PR !

polybassa pushed a commit to polybassa/scapy-1 that referenced this pull request Aug 7, 2026
* 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
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.

RTM_IFINFO routing messages aren't parsed correctly on NetBSD (32-bit)

2 participants