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

Add BPF support for FreeBSD #906

Merged
merged 1 commit into from
Feb 7, 2024
Merged

Add BPF support for FreeBSD #906

merged 1 commit into from
Feb 7, 2024

Conversation

jamwaffles
Copy link
Contributor

Adds support for FreeBSD to bpf.rs. This was tested on a FreeBSD system with an EtherCrab example which involves some reasonably complex networking.

The FreeBSD source code defines SIZEOF_BPF_HDR as 18 bytes, however during testing on a FreeBSD 14 system it was found that the size is actually 24 bytes, so that is what is used here in smoltcp when targeting FreeBSD. I'm open to corrections as I don't like just going of empirical evidence, but 18 bytes definitely did not work for the code I was testing with.

The other constants were checked against the FreeBSD source code and are correct, so those were just a matter of adding the target_os cfg parameters.

The FreeBSD [source
code](https://github.com/freebsd/freebsd-src/blob/b8afdda360e5915be3c2cf0d1438f511779b03db/sbin/ipf/ipf/bpf-ipf.h#L159)
defines `SIZEOF_BPF_HDR` as 18 bytes, however during testing on a
FreeBSD 14 system it was found that the size is actually 24 bytes, so
that is what is used here in `smoltcp` when targeting FreeBSD.
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5eced2a) 79.92% compared to head (340565e) 79.92%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #906   +/-   ##
=======================================
  Coverage   79.92%   79.92%           
=======================================
  Files          80       80           
  Lines       28234    28234           
=======================================
  Hits        22566    22566           
  Misses       5668     5668           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Dirbaio Dirbaio left a comment

Choose a reason for hiding this comment

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

thanks!

@Dirbaio Dirbaio added this pull request to the merge queue Feb 7, 2024
Merged via the queue into smoltcp-rs:main with commit f0d1fd9 Feb 7, 2024
14 checks passed
@jamwaffles jamwaffles deleted the freebsd branch February 7, 2024 20:29
@jamwaffles
Copy link
Contributor Author

Rapid! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants