git: ffc4301ba780 - stable/12 - pfsync: fix defer timeout

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 13 Dec 2021 13:50:37 UTC
The branch stable/12 has been updated by kp:

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

commit ffc4301ba780b2184b9a04348ca992ad8002e0ea
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-12-02 16:30:36 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-12-13 08:54:15 +0000

    pfsync: fix defer timeout
    
    Don't use a fixed number of ticks, but take hz into account so we have a
    consistent timeout, regardless of what hz is set up.
    Use a 20ms timeout, becaues that's what OpenBSD uses.
    
    Reviewed by:    glebius
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D33242
    
    (cherry picked from commit 93a3fa41dcff274180133712a13392d17a3e75a1)
---
 sys/netpfil/pf/if_pfsync.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index 301d963abd9c..ce4ad158e557 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -316,6 +316,7 @@ static struct pfsync_bucket	*pfsync_get_bucket(struct pfsync_softc *,
 
 
 #define PFSYNC_MAX_BULKTRIES	12
+#define PFSYNC_DEFER_TIMEOUT	((20 * hz) / 1000)
 
 VNET_DEFINE(struct if_clone *, pfsync_cloner);
 #define	V_pfsync_cloner	VNET(pfsync_cloner)
@@ -1771,7 +1772,7 @@ pfsync_defer(struct pf_kstate *st, struct mbuf *m)
 
 	TAILQ_INSERT_TAIL(&b->b_deferrals, pd, pd_entry);
 	callout_init_mtx(&pd->pd_tmo, &b->b_mtx, CALLOUT_RETURNUNLOCKED);
-	callout_reset(&pd->pd_tmo, 10, pfsync_defer_tmo, pd);
+	callout_reset(&pd->pd_tmo, PFSYNC_DEFER_TIMEOUT, pfsync_defer_tmo, pd);
 
 	pfsync_push(b);