mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									7dad9937e0
								
							
						
					
					
						commit
						1295e2cf30
					
				
					 3 changed files with 2 additions and 3 deletions
				
			
		| 
						 | 
					@ -948,6 +948,7 @@ int inet_dccp_listen(struct socket *sock, int backlog)
 | 
				
			||||||
	if (!((1 << old_state) & (DCCPF_CLOSED | DCCPF_LISTEN)))
 | 
						if (!((1 << old_state) & (DCCPF_CLOSED | DCCPF_LISTEN)))
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sk->sk_max_ack_backlog = backlog;
 | 
				
			||||||
	/* Really, if the socket is already in listen state
 | 
						/* Really, if the socket is already in listen state
 | 
				
			||||||
	 * we can only allow the backlog to be adjusted.
 | 
						 * we can only allow the backlog to be adjusted.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					@ -960,7 +961,6 @@ int inet_dccp_listen(struct socket *sock, int backlog)
 | 
				
			||||||
		if (err)
 | 
							if (err)
 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	sk->sk_max_ack_backlog = backlog;
 | 
					 | 
				
			||||||
	err = 0;
 | 
						err = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -208,6 +208,7 @@ int inet_listen(struct socket *sock, int backlog)
 | 
				
			||||||
	if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN)))
 | 
						if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN)))
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sk->sk_max_ack_backlog = backlog;
 | 
				
			||||||
	/* Really, if the socket is already in listen state
 | 
						/* Really, if the socket is already in listen state
 | 
				
			||||||
	 * we can only allow the backlog to be adjusted.
 | 
						 * we can only allow the backlog to be adjusted.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					@ -231,7 +232,6 @@ int inet_listen(struct socket *sock, int backlog)
 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
		tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL);
 | 
							tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	sk->sk_max_ack_backlog = backlog;
 | 
					 | 
				
			||||||
	err = 0;
 | 
						err = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -881,7 +881,6 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	reqsk_queue_alloc(&icsk->icsk_accept_queue);
 | 
						reqsk_queue_alloc(&icsk->icsk_accept_queue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sk->sk_max_ack_backlog = backlog;
 | 
					 | 
				
			||||||
	sk->sk_ack_backlog = 0;
 | 
						sk->sk_ack_backlog = 0;
 | 
				
			||||||
	inet_csk_delack_init(sk);
 | 
						inet_csk_delack_init(sk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue