summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYafang Shao <laoar.shao@gmail.com>2018-11-07 06:20:16 -0500
committerDavid S. Miller <davem@davemloft.net>2018-11-08 01:31:07 -0500
commit1295e2cf3065a55f35d112e4dfeb2c7322823249 (patch)
treeeca7c4d056966400406e516f9cb77e2d0c0cc432
parent7dad9937e064a6411cc3427f3f5870fa72132ad8 (diff)
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 <laoar.shao@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/dccp/proto.c2
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/inet_connection_sock.c1
3 files changed, 2 insertions, 3 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 43733accf58e..658cd32bb7b3 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -948,6 +948,7 @@ int inet_dccp_listen(struct socket *sock, int backlog)
948 if (!((1 << old_state) & (DCCPF_CLOSED | DCCPF_LISTEN))) 948 if (!((1 << old_state) & (DCCPF_CLOSED | DCCPF_LISTEN)))
949 goto out; 949 goto out;
950 950
951 sk->sk_max_ack_backlog = backlog;
951 /* Really, if the socket is already in listen state 952 /* Really, if the socket is already in listen state
952 * we can only allow the backlog to be adjusted. 953 * we can only allow the backlog to be adjusted.
953 */ 954 */
@@ -960,7 +961,6 @@ int inet_dccp_listen(struct socket *sock, int backlog)
960 if (err) 961 if (err)
961 goto out; 962 goto out;
962 } 963 }
963 sk->sk_max_ack_backlog = backlog;
964 err = 0; 964 err = 0;
965 965
966out: 966out:
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 07749c5b0a50..326c422c22f8 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -208,6 +208,7 @@ int inet_listen(struct socket *sock, int backlog)
208 if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN))) 208 if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN)))
209 goto out; 209 goto out;
210 210
211 sk->sk_max_ack_backlog = backlog;
211 /* Really, if the socket is already in listen state 212 /* Really, if the socket is already in listen state
212 * we can only allow the backlog to be adjusted. 213 * we can only allow the backlog to be adjusted.
213 */ 214 */
@@ -231,7 +232,6 @@ int inet_listen(struct socket *sock, int backlog)
231 goto out; 232 goto out;
232 tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL); 233 tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL);
233 } 234 }
234 sk->sk_max_ack_backlog = backlog;
235 err = 0; 235 err = 0;
236 236
237out: 237out:
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 5c63449130d9..6ea523d71947 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -881,7 +881,6 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
881 881
882 reqsk_queue_alloc(&icsk->icsk_accept_queue); 882 reqsk_queue_alloc(&icsk->icsk_accept_queue);
883 883
884 sk->sk_max_ack_backlog = backlog;
885 sk->sk_ack_backlog = 0; 884 sk->sk_ack_backlog = 0;
886 inet_csk_delack_init(sk); 885 inet_csk_delack_init(sk);
887 886