Created
August 13, 2019 03:29
-
-
Save ozaki-r/d2c5c498848bc3d73e1d0298e28711bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit a0b8622b34a7a865eee497dbb8e844f0e39383dd | |
Author: Ryota Ozaki <ozaki.ryota@gmail.com> | |
Date: Tue Aug 13 12:04:03 2019 +0900 | |
fix tcp panic | |
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c | |
index c89dc0f4d57..fc0a7a3fd9d 100644 | |
--- a/sys/kern/uipc_socket.c | |
+++ b/sys/kern/uipc_socket.c | |
@@ -886,6 +886,7 @@ sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, | |
long space, len, resid, clen, mlen; | |
int error, s, dontroute, atomic; | |
short wakeup_state = 0; | |
+ bool need_connect = false; | |
clen = 0; | |
@@ -937,6 +938,7 @@ sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, | |
error = ENOTCONN; | |
goto release; | |
} | |
+ need_connect = true; | |
} else if (addr == NULL) { | |
error = EDESTADDRREQ; | |
goto release; | |
@@ -1051,6 +1053,23 @@ sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, | |
so->so_options |= SO_DONTROUTE; | |
if (resid > 0) | |
so->so_state |= SS_MORETOCOME; | |
+ | |
+ if (need_connect) { | |
+ if (addr == NULL) { | |
+ error = EDESTADDRREQ; | |
+ goto release; | |
+ } | |
+ if (addr->sa_family != | |
+ so->so_proto->pr_domain->dom_family) { | |
+ error = EAFNOSUPPORT; | |
+ goto release; | |
+ } | |
+ error = (*so->so_proto->pr_usrreqs->pr_connect)( | |
+ so, addr, l); | |
+ if (error != 0) | |
+ goto release; | |
+ } | |
+ | |
if (flags & MSG_OOB) { | |
error = (*so->so_proto->pr_usrreqs->pr_sendoob)( | |
so, top, control); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment