Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Oct 2011 15:08:18 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r226661 - head/sys/contrib/pf/net
Message-ID:  <201110231508.p9NF8Ifk043490@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Sun Oct 23 15:08:18 2011
New Revision: 226661
URL: http://svn.freebsd.org/changeset/base/226661

Log:
  - Fix a bad typo (FreeBSD specific) in pfsync_bulk_update(). Instead
    of scheduling next run pfsync_bulk_update(), pfsync_bulk_fail()
    was scheduled.
    This lead to instant 100% state leak after first bulk update
    request.
  - After above fix, it appeared that pfsync_bulk_update() lacks
    locking. To fix this, sc_bulk_tmo callout was converted to an
    mtx one. Eventually, all pf/pfsync callouts should be converted
    to mtx version, since it isn't possible to stop or drain a
    non-mtx callout without risk of race.
  - Add comment that callout_stop() in pfsync_clone_destroy() lacks
    locking. Since pfsync0 can't be destroyed (yet), let it be here.

Modified:
  head/sys/contrib/pf/net/if_pfsync.c

Modified: head/sys/contrib/pf/net/if_pfsync.c
==============================================================================
--- head/sys/contrib/pf/net/if_pfsync.c	Sun Oct 23 14:59:54 2011	(r226660)
+++ head/sys/contrib/pf/net/if_pfsync.c	Sun Oct 23 15:08:18 2011	(r226661)
@@ -493,7 +493,7 @@ pfsync_clone_create(struct if_clone *ifc
 	ifp->if_mtu = 1500; /* XXX */
 #ifdef __FreeBSD__
 	callout_init(&sc->sc_tmo, CALLOUT_MPSAFE);
-	callout_init(&sc->sc_bulk_tmo, CALLOUT_MPSAFE);
+	callout_init_mtx(&sc->sc_bulk_tmo, &pf_task_mtx, 0);
 	callout_init(&sc->sc_bulkfail_tmo, CALLOUT_MPSAFE);
 #else
 	ifp->if_hardmtu = MCLBYTES; /* XXX */
@@ -540,7 +540,7 @@ pfsync_clone_destroy(struct ifnet *ifp)
 #ifdef __FreeBSD__
 	EVENTHANDLER_DEREGISTER(ifnet_departure_event, sc->sc_detachtag);
 #endif
-	timeout_del(&sc->sc_bulk_tmo);
+	timeout_del(&sc->sc_bulk_tmo);	/* XXX: need PF_LOCK() before */
 	timeout_del(&sc->sc_tmo);
 #if NCARP > 0
 #ifdef notyet
@@ -3061,7 +3061,7 @@ pfsync_bulk_update(void *arg)
 			sc->sc_bulk_next = st;
 #ifdef __FreeBSD__
 			callout_reset(&sc->sc_bulk_tmo, 1,
-			    pfsync_bulk_fail, sc);
+			    pfsync_bulk_update, sc);
 #else
 			timeout_add(&sc->sc_bulk_tmo, 1);
 #endif



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