Commit e3715899 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

tcp: refine SYN handling in tcp_validate_incoming

Followup of commit 0c24604b (tcp: implement RFC 5961 4.2)

As reported by Vijay Subramanian, we should send a challenge ACK
instead of a dup ack if a SYN flag is set on a packet received out of
window.

This permits the ratelimiting to work as intended, and to increase
correct SNMP counters.
Suggested-by: default avatarVijay Subramanian <subramanian.vijay@gmail.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Acked-by: default avatarVijay Subramanian <subramanian.vijay@gmail.com>
Cc: Kiran Kumar Kella <kkiran@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b6fe83e9
...@@ -5296,8 +5296,11 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, ...@@ -5296,8 +5296,11 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
* an acknowledgment should be sent in reply (unless the RST * an acknowledgment should be sent in reply (unless the RST
* bit is set, if so drop the segment and return)". * bit is set, if so drop the segment and return)".
*/ */
if (!th->rst) if (!th->rst) {
if (th->syn)
goto syn_challenge;
tcp_send_dupack(sk, skb); tcp_send_dupack(sk, skb);
}
goto discard; goto discard;
} }
...@@ -5327,6 +5330,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, ...@@ -5327,6 +5330,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
* RFC 5691 4.2 : Send a challenge ack * RFC 5691 4.2 : Send a challenge ack
*/ */
if (th->syn) { if (th->syn) {
syn_challenge:
if (syn_inerr) if (syn_inerr)
TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_INERRS); TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_INERRS);
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPSYNCHALLENGE); NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPSYNCHALLENGE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment