The NET_LOCK() is currently what guarantees that accesses to PF data
structures are serialized.
While here use rwsleep(9) instead of calling NET_LOCK()/NET_UNLOCK()
for every iteration.
Tested by Hrvoje Popovski, ok sashan@, visa@
-/* $OpenBSD: pf.c,v 1.1035 2017/06/21 15:29:23 bluhm Exp $ */
+/* $OpenBSD: pf.c,v 1.1036 2017/07/03 08:11:21 mpi Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
{
int nloops = 0, s;
+ KERNEL_UNLOCK();
+
+ NET_LOCK(s);
for (;;) {
- tsleep(pf_purge_thread, PWAIT, "pftm", 1 * hz);
+ rwsleep(pf_purge_thread, &netlock, PWAIT, "pftm", 1 * hz);
- NET_LOCK(s);
PF_LOCK();
/* process a fraction of the state table every second */
pf_purge_expired_fragments();
nloops = 0;
}
-
- NET_UNLOCK(s);
}
+ NET_UNLOCK(s);
}
int32_t