Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Mar 2017 05:42:57 +0000 (UTC)
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315136 - head/sys/netpfil/pf
Message-ID:  <201703120542.v2C5gvM4075391@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kp
Date: Sun Mar 12 05:42:57 2017
New Revision: 315136
URL: https://svnweb.freebsd.org/changeset/base/315136

Log:
  pf: Fix incorrect rw_sleep() in pf_unload()
  
  When we unload we don't hold the pf_rules_lock, so we cannot call rw_sleep()
  with it, because it would release a lock we do not hold. There's no need for the
  lock either, so we can just tsleep().
  
  While here also make the same change in pf_purge_thread(), because it explicitly
  takes the lock before rw_sleep() and then immediately releases it afterwards.

Modified:
  head/sys/netpfil/pf/pf.c
  head/sys/netpfil/pf/pf_ioctl.c

Modified: head/sys/netpfil/pf/pf.c
==============================================================================
--- head/sys/netpfil/pf/pf.c	Sun Mar 12 05:36:31 2017	(r315135)
+++ head/sys/netpfil/pf/pf.c	Sun Mar 12 05:42:57 2017	(r315136)
@@ -1429,9 +1429,7 @@ pf_purge_thread(void *unused __unused)
 	u_int idx = 0;
 
 	for (;;) {
-		PF_RULES_RLOCK();
-		rw_sleep(pf_purge_thread, &pf_rules_lock, 0, "pftm", hz / 10);
-		PF_RULES_RUNLOCK();
+		tsleep(pf_purge_thread, 0, "pftm", hz / 10);
 
 		VNET_LIST_RLOCK();
 		VNET_FOREACH(vnet_iter) {

Modified: head/sys/netpfil/pf/pf_ioctl.c
==============================================================================
--- head/sys/netpfil/pf/pf_ioctl.c	Sun Mar 12 05:36:31 2017	(r315135)
+++ head/sys/netpfil/pf/pf_ioctl.c	Sun Mar 12 05:42:57 2017	(r315136)
@@ -3791,7 +3791,7 @@ pf_unload(void)
 	pf_end_threads = 1;
 	while (pf_end_threads < 2) {
 		wakeup_one(pf_purge_thread);
-		rw_sleep(pf_purge_thread, &pf_rules_lock, 0, "pftmo", 0);
+		tsleep(pf_purge_thread, 0, "pftmo", 0);
 	}
 
 	if (pf_dev != NULL)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703120542.v2C5gvM4075391>