Commit a594920f authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by David S. Miller

inet: Remove an unnecessary argument of syn_ack_recalc().

Commit 0c3d79bc ("tcp: reduce SYN-ACK
retrans for TCP_DEFER_ACCEPT") introduces syn_ack_recalc() which decides
if a minisock is held and a SYN+ACK is retransmitted or not.

If rskq_defer_accept is not zero in syn_ack_recalc(), max_retries always
has the same value because max_retries is overwritten by rskq_defer_accept
in reqsk_timer_handler().

This commit adds three changes:
- remove redundant non-zero check for rskq_defer_accept in
   reqsk_timer_handler().
- remove max_retries from the arguments of syn_ack_recalc() and use
   rskq_defer_accept instead.
- rename thresh to max_syn_ack_retries for readability.
Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.co.jp>
Reviewed-by: default avatarBenjamin Herrenschmidt <benh@amazon.com>
CC: Julian Anastasov <ja@ssi.bg>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac4cd478
...@@ -648,20 +648,19 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk, ...@@ -648,20 +648,19 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk,
EXPORT_SYMBOL_GPL(inet_csk_route_child_sock); EXPORT_SYMBOL_GPL(inet_csk_route_child_sock);
/* Decide when to expire the request and when to resend SYN-ACK */ /* Decide when to expire the request and when to resend SYN-ACK */
static inline void syn_ack_recalc(struct request_sock *req, const int thresh, static void syn_ack_recalc(struct request_sock *req,
const int max_retries, const int max_syn_ack_retries,
const u8 rskq_defer_accept, const u8 rskq_defer_accept,
int *expire, int *resend) int *expire, int *resend)
{ {
if (!rskq_defer_accept) { if (!rskq_defer_accept) {
*expire = req->num_timeout >= thresh; *expire = req->num_timeout >= max_syn_ack_retries;
*resend = 1; *resend = 1;
return; return;
} }
*expire = req->num_timeout >= thresh && *expire = req->num_timeout >= max_syn_ack_retries &&
(!inet_rsk(req)->acked || req->num_timeout >= max_retries); (!inet_rsk(req)->acked || req->num_timeout >= rskq_defer_accept);
/* /* Do not resend while waiting for data after ACK,
* Do not resend while waiting for data after ACK,
* start to resend on end of deferring period to give * start to resend on end of deferring period to give
* last chance for data or ACK to create established socket. * last chance for data or ACK to create established socket.
*/ */
...@@ -720,15 +719,12 @@ static void reqsk_timer_handler(struct timer_list *t) ...@@ -720,15 +719,12 @@ static void reqsk_timer_handler(struct timer_list *t)
struct net *net = sock_net(sk_listener); struct net *net = sock_net(sk_listener);
struct inet_connection_sock *icsk = inet_csk(sk_listener); struct inet_connection_sock *icsk = inet_csk(sk_listener);
struct request_sock_queue *queue = &icsk->icsk_accept_queue; struct request_sock_queue *queue = &icsk->icsk_accept_queue;
int qlen, expire = 0, resend = 0; int max_syn_ack_retries, qlen, expire = 0, resend = 0;
int max_retries, thresh;
u8 defer_accept;
if (inet_sk_state_load(sk_listener) != TCP_LISTEN) if (inet_sk_state_load(sk_listener) != TCP_LISTEN)
goto drop; goto drop;
max_retries = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_synack_retries; max_syn_ack_retries = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_synack_retries;
thresh = max_retries;
/* Normally all the openreqs are young and become mature /* Normally all the openreqs are young and become mature
* (i.e. converted to established socket) for first timeout. * (i.e. converted to established socket) for first timeout.
* If synack was not acknowledged for 1 second, it means * If synack was not acknowledged for 1 second, it means
...@@ -750,17 +746,14 @@ static void reqsk_timer_handler(struct timer_list *t) ...@@ -750,17 +746,14 @@ static void reqsk_timer_handler(struct timer_list *t)
if ((qlen << 1) > max(8U, READ_ONCE(sk_listener->sk_max_ack_backlog))) { if ((qlen << 1) > max(8U, READ_ONCE(sk_listener->sk_max_ack_backlog))) {
int young = reqsk_queue_len_young(queue) << 1; int young = reqsk_queue_len_young(queue) << 1;
while (thresh > 2) { while (max_syn_ack_retries > 2) {
if (qlen < young) if (qlen < young)
break; break;
thresh--; max_syn_ack_retries--;
young <<= 1; young <<= 1;
} }
} }
defer_accept = READ_ONCE(queue->rskq_defer_accept); syn_ack_recalc(req, max_syn_ack_retries, READ_ONCE(queue->rskq_defer_accept),
if (defer_accept)
max_retries = defer_accept;
syn_ack_recalc(req, thresh, max_retries, defer_accept,
&expire, &resend); &expire, &resend);
req->rsk_ops->syn_ack_timeout(req); req->rsk_ops->syn_ack_timeout(req);
if (!expire && if (!expire &&
......
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