inet: minor optimization for backlog setting in listen(2)
authorYafang Shao <laoar.shao@gmail.com>
Wed, 7 Nov 2018 11:20:16 +0000 (19:20 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 8 Nov 2018 06:31:07 +0000 (22:31 -0800)
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>
net/dccp/proto.c
net/ipv4/af_inet.c
net/ipv4/inet_connection_sock.c

index 43733accf58eb611fe8f0e57436b4ad02819398f..658cd32bb7b37e740ec174481c067ef2ea67cb7e 100644 (file)
@@ -948,6 +948,7 @@ int inet_dccp_listen(struct socket *sock, int backlog)
        if (!((1 << old_state) & (DCCPF_CLOSED | DCCPF_LISTEN)))
                goto out;
 
+       sk->sk_max_ack_backlog = backlog;
        /* Really, if the socket is already in listen state
         * we can only allow the backlog to be adjusted.
         */
@@ -960,7 +961,6 @@ int inet_dccp_listen(struct socket *sock, int backlog)
                if (err)
                        goto out;
        }
-       sk->sk_max_ack_backlog = backlog;
        err = 0;
 
 out:
index 07749c5b0a50bda0a08c4d62947eba3ef646c814..326c422c22f8d7e6c3da8f2015a290915d584446 100644 (file)
@@ -208,6 +208,7 @@ int inet_listen(struct socket *sock, int backlog)
        if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN)))
                goto out;
 
+       sk->sk_max_ack_backlog = backlog;
        /* Really, if the socket is already in listen state
         * we can only allow the backlog to be adjusted.
         */
@@ -231,7 +232,6 @@ int inet_listen(struct socket *sock, int backlog)
                        goto out;
                tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL);
        }
-       sk->sk_max_ack_backlog = backlog;
        err = 0;
 
 out:
index 5c63449130d9553e00695d127ca7a944c8642985..6ea523d71947779b68d599de11a2a74535f578f0 100644 (file)
@@ -881,7 +881,6 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
 
        reqsk_queue_alloc(&icsk->icsk_accept_queue);
 
-       sk->sk_max_ack_backlog = backlog;
        sk->sk_ack_backlog = 0;
        inet_csk_delack_init(sk);