aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 4df4fa3c5de0..96e00b08698f 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * Version: $Id: sock.c,v 1.117 2002/02/01 22:01:03 davem Exp $ 10 * Version: $Id: sock.c,v 1.117 2002/02/01 22:01:03 davem Exp $
11 * 11 *
12 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 12 * Authors: Ross Biro
13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 * Florian La Roche, <flla@stud.uni-sb.de> 14 * Florian La Roche, <flla@stud.uni-sb.de>
15 * Alan Cox, <A.Cox@swansea.ac.uk> 15 * Alan Cox, <A.Cox@swansea.ac.uk>
@@ -97,7 +97,6 @@
97#include <linux/socket.h> 97#include <linux/socket.h>
98#include <linux/in.h> 98#include <linux/in.h>
99#include <linux/kernel.h> 99#include <linux/kernel.h>
100#include <linux/major.h>
101#include <linux/module.h> 100#include <linux/module.h>
102#include <linux/proc_fs.h> 101#include <linux/proc_fs.h>
103#include <linux/seq_file.h> 102#include <linux/seq_file.h>
@@ -617,10 +616,10 @@ lenout:
617 616
618/** 617/**
619 * sk_alloc - All socket objects are allocated here 618 * sk_alloc - All socket objects are allocated here
620 * @family - protocol family 619 * @family: protocol family
621 * @priority - for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc) 620 * @priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc)
622 * @prot - struct proto associated with this new sock instance 621 * @prot: struct proto associated with this new sock instance
623 * @zero_it - if we should zero the newly allocated sock 622 * @zero_it: if we should zero the newly allocated sock
624 */ 623 */
625struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it) 624struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it)
626{ 625{
@@ -636,7 +635,11 @@ struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it)
636 if (zero_it) { 635 if (zero_it) {
637 memset(sk, 0, prot->obj_size); 636 memset(sk, 0, prot->obj_size);
638 sk->sk_family = family; 637 sk->sk_family = family;
639 sk->sk_prot = prot; 638 /*
639 * See comment in struct sock definition to understand
640 * why we need sk_prot_creator -acme
641 */
642 sk->sk_prot = sk->sk_prot_creator = prot;
640 sock_lock_init(sk); 643 sock_lock_init(sk);
641 } 644 }
642 645
@@ -655,7 +658,7 @@ struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it)
655void sk_free(struct sock *sk) 658void sk_free(struct sock *sk)
656{ 659{
657 struct sk_filter *filter; 660 struct sk_filter *filter;
658 struct module *owner = sk->sk_prot->owner; 661 struct module *owner = sk->sk_prot_creator->owner;
659 662
660 if (sk->sk_destruct) 663 if (sk->sk_destruct)
661 sk->sk_destruct(sk); 664 sk->sk_destruct(sk);
@@ -673,8 +676,8 @@ void sk_free(struct sock *sk)
673 __FUNCTION__, atomic_read(&sk->sk_omem_alloc)); 676 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
674 677
675 security_sk_free(sk); 678 security_sk_free(sk);
676 if (sk->sk_prot->slab != NULL) 679 if (sk->sk_prot_creator->slab != NULL)
677 kmem_cache_free(sk->sk_prot->slab, sk); 680 kmem_cache_free(sk->sk_prot_creator->slab, sk);
678 else 681 else
679 kfree(sk); 682 kfree(sk);
680 module_put(owner); 683 module_put(owner);
@@ -971,8 +974,8 @@ static void __release_sock(struct sock *sk)
971 974
972/** 975/**
973 * sk_wait_data - wait for data to arrive at sk_receive_queue 976 * sk_wait_data - wait for data to arrive at sk_receive_queue
974 * sk - sock to wait on 977 * @sk: sock to wait on
975 * timeo - for how long 978 * @timeo: for how long
976 * 979 *
977 * Now socket state including sk->sk_err is changed only under lock, 980 * Now socket state including sk->sk_err is changed only under lock,
978 * hence we may omit checks after joining wait queue. 981 * hence we may omit checks after joining wait queue.