]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/af_inet.c
[NET]: Small cleanup to socket initialization
[net-next-2.6.git] / net / ipv4 / af_inet.c
index eaa150c33b0403204fa22224d6434e5c45f7695c..617e858beff1b7fd3dc3775b62dba111e04363f3 100644 (file)
@@ -228,13 +228,14 @@ static int inet_create(struct socket *sock, int protocol)
        unsigned char answer_flags;
        char answer_no_check;
        int try_loading_module = 0;
-       int err = -ESOCKTNOSUPPORT;
+       int err;
 
        sock->state = SS_UNCONNECTED;
 
        /* Look for the requested type/protocol pair. */
        answer = NULL;
 lookup_protocol:
+       err = -ESOCKTNOSUPPORT;
        rcu_read_lock();
        list_for_each_rcu(p, &inetsw[sock->type]) {
                answer = list_entry(p, struct inet_protosw, list);
@@ -252,6 +253,7 @@ lookup_protocol:
                        if (IPPROTO_IP == answer->protocol)
                                break;
                }
+               err = -EPROTONOSUPPORT;
                answer = NULL;
        }
 
@@ -280,9 +282,6 @@ lookup_protocol:
        err = -EPERM;
        if (answer->capability > 0 && !capable(answer->capability))
                goto out_rcu_unlock;
-       err = -EPROTONOSUPPORT;
-       if (!protocol)
-               goto out_rcu_unlock;
 
        sock->ops = answer->ops;
        answer_prot = answer->prot;
@@ -303,6 +302,7 @@ lookup_protocol:
                sk->sk_reuse = 1;
 
        inet = inet_sk(sk);
+       inet->is_icsk = INET_PROTOSW_ICSK & answer_flags;
 
        if (SOCK_RAW == sock->type) {
                inet->num = protocol;
@@ -870,7 +870,8 @@ static struct inet_protosw inetsw_array[] =
                 .ops =        &inet_stream_ops,
                 .capability = -1,
                 .no_check =   0,
-                .flags =      INET_PROTOSW_PERMANENT,
+                .flags =      INET_PROTOSW_PERMANENT |
+                             INET_PROTOSW_ICSK,
         },
 
         {