Commit 2a1d4bd4 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

syncookies: make v4/v6 synflood warning behaviour the same

both syn_flood_warning functions print a message, but
ipv4 version only prints a warning if CONFIG_SYN_COOKIES=y.

Make the v4 one behave like the v6 one.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 87eb743b
...@@ -793,19 +793,20 @@ static void tcp_v4_reqsk_destructor(struct request_sock *req) ...@@ -793,19 +793,20 @@ static void tcp_v4_reqsk_destructor(struct request_sock *req)
kfree(inet_rsk(req)->opt); kfree(inet_rsk(req)->opt);
} }
#ifdef CONFIG_SYN_COOKIES static void syn_flood_warning(const struct sk_buff *skb)
static void syn_flood_warning(struct sk_buff *skb)
{ {
static unsigned long warntime; const char *msg;
if (time_after(jiffies, (warntime + HZ * 60))) { #ifdef CONFIG_SYN_COOKIES
warntime = jiffies; if (sysctl_tcp_syncookies)
printk(KERN_INFO msg = "Sending cookies";
"possible SYN flooding on port %d. Sending cookies.\n", else
ntohs(tcp_hdr(skb)->dest));
}
}
#endif #endif
msg = "Dropping request";
pr_info("TCP: Possible SYN flooding on port %d. %s.\n",
ntohs(tcp_hdr(skb)->dest), msg);
}
/* /*
* Save and compile IPv4 options into the request_sock if needed. * Save and compile IPv4 options into the request_sock if needed.
...@@ -1243,6 +1244,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) ...@@ -1243,6 +1244,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
* evidently real one. * evidently real one.
*/ */
if (inet_csk_reqsk_queue_is_full(sk) && !isn) { if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
if (net_ratelimit())
syn_flood_warning(skb);
#ifdef CONFIG_SYN_COOKIES #ifdef CONFIG_SYN_COOKIES
if (sysctl_tcp_syncookies) { if (sysctl_tcp_syncookies) {
want_cookie = 1; want_cookie = 1;
...@@ -1328,7 +1331,6 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) ...@@ -1328,7 +1331,6 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
if (want_cookie) { if (want_cookie) {
#ifdef CONFIG_SYN_COOKIES #ifdef CONFIG_SYN_COOKIES
syn_flood_warning(skb);
req->cookie_ts = tmp_opt.tstamp_ok; req->cookie_ts = tmp_opt.tstamp_ok;
#endif #endif
isn = cookie_v4_init_sequence(sk, skb, &req->mss); isn = cookie_v4_init_sequence(sk, skb, &req->mss);
......
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