summaryrefslogtreecommitdiff
path: root/include/net/tcp.h
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2019-12-14 20:57:36 +0300
committerJakub Kicinski <jakub.kicinski@netronome.com>2019-12-14 20:57:36 +0300
commitcd1263b6dcfdf0e938946441295d8fcfe1654d3a (patch)
tree99e290567b1943af5cf51b3cdfbf9f8f3752b6e8 /include/net/tcp.h
parent5c9934b6767b16ba60be22ec3cbd4379ad64170d (diff)
parent216808c6ba6d00169fd2aa928ec3c0e63bef254f (diff)
downloadlinux-cd1263b6dcfdf0e938946441295d8fcfe1654d3a.tar.xz
Merge branch 'tcp-take-care-of-empty-skbs-in-write-queue'
Eric Dumazet says: ==================== tcp: take care of empty skbs in write queue We understood recently that TCP sockets could have an empty skb at the tail of the write queue, leading to various problems. This patch series : 1) Make sure we do not send an empty packet since this was unintended and causing crashes in old kernels. 2) Change tcp_write_queue_empty() to not be fooled by the presence of an empty skb. 3) Fix a bug that could trigger suboptimal epoll() application behavior under memory pressure. ==================== Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 86b9a8766648..e460ea7f767b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1766,9 +1766,18 @@ static inline bool tcp_skb_is_last(const struct sock *sk,
return skb_queue_is_last(&sk->sk_write_queue, skb);
}
+/**
+ * tcp_write_queue_empty - test if any payload (or FIN) is available in write queue
+ * @sk: socket
+ *
+ * Since the write queue can have a temporary empty skb in it,
+ * we must not use "return skb_queue_empty(&sk->sk_write_queue)"
+ */
static inline bool tcp_write_queue_empty(const struct sock *sk)
{
- return skb_queue_empty(&sk->sk_write_queue);
+ const struct tcp_sock *tp = tcp_sk(sk);
+
+ return tp->write_seq == tp->snd_nxt;
}
static inline bool tcp_rtx_queue_empty(const struct sock *sk)