File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
crates/shadowsocks/src/net/sys/unix Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ impl TcpStream {
5454
5555 let socket = unsafe {
5656 let fd = libc:: socket ( AF_MULTIPATH , libc:: SOCK_STREAM , libc:: IPPROTO_TCP ) ;
57+ if fd < 0 {
58+ let err = io:: Error :: last_os_error ( ) ;
59+ return Err ( err) ;
60+ }
5761 let socket = Socket :: from_raw_fd ( fd) ;
5862 socket. set_nonblocking ( true ) ?;
5963 TcpSocket :: from_raw_fd ( socket. into_raw_fd ( ) )
Original file line number Diff line number Diff line change @@ -213,12 +213,18 @@ pub fn set_tcp_fastopen<S: AsRawFd>(socket: &S) -> io::Result<()> {
213213}
214214
215215fn create_mptcp_socket ( bind_addr : & SocketAddr ) -> io:: Result < TcpSocket > {
216+ // https://www.kernel.org/doc/html/next/networking/mptcp.html
217+
216218 unsafe {
217219 let family = match bind_addr {
218220 SocketAddr :: V4 ( ..) => libc:: AF_INET ,
219221 SocketAddr :: V6 ( ..) => libc:: AF_INET6 ,
220222 } ;
221223 let fd = libc:: socket ( family, libc:: SOCK_STREAM , libc:: IPPROTO_MPTCP ) ;
224+ if fd < 0 {
225+ let err = io:: Error :: last_os_error ( ) ;
226+ return Err ( err) ;
227+ }
222228 let socket = Socket :: from_raw_fd ( fd) ;
223229 socket. set_nonblocking ( true ) ?;
224230 Ok ( TcpSocket :: from_raw_fd ( socket. into_raw_fd ( ) ) )
You can’t perform that action at this time.
0 commit comments