diff options
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 1e4c76d2b827..59792d283ff8 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -1084,9 +1084,12 @@ static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, | |||
1084 | { | 1084 | { |
1085 | struct tcp_sock *tp = tcp_sk(sk); | 1085 | struct tcp_sock *tp = tcp_sk(sk); |
1086 | struct inet_sock *inet = inet_sk(sk); | 1086 | struct inet_sock *inet = inet_sk(sk); |
1087 | struct sockaddr *uaddr = msg->msg_name; | ||
1087 | int err, flags; | 1088 | int err, flags; |
1088 | 1089 | ||
1089 | if (!(sysctl_tcp_fastopen & TFO_CLIENT_ENABLE)) | 1090 | if (!(sysctl_tcp_fastopen & TFO_CLIENT_ENABLE) || |
1091 | (uaddr && msg->msg_namelen >= sizeof(uaddr->sa_family) && | ||
1092 | uaddr->sa_family == AF_UNSPEC)) | ||
1090 | return -EOPNOTSUPP; | 1093 | return -EOPNOTSUPP; |
1091 | if (tp->fastopen_req) | 1094 | if (tp->fastopen_req) |
1092 | return -EALREADY; /* Another Fast Open is in progress */ | 1095 | return -EALREADY; /* Another Fast Open is in progress */ |
@@ -1108,7 +1111,7 @@ static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, | |||
1108 | } | 1111 | } |
1109 | } | 1112 | } |
1110 | flags = (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0; | 1113 | flags = (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0; |
1111 | err = __inet_stream_connect(sk->sk_socket, msg->msg_name, | 1114 | err = __inet_stream_connect(sk->sk_socket, uaddr, |
1112 | msg->msg_namelen, flags, 1); | 1115 | msg->msg_namelen, flags, 1); |
1113 | /* fastopen_req could already be freed in __inet_stream_connect | 1116 | /* fastopen_req could already be freed in __inet_stream_connect |
1114 | * if the connection times out or gets rst | 1117 | * if the connection times out or gets rst |
@@ -2320,6 +2323,10 @@ int tcp_disconnect(struct sock *sk, int flags) | |||
2320 | tcp_set_ca_state(sk, TCP_CA_Open); | 2323 | tcp_set_ca_state(sk, TCP_CA_Open); |
2321 | tcp_clear_retrans(tp); | 2324 | tcp_clear_retrans(tp); |
2322 | inet_csk_delack_init(sk); | 2325 | inet_csk_delack_init(sk); |
2326 | /* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0 | ||
2327 | * issue in __tcp_select_window() | ||
2328 | */ | ||
2329 | icsk->icsk_ack.rcv_mss = TCP_MIN_MSS; | ||
2323 | tcp_init_send_head(sk); | 2330 | tcp_init_send_head(sk); |
2324 | memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); | 2331 | memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); |
2325 | __sk_dst_reset(sk); | 2332 | __sk_dst_reset(sk); |