]> 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 5810f9d14914cf0a204dda0c060bae7ec8506379..617e858beff1b7fd3dc3775b62dba111e04363f3 100644 (file)
 #include <linux/mroute.h>
 #endif
 
-DEFINE_SNMP_STAT(struct linux_mib, net_statistics);
+DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly;
 
 extern void ip_mc_drop_socket(struct sock *sk);
 
@@ -147,8 +147,7 @@ void inet_sock_destruct(struct sock *sk)
        BUG_TRAP(!sk->sk_wmem_queued);
        BUG_TRAP(!sk->sk_forward_alloc);
 
-       if (inet->opt)
-               kfree(inet->opt);
+       kfree(inet->opt);
        dst_release(sk->sk_dst_cache);
        sk_refcnt_debug_dec(sk);
 }
@@ -229,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);
@@ -253,6 +253,7 @@ lookup_protocol:
                        if (IPPROTO_IP == answer->protocol)
                                break;
                }
+               err = -EPROTONOSUPPORT;
                answer = NULL;
        }
 
@@ -281,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;
@@ -304,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;
@@ -871,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,
         },
 
         {
@@ -1248,11 +1248,6 @@ module_init(inet_init);
 /* ------------------------------------------------------------------------ */
 
 #ifdef CONFIG_PROC_FS
-#ifdef CONFIG_IP_FIB_TRIE
-extern int  fib_stat_proc_init(void);
-extern void fib_stat_proc_exit(void);
-#endif
-
 static int __init ipv4_proc_init(void)
 {
        int rc = 0;
@@ -1265,19 +1260,11 @@ static int __init ipv4_proc_init(void)
                goto out_udp;
        if (fib_proc_init())
                goto out_fib;
-#ifdef CONFIG_IP_FIB_TRIE
-         if (fib_stat_proc_init())
-                 goto out_fib_stat;
-#endif
        if (ip_misc_proc_init())
                goto out_misc;
 out:
        return rc;
 out_misc:
-#ifdef CONFIG_IP_FIB_TRIE
-       fib_stat_proc_exit();
-out_fib_stat:
-#endif
        fib_proc_exit();
 out_fib:
        udp4_proc_exit();