aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2021-12-28 16:50:02 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2021-12-28 16:50:02 +0000
commit4287aa56197fc2e37cad07c23b52f9ed4f1a7fd0 (patch)
treeb886e734afc3b5ecd00bccfc0f47bef28e931320
parentf7926a6d0c1029c8da265769e7c57b4065faa2df (diff)
downloadsrc-4287aa56197fc2e37cad07c23b52f9ed4f1a7fd0.tar.gz
src-4287aa56197fc2e37cad07c23b52f9ed4f1a7fd0.zip
-rw-r--r--sys/netinet/tcp_usrreq.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 2dea7253e0d6..def7d477c72b 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -993,34 +993,31 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
bool restoreflags;
TCPDEBUG0;
- /*
- * We require the pcbinfo "read lock" if we will close the socket
- * as part of this call.
- */
- NET_EPOCH_ENTER(et);
- inp = sotoinpcb(so);
- KASSERT(inp != NULL, ("tcp_usr_send: inp == NULL"));
- INP_WLOCK(inp);
- tp = intotcpcb(inp);
- vflagsav = inp->inp_vflag;
- incflagsav = inp->inp_inc.inc_flags;
- restoreflags = false;
- if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
- if (control)
- m_freem(control);
- error = ECONNRESET;
- goto out;
- }
if (control != NULL) {
/* TCP doesn't do control messages (rights, creds, etc) */
if (control->m_len) {
m_freem(control);
- error = EINVAL;
- goto out;
+ return (EINVAL);
}
m_freem(control); /* empty control, just free it */
- control = NULL;
}
+
+ inp = sotoinpcb(so);
+ KASSERT(inp != NULL, ("tcp_usr_send: inp == NULL"));
+ INP_WLOCK(inp);
+ if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
+ if (m != NULL && (flags & PRUS_NOTREADY) == 0)
+ m_freem(m);
+ INP_WUNLOCK(inp);
+ return (ECONNRESET);
+ }
+
+ vflagsav = inp->inp_vflag;
+ incflagsav = inp->inp_inc.inc_flags;
+ restoreflags = false;
+ tp = intotcpcb(inp);
+
+ NET_EPOCH_ENTER(et);
if ((flags & PRUS_OOB) != 0 &&
(error = tcp_pru_options_support(tp, PRUS_OOB)) != 0)
goto out;