Skip to content

Commit 1295e2c

Browse files
laoardavem330
authored andcommitted
inet: minor optimization for backlog setting in listen(2)
Set the backlog earlier in inet_dccp_listen() and inet_listen(), then we can avoid the redundant setting. Signed-off-by: Yafang Shao <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7dad993 commit 1295e2c

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

net/dccp/proto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,7 @@ int inet_dccp_listen(struct socket *sock, int backlog)
948948
if (!((1 << old_state) & (DCCPF_CLOSED | DCCPF_LISTEN)))
949949
goto out;
950950

951+
sk->sk_max_ack_backlog = backlog;
951952
/* Really, if the socket is already in listen state
952953
* we can only allow the backlog to be adjusted.
953954
*/
@@ -960,7 +961,6 @@ int inet_dccp_listen(struct socket *sock, int backlog)
960961
if (err)
961962
goto out;
962963
}
963-
sk->sk_max_ack_backlog = backlog;
964964
err = 0;
965965

966966
out:

net/ipv4/af_inet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ int inet_listen(struct socket *sock, int backlog)
208208
if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN)))
209209
goto out;
210210

211+
sk->sk_max_ack_backlog = backlog;
211212
/* Really, if the socket is already in listen state
212213
* we can only allow the backlog to be adjusted.
213214
*/
@@ -231,7 +232,6 @@ int inet_listen(struct socket *sock, int backlog)
231232
goto out;
232233
tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL);
233234
}
234-
sk->sk_max_ack_backlog = backlog;
235235
err = 0;
236236

237237
out:

net/ipv4/inet_connection_sock.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,6 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
881881

882882
reqsk_queue_alloc(&icsk->icsk_accept_queue);
883883

884-
sk->sk_max_ack_backlog = backlog;
885884
sk->sk_ack_backlog = 0;
886885
inet_csk_delack_init(sk);
887886

0 commit comments

Comments
 (0)