[NET]: Use is_zero_ether_addr() in net/core/netpoll.c
[safe/jmp/linux-2.6] / net / core / sock.c
index 928d2a1..6e00811 100644 (file)
@@ -91,6 +91,7 @@
  *             2 of the License, or (at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
@@ -637,7 +638,7 @@ lenout:
  *     @prot: struct proto associated with this new sock instance
  *     @zero_it: if we should zero the newly allocated sock
  */
-struct sock *sk_alloc(int family, unsigned int __nocast priority,
+struct sock *sk_alloc(int family, gfp_t priority,
                      struct proto *prot, int zero_it)
 {
        struct sock *sk = NULL;
@@ -704,7 +705,7 @@ void sk_free(struct sock *sk)
        module_put(owner);
 }
 
-struct sock *sk_clone(const struct sock *sk, const unsigned int __nocast priority)
+struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
 {
        struct sock *newsk = sk_alloc(sk->sk_family, priority, sk->sk_prot, 0);
 
@@ -845,7 +846,7 @@ unsigned long sock_i_ino(struct sock *sk)
  * Allocate a skb from the socket's send buffer.
  */
 struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force,
-                            unsigned int __nocast priority)
+                            gfp_t priority)
 {
        if (force || atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) {
                struct sk_buff * skb = alloc_skb(size, priority);
@@ -861,7 +862,7 @@ struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force,
  * Allocate a skb from the socket's receive buffer.
  */ 
 struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force,
-                            unsigned int __nocast priority)
+                            gfp_t priority)
 {
        if (force || atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) {
                struct sk_buff *skb = alloc_skb(size, priority);
@@ -876,7 +877,7 @@ struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force,
 /* 
  * Allocate a memory block from the socket's option memory buffer.
  */ 
-void *sock_kmalloc(struct sock *sk, int size, unsigned int __nocast priority)
+void *sock_kmalloc(struct sock *sk, int size, gfp_t priority)
 {
        if ((unsigned)size <= sysctl_optmem_max &&
            atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) {
@@ -940,7 +941,7 @@ static struct sk_buff *sock_alloc_send_pskb(struct sock *sk,
                                            int noblock, int *errcode)
 {
        struct sk_buff *skb;
-       unsigned int gfp_mask;
+       gfp_t gfp_mask;
        long timeo;
        int err;
 
@@ -1242,8 +1243,7 @@ static void sock_def_write_space(struct sock *sk)
 
 static void sock_def_destruct(struct sock *sk)
 {
-       if (sk->sk_protinfo)
-               kfree(sk->sk_protinfo);
+       kfree(sk->sk_protinfo);
 }
 
 void sk_send_sigurg(struct sock *sk)
@@ -1489,7 +1489,7 @@ int proto_register(struct proto *prot, int alloc_slab)
                        }
                }
 
-               if (prot->twsk_obj_size) {
+               if (prot->twsk_prot != NULL) {
                        static const char mask[] = "tw_sock_%s";
 
                        timewait_sock_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL);
@@ -1498,11 +1498,12 @@ int proto_register(struct proto *prot, int alloc_slab)
                                goto out_free_request_sock_slab;
 
                        sprintf(timewait_sock_slab_name, mask, prot->name);
-                       prot->twsk_slab = kmem_cache_create(timewait_sock_slab_name,
-                                                           prot->twsk_obj_size,
-                                                           0, SLAB_HWCACHE_ALIGN,
-                                                           NULL, NULL);
-                       if (prot->twsk_slab == NULL)
+                       prot->twsk_prot->twsk_slab =
+                               kmem_cache_create(timewait_sock_slab_name,
+                                                 prot->twsk_prot->twsk_obj_size,
+                                                 0, SLAB_HWCACHE_ALIGN,
+                                                 NULL, NULL);
+                       if (prot->twsk_prot->twsk_slab == NULL)
                                goto out_free_timewait_sock_slab_name;
                }
        }
@@ -1549,12 +1550,12 @@ void proto_unregister(struct proto *prot)
                prot->rsk_prot->slab = NULL;
        }
 
-       if (prot->twsk_slab != NULL) {
-               const char *name = kmem_cache_name(prot->twsk_slab);
+       if (prot->twsk_prot != NULL && prot->twsk_prot->twsk_slab != NULL) {
+               const char *name = kmem_cache_name(prot->twsk_prot->twsk_slab);
 
-               kmem_cache_destroy(prot->twsk_slab);
+               kmem_cache_destroy(prot->twsk_prot->twsk_slab);
                kfree(name);
-               prot->twsk_slab = NULL;
+               prot->twsk_prot->twsk_slab = NULL;
        }
 }