git: 12ae3476f35c - main - tcp_drain(): initialize the inpcb iterator when curvnet is set

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Fri, 03 Dec 2021 05:10:07 UTC
The branch main has been updated by glebius:

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

commit 12ae3476f35c1f7c0e8cb55444728ed04c7130f9
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2021-12-03 05:08:30 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2021-12-03 05:08:30 +0000

    tcp_drain(): initialize the inpcb iterator when curvnet is set
    
    Reported by:    cy
    Pointy hat to:  glebius
    Fixes:          de2d47842e88
---
 sys/netinet/tcp_subr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 5b5df6821e6a..86417aad5836 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -2613,8 +2613,6 @@ tcp_close(struct tcpcb *tp)
 void
 tcp_drain(void)
 {
-	struct inpcb_iterator inpi = INP_ALL_ITERATOR(&V_tcbinfo,
-	    INPLOOKUP_WLOCKPCB);
 	VNET_ITERATOR_DECL(vnet_iter);
 
 	if (!do_tcpdrain)
@@ -2623,6 +2621,8 @@ tcp_drain(void)
 	VNET_LIST_RLOCK_NOSLEEP();
 	VNET_FOREACH(vnet_iter) {
 		CURVNET_SET(vnet_iter);
+		struct inpcb_iterator inpi = INP_ALL_ITERATOR(&V_tcbinfo,
+		    INPLOOKUP_WLOCKPCB);
 		struct inpcb *inpb;
 		struct tcpcb *tcpb;