mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
tcp: constify tcp_syn_flood_action() socket argument
tcp_syn_flood_action() will soon be called with unlocked socket. In order to avoid SYN flood warning being emitted multiple times, use xchg(). Extend max_qlen_log and synflood_warned fields in struct listen_sock to u32 Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f964629e33
commit
2985aaac01
2 changed files with 7 additions and 7 deletions
|
@ -129,9 +129,8 @@ struct listen_sock {
|
||||||
atomic_t qlen_dec; /* qlen = qlen_inc - qlen_dec */
|
atomic_t qlen_dec; /* qlen = qlen_inc - qlen_dec */
|
||||||
atomic_t young_dec;
|
atomic_t young_dec;
|
||||||
|
|
||||||
u8 max_qlen_log ____cacheline_aligned_in_smp;
|
u32 max_qlen_log ____cacheline_aligned_in_smp;
|
||||||
u8 synflood_warned;
|
u32 synflood_warned;
|
||||||
/* 2 bytes hole, try to use */
|
|
||||||
u32 hash_rnd;
|
u32 hash_rnd;
|
||||||
u32 nr_table_entries;
|
u32 nr_table_entries;
|
||||||
struct request_sock *syn_table[0];
|
struct request_sock *syn_table[0];
|
||||||
|
|
|
@ -6064,7 +6064,7 @@ EXPORT_SYMBOL(inet_reqsk_alloc);
|
||||||
/*
|
/*
|
||||||
* Return true if a syncookie should be sent
|
* Return true if a syncookie should be sent
|
||||||
*/
|
*/
|
||||||
static bool tcp_syn_flood_action(struct sock *sk,
|
static bool tcp_syn_flood_action(const struct sock *sk,
|
||||||
const struct sk_buff *skb,
|
const struct sk_buff *skb,
|
||||||
const char *proto)
|
const char *proto)
|
||||||
{
|
{
|
||||||
|
@ -6082,11 +6082,12 @@ static bool tcp_syn_flood_action(struct sock *sk,
|
||||||
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP);
|
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP);
|
||||||
|
|
||||||
lopt = inet_csk(sk)->icsk_accept_queue.listen_opt;
|
lopt = inet_csk(sk)->icsk_accept_queue.listen_opt;
|
||||||
if (!lopt->synflood_warned && sysctl_tcp_syncookies != 2) {
|
if (!lopt->synflood_warned &&
|
||||||
lopt->synflood_warned = 1;
|
sysctl_tcp_syncookies != 2 &&
|
||||||
|
xchg(&lopt->synflood_warned, 1) == 0)
|
||||||
pr_info("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n",
|
pr_info("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n",
|
||||||
proto, ntohs(tcp_hdr(skb)->dest), msg);
|
proto, ntohs(tcp_hdr(skb)->dest), msg);
|
||||||
}
|
|
||||||
return want_cookie;
|
return want_cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue