git: d6163ad0d9ef - stable/12 - altq: Fix panics on rmc_restart()

Kristof Provost kp at FreeBSD.org
Mon Aug 30 09:18:17 UTC 2021


The branch stable/12 has been updated by kp:

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

commit d6163ad0d9ef7098ba58f77c792166efe32db8cb
Author:     Kristof Provost <kp at FreeBSD.org>
AuthorDate: 2021-08-21 11:42:27 +0000
Commit:     Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-08-30 09:15:24 +0000

    altq: Fix panics on rmc_restart()
    
    rmc_restart() is called from a timer, but can trigger traffic. This
    means the curvnet context will not be set.
    Use the vnet associated with the interface we're currently processing to
    set it. We also have to enter net_epoch here, for the same reason.
    
    Reviewed by:    mjg
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D31642
    
    (cherry picked from commit 159258afb50ad57f7ed27fe86ded83a7b3a26f90)
---
 sys/net/altq/altq_rmclass.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/net/altq/altq_rmclass.c b/sys/net/altq/altq_rmclass.c
index 655b5da724cb..288821867b3a 100644
--- a/sys/net/altq/altq_rmclass.c
+++ b/sys/net/altq/altq_rmclass.c
@@ -1567,7 +1567,9 @@ rmc_restart(struct rm_class *cl)
 	int		 s;
 
 	s = splnet();
+	NET_EPOCH_ENTER();
 	IFQ_LOCK(ifd->ifq_);
+	CURVNET_SET(ifd->ifq_->altq_ifp->if_vnet);
 	if (cl->sleeping_) {
 		cl->sleeping_ = 0;
 		cl->undertime_.tv_sec = 0;
@@ -1577,7 +1579,9 @@ rmc_restart(struct rm_class *cl)
 			(ifd->restart)(ifd->ifq_);
 		}
 	}
+	CURVNET_RESTORE();
 	IFQ_UNLOCK(ifd->ifq_);
+	NET_EPOCH_EXIT();
 	splx(s);
 }
 


More information about the dev-commits-src-all mailing list