smoltcp-rs / smoltcp

a smol tcp/ip stack
BSD Zero Clause License
3.63k stars 402 forks source link

Add BPF support for FreeBSD #906

Closed jamwaffles closed 4 months ago

jamwaffles commented 4 months ago

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.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jamwaffles commented 4 months ago

Rapid! Thank you!