aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>2016-12-05 15:37:13 -0500
committerDavid S. Miller <davem@davemloft.net>2016-12-06 11:01:19 -0500
commitdcb17d22e1c2cd72e72190c736349a675362b3bc (patch)
tree625a1b7ca8f1ef0004a51aa8287653d603b153fb /net
parentefc45154828ae4e49c6b46f59882bfef32697d44 (diff)
tcp: warn on bogus MSS and try to amend it
There have been some reports lately about TCP connection stalls caused by NIC drivers that aren't setting gso_size on aggregated packets on rx path. This causes TCP to assume that the MSS is actually the size of the aggregated packet, which is invalid. Although the proper fix is to be done at each driver, it's often hard and cumbersome for one to debug, come to such root cause and report/fix it. This patch amends this situation in two ways. First, it adds a warning on when this situation occurs, so it gives a hint to those trying to debug this. It also limit the maximum probed MSS to the adverised MSS, as it should never be any higher than that. The result is that the connection may not have the best performance ever but it shouldn't stall, and the admin will have a hint on what to look for. Tested with virtio by forcing gso_size to 0. v2: updated msg per David's suggestion v3: use skb_iif to find the interface and also log its name, per Eric Dumazet's suggestion. As the skb may be backlogged and the interface gone by then, we need to check if the number still has a meaning. v4: use helper tcp_gro_dev_warn() and avoid pr_warn_once inside __once, per David's suggestion Cc: Jonathan Maxwell <jmaxwell37@gmail.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp_input.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a27b9c0e27c0..c71d49ce0c93 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -128,6 +128,23 @@ int sysctl_tcp_invalid_ratelimit __read_mostly = HZ/2;
128#define REXMIT_LOST 1 /* retransmit packets marked lost */ 128#define REXMIT_LOST 1 /* retransmit packets marked lost */
129#define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */ 129#define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */
130 130
131static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb)
132{
133 static bool __once __read_mostly;
134
135 if (!__once) {
136 struct net_device *dev;
137
138 __once = true;
139
140 rcu_read_lock();
141 dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif);
142 pr_warn("%s: Driver has suspect GRO implementation, TCP performance may be compromised.\n",
143 dev ? dev->name : "Unknown driver");
144 rcu_read_unlock();
145 }
146}
147
131/* Adapt the MSS value used to make delayed ack decision to the 148/* Adapt the MSS value used to make delayed ack decision to the
132 * real world. 149 * real world.
133 */ 150 */
@@ -144,7 +161,10 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb)
144 */ 161 */
145 len = skb_shinfo(skb)->gso_size ? : skb->len; 162 len = skb_shinfo(skb)->gso_size ? : skb->len;
146 if (len >= icsk->icsk_ack.rcv_mss) { 163 if (len >= icsk->icsk_ack.rcv_mss) {
147 icsk->icsk_ack.rcv_mss = len; 164 icsk->icsk_ack.rcv_mss = min_t(unsigned int, len,
165 tcp_sk(sk)->advmss);
166 if (unlikely(icsk->icsk_ack.rcv_mss != len))
167 tcp_gro_dev_warn(sk, skb);
148 } else { 168 } else {
149 /* Otherwise, we make more careful check taking into account, 169 /* Otherwise, we make more careful check taking into account,
150 * that SACKs block is variable. 170 * that SACKs block is variable.