Subject: Re: [PATCH] inet, inet6: make tcp_sendmsg() and tcp_sendpage() through inet_sendmsg() and inet_sendpage()

From: Dimitris Michailidis <[email-masked]>
Date: Sat, 10 Jul 2010 21:45:18 -0700

Changli Gao wrote:

> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index 3ceb025..1e5bad1 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -727,28 +727,31 @@ int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
>  	sock_rps_record_flow(sk);
>  
>  	/* We may need to bind the socket. */
> -	if (!inet_sk(sk)->inet_num && inet_autobind(sk))
> +	if (!sk->sk_prot->no_autobind &&
> +	    !inet_sk(sk)->inet_num && inet_autobind(sk))
>  		return -EAGAIN;

I think it's better to test inet_num first since usually it's not 0.  With 
the above ordering protocols with no_autobind==false end up making two 
comparisons.