File tree 2 files changed +10
-0
lines changed
crates/shadowsocks/src/net/sys/unix
2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ impl TcpStream {
54
54
55
55
let socket = unsafe {
56
56
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
+ }
57
61
let socket = Socket :: from_raw_fd ( fd) ;
58
62
socket. set_nonblocking ( true ) ?;
59
63
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<()> {
213
213
}
214
214
215
215
fn create_mptcp_socket ( bind_addr : & SocketAddr ) -> io:: Result < TcpSocket > {
216
+ // https://www.kernel.org/doc/html/next/networking/mptcp.html
217
+
216
218
unsafe {
217
219
let family = match bind_addr {
218
220
SocketAddr :: V4 ( ..) => libc:: AF_INET ,
219
221
SocketAddr :: V6 ( ..) => libc:: AF_INET6 ,
220
222
} ;
221
223
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
+ }
222
228
let socket = Socket :: from_raw_fd ( fd) ;
223
229
socket. set_nonblocking ( true ) ?;
224
230
Ok ( TcpSocket :: from_raw_fd ( socket. into_raw_fd ( ) ) )
You can’t perform that action at this time.
0 commit comments