The branch stable/15 has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=59409ef15769b0b08f1e86f446bb1c3fb105dbd4

commit 59409ef15769b0b08f1e86f446bb1c3fb105dbd4
Author:     Kristof Provost <[email protected]>
AuthorDate: 2026-11-26 16:44:36 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-12-04 18:36:51 +0000

    pfsync: account for second tickover in bulk updates
    
    When one peer requests a bulk update it keeps track of when it sent this
    request. The exporting peer includes 'endtime', indicating how long it
    took to send the entire update along with its final message.
    
    That allows the receiving peer to verify that the entire update was done
    in response to its most recent request. However, due to different second
    tickovers this calculation might be off by one.
    
    Use milliseconds internally. This does not change the wire protocol,
    'endtime' is still expressed in seconds. When the exporting peer
    computes this value it will implicitly round down.
    
    PR:             300824
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit f3cb62f798070570db00b51138873474c31bbc6a)
---
 sys/netpfil/pf/if_pfsync.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index 8ce0808527fe..c63a6a7d6180 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -272,9 +272,9 @@ struct pfsync_softc {
 
        /* Bulk update info */
        struct mtx              sc_bulk_mtx;
-       uint32_t                sc_ureq_sent;
+       uint64_t                sc_ureq_sent;
        int                     sc_bulk_tries;
-       uint32_t                sc_ureq_received;
+       uint64_t                sc_ureq_received;
        int                     sc_bulk_hashid;
        uint64_t                sc_bulk_stateid;
        uint32_t                sc_bulk_creatorid;
@@ -1635,8 +1635,8 @@ pfsync_in_bus(struct mbuf *m, int offset, int count, int 
flags, int action)
                break;
 
        case PFSYNC_BUS_END:
-               if (time_uptime - ntohl(bus->endtime) >=
-                   sc->sc_ureq_sent) {
+               if (pf_get_uptime() >= sc->sc_ureq_sent +
+                   (uint64_t)ntohl(bus->endtime) * 1000) {
                        /* that's it, we're happy */
                        sc->sc_ureq_sent = 0;
                        sc->sc_bulk_tries = 0;
@@ -2692,7 +2692,7 @@ pfsync_bulk_start(void)
 
        PFSYNC_BLOCK(sc);
 
-       sc->sc_ureq_received = time_uptime;
+       sc->sc_ureq_received = pf_get_uptime();
        sc->sc_bulk_hashid = 0;
        sc->sc_bulk_stateid = 0;
        pfsync_bulk_status(PFSYNC_BUS_START);
@@ -2735,7 +2735,8 @@ pfsync_bulk_update(void *arg)
                for (; s; s = LIST_NEXT(s, entry)) {
                        if (s->sync_state == PFSYNC_S_NONE &&
                            s->timeout < PFTM_MAX &&
-                           s->pfsync_time <= sc->sc_ureq_received) {
+                           (uint64_t)s->pfsync_time * 1000 <=
+                           sc->sc_ureq_received) {
                                if (pfsync_update_state_req(s)) {
                                        /* We've filled a packet. */
                                        sc->sc_bulk_hashid = i;
@@ -2774,7 +2775,7 @@ pfsync_bulk_status(u_int8_t status)
        V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_BUS]++;
 
        r.bus.creatorid = V_pf_status.hostid;
-       r.bus.endtime = htonl(time_uptime - sc->sc_ureq_received);
+       r.bus.endtime = htonl((pf_get_uptime() - sc->sc_ureq_received) / 1000);
        r.bus.status = status;
 
        pfsync_send_plus(&r, sizeof(r));
@@ -3313,7 +3314,7 @@ pfsync_kstatus_to_softc(struct pfsync_kstatus *status, 
struct pfsync_softc *sc)
        pfsync_request_update(0, 0);
        PFSYNC_BUCKET_UNLOCK(&sc->sc_buckets[0]);
        PFSYNC_BLOCK(sc);
-       sc->sc_ureq_sent = time_uptime;
+       sc->sc_ureq_sent = pf_get_uptime();
        callout_reset(&sc->sc_bulkfail_tmo, 5 * hz, pfsync_bulk_fail, sc);
        PFSYNC_BUNLOCK(sc);
        return (0);

Reply via email to