Merge tag 'y2038-cleanups-5.5' of git://git.kernel.org:/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / net / ipv4 / tcp.c
index 013f635..8a39ee7 100644 (file)
@@ -1741,8 +1741,8 @@ static int tcp_zerocopy_receive(struct sock *sk,
                                struct tcp_zerocopy_receive *zc)
 {
        unsigned long address = (unsigned long)zc->address;
+       u32 length = 0, seq, offset, zap_len;
        const skb_frag_t *frags = NULL;
-       u32 length = 0, seq, offset;
        struct vm_area_struct *vma;
        struct sk_buff *skb = NULL;
        struct tcp_sock *tp;
@@ -1769,12 +1769,12 @@ static int tcp_zerocopy_receive(struct sock *sk,
        seq = tp->copied_seq;
        inq = tcp_inq(sk);
        zc->length = min_t(u32, zc->length, inq);
-       zc->length &= ~(PAGE_SIZE - 1);
-       if (zc->length) {
-               zap_page_range(vma, address, zc->length);
+       zap_len = zc->length & ~(PAGE_SIZE - 1);
+       if (zap_len) {
+               zap_page_range(vma, address, zap_len);
                zc->recv_skip_hint = 0;
        } else {
-               zc->recv_skip_hint = inq;
+               zc->recv_skip_hint = zc->length;
        }
        ret = 0;
        while (length + PAGE_SIZE <= zc->length) {
@@ -1962,8 +1962,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
        struct sk_buff *skb, *last;
        u32 urg_hole = 0;
        struct scm_timestamping_internal tss;
-       bool has_tss = false;
-       bool has_cmsg;
+       int cmsg_flags;
 
        if (unlikely(flags & MSG_ERRQUEUE))
                return inet_recv_error(sk, msg, len, addr_len);
@@ -1978,7 +1977,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
        if (sk->sk_state == TCP_LISTEN)
                goto out;
 
-       has_cmsg = tp->recvmsg_inq;
+       cmsg_flags = tp->recvmsg_inq ? 1 : 0;
        timeo = sock_rcvtimeo(sk, nonblock);
 
        /* Urgent data needs to be handled specially. */
@@ -2051,7 +2050,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
 
                /* Well, if we have backlog, try to process it now yet. */
 
-               if (copied >= target && !sk->sk_backlog.tail)
+               if (copied >= target && !READ_ONCE(sk->sk_backlog.tail))
                        break;
 
                if (copied) {
@@ -2161,8 +2160,7 @@ skip_copy:
 
                if (TCP_SKB_CB(skb)->has_rxtstamp) {
                        tcp_update_recv_tstamps(skb, &tss);
-                       has_tss = true;
-                       has_cmsg = true;
+                       cmsg_flags |= 2;
                }
                if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
                        goto found_fin_ok;
@@ -2187,10 +2185,10 @@ found_fin_ok:
 
        release_sock(sk);
 
-       if (has_cmsg) {
-               if (has_tss)
+       if (cmsg_flags) {
+               if (cmsg_flags & 2)
                        tcp_recv_timestamp(msg, sk, &tss);
-               if (tp->recvmsg_inq) {
+               if (cmsg_flags & 1) {
                        inq = tcp_inq_hint(sk);
                        put_cmsg(msg, SOL_TCP, TCP_CM_INQ, sizeof(inq), &inq);
                }
@@ -2670,6 +2668,7 @@ int tcp_disconnect(struct sock *sk, int flags)
        /* Clean up fastopen related fields */
        tcp_free_fastopen_req(tp);
        inet->defer_connect = 0;
+       tp->fastopen_client_fail = 0;
 
        WARN_ON(inet->inet_num && !icsk->icsk_bind_hash);
 
@@ -3228,8 +3227,8 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
                 * tcpi_unacked -> Number of children ready for accept()
                 * tcpi_sacked  -> max backlog
                 */
-               info->tcpi_unacked = sk->sk_ack_backlog;
-               info->tcpi_sacked = sk->sk_max_ack_backlog;
+               info->tcpi_unacked = READ_ONCE(sk->sk_ack_backlog);
+               info->tcpi_sacked = READ_ONCE(sk->sk_max_ack_backlog);
                return;
        }
 
@@ -3309,6 +3308,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
        info->tcpi_reord_seen = tp->reord_seen;
        info->tcpi_rcv_ooopack = tp->rcv_ooopack;
        info->tcpi_snd_wnd = tp->snd_wnd;
+       info->tcpi_fastopen_client_fail = tp->fastopen_client_fail;
        unlock_sock_fast(sk, slow);
 }
 EXPORT_SYMBOL_GPL(tcp_get_info);