git: 0d0c1ffcf4fc - stable/13 - tcp: tcp6_connect() requires net epoch

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 19 Sep 2022 15:50:42 UTC
The branch stable/13 has been updated by glebius:

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

commit 0d0c1ffcf4fc6d382887e89c5d8b0b7a270d0689
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-09-05 17:15:19 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-09-19 15:49:55 +0000

    tcp: tcp6_connect() requires net epoch
    
    PR:                     262663
    Reported & tested by:   dch
    
    (cherry picked from commit 0773b44e829421a806a89087009b294f16ee51fd)
---
 sys/netinet/tcp_usrreq.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 4f40fe4d7730..74bf2925870f 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -700,20 +700,18 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
 	inp->inp_vflag &= ~INP_IPV4;
 	inp->inp_vflag |= INP_IPV6;
 	inp->inp_inc.inc_flags |= INC_ISIPV6;
+	NET_EPOCH_ENTER(et);
 	if ((error = tcp6_connect(tp, nam, td)) != 0)
-		goto out;
+		goto out_in_epoch;
 #ifdef TCP_OFFLOAD
 	if (registered_toedevs > 0 &&
 	    (so->so_options & SO_NO_OFFLOAD) == 0 &&
 	    (error = tcp_offload_connect(so, nam)) == 0)
-		goto out;
+		goto out_in_epoch;
 #endif
 	tcp_timer_activate(tp, TT_KEEP, TP_KEEPINIT(tp));
-	NET_EPOCH_ENTER(et);
 	error = tp->t_fb->tfb_tcp_output(tp);
-#ifdef INET
 out_in_epoch:
-#endif
 	NET_EPOCH_EXIT(et);
 out:
 	/*