aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 023196f7ec37..18b80e8bc533 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5987,6 +5987,35 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
5987} 5987}
5988EXPORT_SYMBOL(inet_reqsk_alloc); 5988EXPORT_SYMBOL(inet_reqsk_alloc);
5989 5989
5990/*
5991 * Return true if a syncookie should be sent
5992 */
5993static bool tcp_syn_flood_action(struct sock *sk,
5994 const struct sk_buff *skb,
5995 const char *proto)
5996{
5997 const char *msg = "Dropping request";
5998 bool want_cookie = false;
5999 struct listen_sock *lopt;
6000
6001#ifdef CONFIG_SYN_COOKIES
6002 if (sysctl_tcp_syncookies) {
6003 msg = "Sending cookies";
6004 want_cookie = true;
6005 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDOCOOKIES);
6006 } else
6007#endif
6008 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP);
6009
6010 lopt = inet_csk(sk)->icsk_accept_queue.listen_opt;
6011 if (!lopt->synflood_warned && sysctl_tcp_syncookies != 2) {
6012 lopt->synflood_warned = 1;
6013 pr_info("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n",
6014 proto, ntohs(tcp_hdr(skb)->dest), msg);
6015 }
6016 return want_cookie;
6017}
6018
5990int tcp_conn_request(struct request_sock_ops *rsk_ops, 6019int tcp_conn_request(struct request_sock_ops *rsk_ops,
5991 const struct tcp_request_sock_ops *af_ops, 6020 const struct tcp_request_sock_ops *af_ops,
5992 struct sock *sk, struct sk_buff *skb) 6021 struct sock *sk, struct sk_buff *skb)