MFC r302667
authortruckman <truckman@FreeBSD.org>
Mon, 18 Jul 2016 06:09:52 +0000 (06:09 +0000)
committertruckman <truckman@FreeBSD.org>
Mon, 18 Jul 2016 06:09:52 +0000 (06:09 +0000)
commit8a82654af3aa5b65efa78b88f4ad933019153887
tree3038545c120d0bdefa08a76b41030f37d4841949
parent204e0ef37ba4de4782f59a62f5cbea54c4474a5f
MFC r302667

Fix problems in the FQ-PIE AQM cleanup code that could leak memory or
cause a crash.

Because dummynet calls pie_cleanup() while holding a mutex, pie_cleanup()
is not able to use callout_drain() to make sure that all callouts are
finished before it returns, and callout_stop() is not sufficient to make
that guarantee.  After pie_cleanup() returns, dummynet will free a
structure that any remaining callouts will want to access.

Fix these problems by allocating a separate structure to contain the
data used by the callouts.  In pie_cleanup(), call callout_reset_sbt()
to replace the normal callout with a cleanup callout that does the cleanup
work for each sub-queue.  The instance of the cleanup callout that
destroys the last flow will also free the extra allocated block of memory.
Protect the reference count manipulation in the cleanup callout with
DN_BH_WLOCK() to be consistent with all of the other usage of the reference
count where this lock is held by the dummynet code.

Submitted by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
Differential Revision: https://reviews.freebsd.org/D7174
sys/netpfil/ipfw/dn_sched_fq_pie.c