git: 93a3fa41dcff - main - pfsync: fix defer timeout

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 12:25:46 UTC
The branch main has been updated by kp:

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

commit 93a3fa41dcff274180133712a13392d17a3e75a1
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-12-02 16:30:36 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-12-06 12:25:14 +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
---
 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 a991c7ce5c7f..244e619bbe46 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 *,
 		    struct pf_kstate *);
 
 #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)
@@ -1769,7 +1770,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);