Skip to content

Commit 2985aaa

Browse files
edumazetdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f964629 commit 2985aaa

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

include/net/request_sock.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ struct listen_sock {
129129
atomic_t qlen_dec; /* qlen = qlen_inc - qlen_dec */
130130
atomic_t young_dec;
131131

132-
u8 max_qlen_log ____cacheline_aligned_in_smp;
133-
u8 synflood_warned;
134-
/* 2 bytes hole, try to use */
132+
u32 max_qlen_log ____cacheline_aligned_in_smp;
133+
u32 synflood_warned;
135134
u32 hash_rnd;
136135
u32 nr_table_entries;
137136
struct request_sock *syn_table[0];

net/ipv4/tcp_input.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6064,7 +6064,7 @@ EXPORT_SYMBOL(inet_reqsk_alloc);
60646064
/*
60656065
* Return true if a syncookie should be sent
60666066
*/
6067-
static bool tcp_syn_flood_action(struct sock *sk,
6067+
static bool tcp_syn_flood_action(const struct sock *sk,
60686068
const struct sk_buff *skb,
60696069
const char *proto)
60706070
{
@@ -6082,11 +6082,12 @@ static bool tcp_syn_flood_action(struct sock *sk,
60826082
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP);
60836083

60846084
lopt = inet_csk(sk)->icsk_accept_queue.listen_opt;
6085-
if (!lopt->synflood_warned && sysctl_tcp_syncookies != 2) {
6086-
lopt->synflood_warned = 1;
6085+
if (!lopt->synflood_warned &&
6086+
sysctl_tcp_syncookies != 2 &&
6087+
xchg(&lopt->synflood_warned, 1) == 0)
60876088
pr_info("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n",
60886089
proto, ntohs(tcp_hdr(skb)->dest), msg);
6089-
}
6090+
60906091
return want_cookie;
60916092
}
60926093

0 commit comments

Comments
 (0)