Skip to content

bpf: adjust bpf_ts on FreeBSD - #5077

Open
evverx wants to merge 1 commit into
secdev:masterfrom
evverx:freebsd-bpf-ts
Open

bpf: adjust bpf_ts on FreeBSD#5077
evverx wants to merge 1 commit into
secdev:masterfrom
evverx:freebsd-bpf-ts

Conversation

@evverx

@evverx evverx commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

to get scapy to capture packets on both 32-bit and 64-bit machines.

The bpf_ts structure contains two 64-bit fields:
https://github.com/freebsd/freebsd-src/blob/aea4240ef5834fb4a47f80c659c80f902cb4bb06/sys/net/bpf.h#L206-L209

struct bpf_ts {
	bpf_int64	bt_sec;		/* seconds */
	bpf_u_int64	bt_frac;	/* fraction */
};

and it has been this way since it was introduced in freebsd/freebsd-src@547d94b back in 2010.

Introduce new time stamp 'struct bpf_ts' and header 'struct bpf_xhdr'.
The new time stamp has both 64-bit second and fractional parts.  bpf_xhdr
has this time stamp instead of 'struct timeval' for bh_tstamp.  The new
structures let us use bh_tstamp of same size on both 32-bit and 64-bit
platforms without adding additional shims for 32-bit binaries.

It was tested on FreeBSD 14.4-RELEASE/i386 and 15.1-RELEASE-p2/amd64.

to get scapy to capture packets on both 32-bit and 64-bit machines.

The bpf_ts structure contains two 64-bit fields:
https://github.com/freebsd/freebsd-src/blob/aea4240ef5834fb4a47f80c659c80f902cb4bb06/sys/net/bpf.h#L206-L209
```
struct bpf_ts {
	bpf_int64	bt_sec;		/* seconds */
	bpf_u_int64	bt_frac;	/* fraction */
};
```
and it has been this way since it was introduced in
freebsd/freebsd-src@547d94b
back in 2010.
```
Introduce new time stamp 'struct bpf_ts' and header 'struct bpf_xhdr'.
The new time stamp has both 64-bit second and fractional parts.  bpf_xhdr
has this time stamp instead of 'struct timeval' for bh_tstamp.  The new
structures let us use bh_tstamp of same size on both 32-bit and 64-bit
platforms without adding additional shims for 32-bit binaries.
```

It was tested on FreeBSD 14.4-RELEASE/i386 and 15.1-RELEASE-p2/amd64.

AI-Assisted: no
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.31%. Comparing base (d8f7b27) to head (c68f0ab).

Files with missing lines Patch % Lines
scapy/arch/bpf/supersocket.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5077      +/-   ##
==========================================
- Coverage   80.48%   80.31%   -0.18%     
==========================================
  Files         390      390              
  Lines       96810    96810              
==========================================
- Hits        77917    77750     -167     
- Misses      18893    19060     +167     
Files with missing lines Coverage Δ
scapy/arch/bpf/supersocket.py 71.84% <0.00%> (ø)

... and 19 files with indirect coverage changes

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

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.

1 participant