ChangeSet 1.2327, 2005/03/31 21:14:28-08:00, [EMAIL PROTECTED]

        Merge bk://kernel.bkbits.net/acme/net-2.6
        into sunset.davemloft.net:/home/davem/src/BK/net-2.6



 netlink/af_netlink.c |   28 +++++++++++++++++++---------
 unix/af_unix.c       |   34 +++++++++++++++++++---------------
 2 files changed, 38 insertions(+), 24 deletions(-)


diff -Nru a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
--- a/net/netlink/af_netlink.c  2005-04-01 09:09:44 -08:00
+++ b/net/netlink/af_netlink.c  2005-04-01 09:09:44 -08:00
@@ -321,6 +321,12 @@
        netlink_table_ungrab();
 }
 
+static struct proto netlink_proto = {
+       .name     = "NETLINK",
+       .owner    = THIS_MODULE,
+       .obj_size = sizeof(struct netlink_sock),
+};
+
 static int netlink_create(struct socket *sock, int protocol)
 {
        struct sock *sk;
@@ -336,13 +342,11 @@
 
        sock->ops = &netlink_ops;
 
-       sk = sk_alloc(PF_NETLINK, GFP_KERNEL,
-                     sizeof(struct netlink_sock), NULL);
+       sk = sk_alloc(PF_NETLINK, GFP_KERNEL, &netlink_proto, 1);
        if (!sk)
                return -ENOMEM;
 
-       sock_init_data(sock,sk);
-       sk_set_owner(sk, THIS_MODULE);
+       sock_init_data(sock, sk);
 
        nlk = nlk_sk(sk);
 
@@ -1369,6 +1373,10 @@
        int i;
        unsigned long max;
        unsigned int order;
+       int err = proto_register(&netlink_proto, 0);
+
+       if (err != 0)
+               goto out;
 
        if (sizeof(struct netlink_skb_parms) > sizeof(dummy_skb->cb))
                netlink_skb_parms_too_large();
@@ -1415,15 +1423,17 @@
 #endif
        /* The netlink device handler may be needed early. */ 
        rtnetlink_init();
-       return 0;
+out:
+       return err;
 }
 
 static void __exit netlink_proto_exit(void)
 {
-       sock_unregister(PF_NETLINK);
-       proc_net_remove("netlink");
-       kfree(nl_table);
-       nl_table = NULL;
+       sock_unregister(PF_NETLINK);
+       proc_net_remove("netlink");
+       kfree(nl_table);
+       nl_table = NULL;
+       proto_unregister(&netlink_proto);
 }
 
 core_initcall(netlink_proto_init);
diff -Nru a/net/unix/af_unix.c b/net/unix/af_unix.c
--- a/net/unix/af_unix.c        2005-04-01 09:09:44 -08:00
+++ b/net/unix/af_unix.c        2005-04-01 09:09:44 -08:00
@@ -121,8 +121,6 @@
 
 int sysctl_unix_max_dgram_qlen = 10;
 
-static kmem_cache_t *unix_sk_cachep;
-
 struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
 DEFINE_RWLOCK(unix_table_lock);
 static atomic_t unix_nr_socks = ATOMIC_INIT(0);
@@ -539,6 +537,12 @@
        .sendpage =     sock_no_sendpage,
 };
 
+static struct proto unix_proto = {
+       .name     = "UNIX",
+       .owner    = THIS_MODULE,
+       .obj_size = sizeof(struct unix_sock),
+};
+
 static struct sock * unix_create1(struct socket *sock)
 {
        struct sock *sk = NULL;
@@ -547,15 +551,13 @@
        if (atomic_read(&unix_nr_socks) >= 2*files_stat.max_files)
                goto out;
 
-       sk = sk_alloc(PF_UNIX, GFP_KERNEL, sizeof(struct unix_sock),
-                     unix_sk_cachep);
+       sk = sk_alloc(PF_UNIX, GFP_KERNEL, &unix_proto, 1);
        if (!sk)
                goto out;
 
        atomic_inc(&unix_nr_socks);
 
        sock_init_data(sock,sk);
-       sk_set_owner(sk, THIS_MODULE);
 
        sk->sk_write_space      = unix_write_space;
        sk->sk_max_ack_backlog  = sysctl_unix_max_dgram_qlen;
@@ -2057,26 +2059,28 @@
 
 static int __init af_unix_init(void)
 {
+       int rc = -1;
        struct sk_buff *dummy_skb;
 
        if (sizeof(struct unix_skb_parms) > sizeof(dummy_skb->cb)) {
                printk(KERN_CRIT "%s: panic\n", __FUNCTION__);
-               return -1;
+               goto out;
+       }
+
+       rc = proto_register(&unix_proto, 1);
+        if (rc != 0) {
+                printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n",
+                      __FUNCTION__);
+               goto out;
        }
-        /* allocate our sock slab cache */
-        unix_sk_cachep = kmem_cache_create("unix_sock",
-                                          sizeof(struct unix_sock), 0,
-                                          SLAB_HWCACHE_ALIGN, NULL, NULL);
-        if (!unix_sk_cachep)
-                printk(KERN_CRIT
-                        "af_unix_init: Cannot create unix_sock SLAB cache!\n");
 
        sock_register(&unix_family_ops);
 #ifdef CONFIG_PROC_FS
        proc_net_fops_create("unix", 0, &unix_seq_fops);
 #endif
        unix_sysctl_register();
-       return 0;
+out:
+       return rc;
 }
 
 static void __exit af_unix_exit(void)
@@ -2084,7 +2088,7 @@
        sock_unregister(PF_UNIX);
        unix_sysctl_unregister();
        proc_net_remove("unix");
-       kmem_cache_destroy(unix_sk_cachep);
+       proto_unregister(&unix_proto);
 }
 
 module_init(af_unix_init);
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to