* why not use the tcp_set_state() in inet_csk_listen_start()?
@ 2010-03-24 8:13 杨硕
2010-03-24 9:02 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: 杨硕 @ 2010-03-24 8:13 UTC (permalink / raw)
To: netdev
why use "sk->sk_state = TCP_LISTEN" rather than "tcp_set_state(sk, TCP_LISTEN)"?
TIA :)
int inet_csk_listen_start(struct sock *sk, const int nr_table_entries)
{
struct inet_sock *inet = inet_sk(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
int rc = reqsk_queue_alloc(&icsk->icsk_accept_queue, nr_table_entries);
if (rc != 0)
return rc;
sk->sk_max_ack_backlog = 0;
sk->sk_ack_backlog = 0;
inet_csk_delack_init(sk);
/* There is race window here: we announce ourselves listening,
* but this transition is still not validated by get_port().
* It is OK, because this socket enters to hash table only
* after validation is complete.
*/
sk->sk_state = TCP_LISTEN;
if (!sk->sk_prot->get_port(sk, inet->num)) {
inet->sport = htons(inet->num);
sk_dst_reset(sk);
sk->sk_prot->hash(sk);
return 0;
}
sk->sk_state = TCP_CLOSE;
__reqsk_queue_destroy(&icsk->icsk_accept_queue);
return -EADDRINUSE;
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: why not use the tcp_set_state() in inet_csk_listen_start()?
2010-03-24 8:13 why not use the tcp_set_state() in inet_csk_listen_start()? 杨硕
@ 2010-03-24 9:02 ` Eric Dumazet
2010-03-25 0:49 ` 杨硕
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2010-03-24 9:02 UTC (permalink / raw)
To: 杨硕; +Cc: netdev
Le mercredi 24 mars 2010 à 16:13 +0800, 杨硕 a écrit :
> why use "sk->sk_state = TCP_LISTEN" rather than "tcp_set_state(sk, TCP_LISTEN)"?
>
> TIA :)
>
> int inet_csk_listen_start(struct sock *sk, const int nr_table_entries)
> {
> struct inet_sock *inet = inet_sk(sk);
> struct inet_connection_sock *icsk = inet_csk(sk);
> int rc = reqsk_queue_alloc(&icsk->icsk_accept_queue, nr_table_entries);
>
> if (rc != 0)
> return rc;
>
> sk->sk_max_ack_backlog = 0;
> sk->sk_ack_backlog = 0;
> inet_csk_delack_init(sk);
>
> /* There is race window here: we announce ourselves listening,
> * but this transition is still not validated by get_port().
> * It is OK, because this socket enters to hash table only
> * after validation is complete.
> */
> sk->sk_state = TCP_LISTEN;
Because its not necessary ?
tcp_set_state() takes care of particular state transitions.
In case of inet_csk_listen_start(), old state is TCP_CLOSE, so there is
nothing special to do in tcp_set_state().
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-25 0:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-24 8:13 why not use the tcp_set_state() in inet_csk_listen_start()? 杨硕
2010-03-24 9:02 ` Eric Dumazet
2010-03-25 0:49 ` 杨硕
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox