Thread View: muc.lists.freebsd.bugs
2 messages
2 total messages
Started by bugzilla-noreply
Mon, 16 Nov 2026 19:14
[Bug 300824] pfsync: valid bulk update end mark rejected as "bad timestamp" when the peers' uptime seconds tick over at differen...
Author: bugzilla-noreply
Date: Mon, 16 Nov 2026 19:14
Date: Mon, 16 Nov 2026 19:14
109 lines
7178 bytes
7178 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300824
Bug ID: 300824
Summary: pfsync: valid bulk update end mark rejected as "bad
timestamp" when the peers' uptime seconds tick over at
different moments
Product: Base System
Version: 16.0-CURRENT
Hardware: Any
URL: https://github.com/freebsd/freebsd-src/pull/2545
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: andrew.luebke@gmail.com
CC: kp@freebsd.org
A node that requests a pfsync bulk update can reject its peer's end mark
as "bad timestamp" although the update completed. The end mark is sent
once, so the node stays demoted in CARP ("pfsync bulk start", +240) with
syncok: 0 until the bulk fail timeout. On our OPNsense 26.7 CARP pair
(FreeBSD 15.1 base) the rebooted node stayed demoted for just under two
hours, twice in August (hz=100), and it happened again on 2026-11-10.
Since then a workaround script (see the end) has caught the same stuck
state on 2 of the pair's 10 reboots.
Code as of main b3860403a (if_pfsync.c has not changed in main since;
stable/15 has the same code at other line numbers),
sys/netpfil/pf/if_pfsync.c:
- The requester sets sc_ureq_sent = time_uptime when it asks for the
update (pfsync_kstatus_to_softc, line 3297).
- The sender sets sc_ureq_received = time_uptime when the request arrives
(pfsync_bulk_start, line 2676) and puts time_uptime - sc_ureq_received
in the end mark (pfsync_bulk_status, line 2758).
- The requester accepts the end mark only if
time_uptime - endtime >= sc_ureq_sent (pfsync_in_bus, line 1624).
Each side counts whole seconds of its own uptime, and the two clocks tick
over at different instants. When the sender's second ticks over during
the bulk and the requester's does not, endtime is one more than the
requester's own count and a valid mark is rejected. Example:
requester asks at its uptime 1000.1 sc_ureq_sent = 1000
request reaches the sender at its 5000.9 sc_ureq_received = 5000
bulk takes 0.3 s, ends at the sender's 5001.2 endtime = 1
end mark arrives at the requester's 1000.4 1000 - 1 = 999 < 1000: rejected
After that, the bulk fail timer armed by the start mark runs out:
4 * hz + limit / ((mtu - PFSYNC_MINPKT) / sizeof(union pfsync_state_union))
ticks. With a 2,097,152 state limit and MTU 1500 that is 703 s at
hz=1000 and 6,994 s at hz=100. pfsync_bulk_fail then asks again without
updating sc_ureq_sent, so the next end mark passes and the node
recovers. While it waits the node already holds the full state table;
only the demotion and syncok are wrong.
How often: with f the fractional part of the bulk's duration in seconds,
the share of rejected requests averaged over clock offsets is f(1 - f),
so at most 25%. For one pair of running clocks it can be up to
min(f, 1 - f). A bulk of 20,000 states took about 0.56 s on our 6-CPU
test sender, close to the worst case.
It needs two machines (two VMs are enough). Two vnet jails on one kernel
share time_uptime, so the existing pfsync tests cannot hit it.
To reproduce:
1. Two hosts with pfsync between them on a dedicated link (syncdev,
syncpeer). CARP is not needed to see the rejection.
2. On the sender, make about 20,000 states that pfsync syncs, for example
UDP from many source ports through a keep state rule, with long UDP
timeouts.
3. On the requester, run "pfctl -x misc" so the verdict is printed, then
ask for a bulk with "ifconfig pfsync0 syncdev <if> syncpeer <addr>".
Repeat at least 5 s apart, at different points within the requester's
uptime second (we waited for a chosen fraction of
clock_gettime(CLOCK_UPTIME_PRECISE) before running ifconfig).
4. Some requests end with "pfsync: received invalid bulk update end: bad
timestamp" in dmesg and syncok: 0 in "ifconfig pfsync0".
Our results, two VMs on separate hosts, requests at 20 points spread
across the requester's uptime second:
- main b3860403a (INVARIANTS, WITNESS), 20,000 states: 14 of 40 rejected;
60,000 states: 6 of 20 rejected.
- stable/15, 20,000 states: 8 of 40 rejected.
- Forged end marks reporting the requester's wait plus 0, 1 and 2
seconds: accepted, rejected, rejected. Wait plus 1 is what a sender
reports when its second ticks over during the bulk, so this shows the
problem whatever the clock offset.
With one second of slack in the comparison the same runs had no rejects,
and the forged marks gave accepted, accepted, rejected.
Our workaround meanwhile is a boot script that, while syncok is 0, asks
for the bulk again at 0.9 s into the requester's uptime second.
As on the pull request: the analysis and this report were done with the
help of an LLM. No code is attached; the numbers come from our own test
machines.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300824] pfsync: valid bulk update end mark rejected as "bad timestamp" when the peers' uptime seconds tick over at differen...
Author: bugzilla-noreply
Date: Tue, 17 Nov 2026 01:25
Date: Tue, 17 Nov 2026 01:25
19 lines
2801 bytes
2801 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300824
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |maintainer-feedback?(pf@Fre
| |eBSD.org)
Assignee|bugs@FreeBSD.org |pf@FreeBSD.org
CC| |pf@FreeBSD.org
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads