RFC 1122 Section 4.2.3.9 states the following soft errors must not abort connections: o Destination Unreachable -- codes 0, 1, 5 Since these Unreachable messages indicate soft error conditions, TCP MUST NOT abort the connection, and it SHOULD make the information available to the application. o Time Exceeded -- codes 0, 1 o Parameter Problem This should be handled the same way as Destination Unreachable codes 0, 1, 5 (see above). Commit 9cf7490360bf ("tcp: do not drop syn_recv on all icmp reports") introduced the abort arg to tcp_req_err() to avoid aborting connection on ICMP_REDIRECT. However, tcp_v4_err() still abort on soft errors (ICMP_NET_UNREACH (0), ICMP_HOST_UNREACH (1)) and ignore hard errors. For example, we can see SYN+ACK retransmitted after receiving hard error: --ip_version=ipv4 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 +0 bind(3, ..., ...) = 0 +0 listen(3, 10) = 0 +0 < S 0:0(0) win 65535 +0 > S. 0:0(0) ack 1 +0 < icmp unreachable port_unreachable [0:0(0)] +1 > S. 0:0(0) ack 1 Also, tcp_v6_err() uses icmpv6_err_convert(), which handles ICMPV6_PARAMPROB messages as hard error while RFC 5461 defines as soft error. But we should handle ICMPV6_UNK_NEXTHDR as hard error because it is used as IPv6 version ICMP_PROT_UNREACH. Let's correct the abort condition in tcp_v4_err() and tcp_v6_err(). Note that icmpv6_err_convert() is used by other protocols. Fixes: 9cf7490360bf ("tcp: do not drop syn_recv on all icmp reports") Signed-off-by: Kuniyuki Iwashima --- net/ipv4/tcp_ipv4.c | 7 ++----- net/ipv6/tcp_ipv6.c | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index fd9588bba967..f11e090d04fb 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -529,11 +529,8 @@ int tcp_v4_err(struct sk_buff *skb, u32 info) seq = ntohl(th->seq); if (sk->sk_state == TCP_NEW_SYN_RECV) { - tcp_req_err(sk, seq, type == ICMP_PARAMETERPROB || - type == ICMP_TIME_EXCEEDED || - (type == ICMP_DEST_UNREACH && - (code == ICMP_NET_UNREACH || - code == ICMP_HOST_UNREACH))); + tcp_req_err(sk, seq, (type == ICMP_DEST_UNREACH && + icmp_err_convert[code].fatal)); return 0; } diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 0f1523fff939..29fd0a084c91 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -447,7 +447,8 @@ static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, seq = ntohl(th->seq); fatal = icmpv6_err_convert(type, code, &err); if (sk->sk_state == TCP_NEW_SYN_RECV) { - tcp_req_err(sk, seq, fatal); + tcp_req_err(sk, seq, type == ICMPV6_PARAMPROB ? + code == ICMPV6_UNK_NEXTHDR : fatal); return 0; } -- 2.56.0.679.gc527c65306-goog