diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-01 15:09:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-01 15:09:33 -0400 |
commit | 54866f032307063776b4eff7eadb131d47f9f9b4 (patch) | |
tree | 5fb7b5f886b43fbe115e81c14570c40c44956b53 | |
parent | b4d367fb20ed19be4a53fa88b407248aeb8bd461 (diff) | |
parent | 49259d34c52df6be482fefca946debe28ba9a2f6 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6:
[IRDA] IRNET: Fix build when TCGETS2 is defined.
[NET]: docbook fixes for netif_ functions
[NET]: Hide the net_ns kmem cache
[NET]: Mark the setup_net as __net_init
[NET]: Hide the dead code in the net_namespace.c
[NET]: Relax the reference counting of init_net_ns
[NETNS]: Make the init/exit hooks checks outside the loop
[NET]: Forget the zero_it argument of sk_alloc()
[NET]: Remove bogus zero_it argument from sk_alloc
[NET]: Make the sk_clone() lighter
[NET]: Move some core sock setup into sk_prot_alloc
[NET]: Auto-zero the allocated sock object
[NET]: Cleanup the allocation/freeing of the sock object
[NET]: Move the get_net() from sock_copy()
[NET]: Move the sock_copy() from the header
[TCP]: Another TAGBITS -> SACKED_ACKED|LOST conversion
[TCP]: Process DSACKs that reside within a SACK block
39 files changed, 280 insertions, 176 deletions
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 8936ed3469cf..a005d8f4c38e 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c | |||
@@ -491,7 +491,7 @@ static int pppoe_create(struct net *net, struct socket *sock) | |||
491 | int error = -ENOMEM; | 491 | int error = -ENOMEM; |
492 | struct sock *sk; | 492 | struct sock *sk; |
493 | 493 | ||
494 | sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto, 1); | 494 | sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto); |
495 | if (!sk) | 495 | if (!sk) |
496 | goto out; | 496 | goto out; |
497 | 497 | ||
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c index 921d4ef6d14b..f8904fd92369 100644 --- a/drivers/net/pppol2tp.c +++ b/drivers/net/pppol2tp.c | |||
@@ -1416,7 +1416,7 @@ static int pppol2tp_create(struct net *net, struct socket *sock) | |||
1416 | int error = -ENOMEM; | 1416 | int error = -ENOMEM; |
1417 | struct sock *sk; | 1417 | struct sock *sk; |
1418 | 1418 | ||
1419 | sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppol2tp_sk_proto, 1); | 1419 | sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppol2tp_sk_proto); |
1420 | if (!sk) | 1420 | if (!sk) |
1421 | goto out; | 1421 | goto out; |
1422 | 1422 | ||
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 9b0c8f12373e..1e6af4f174b6 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -739,6 +739,16 @@ static inline void *netdev_priv(const struct net_device *dev) | |||
739 | */ | 739 | */ |
740 | #define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev)) | 740 | #define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev)) |
741 | 741 | ||
742 | /** | ||
743 | * netif_napi_add - initialize a napi context | ||
744 | * @dev: network device | ||
745 | * @napi: napi context | ||
746 | * @poll: polling function | ||
747 | * @weight: default weight | ||
748 | * | ||
749 | * netif_napi_add() must be used to initialize a napi context prior to calling | ||
750 | * *any* of the other napi related functions. | ||
751 | */ | ||
742 | static inline void netif_napi_add(struct net_device *dev, | 752 | static inline void netif_napi_add(struct net_device *dev, |
743 | struct napi_struct *napi, | 753 | struct napi_struct *napi, |
744 | int (*poll)(struct napi_struct *, int), | 754 | int (*poll)(struct napi_struct *, int), |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 5279466606d2..1fd449a6530b 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -51,13 +51,12 @@ static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns) | |||
51 | } | 51 | } |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #ifdef CONFIG_NET_NS | ||
54 | extern void __put_net(struct net *net); | 55 | extern void __put_net(struct net *net); |
55 | 56 | ||
56 | static inline struct net *get_net(struct net *net) | 57 | static inline struct net *get_net(struct net *net) |
57 | { | 58 | { |
58 | #ifdef CONFIG_NET | ||
59 | atomic_inc(&net->count); | 59 | atomic_inc(&net->count); |
60 | #endif | ||
61 | return net; | 60 | return net; |
62 | } | 61 | } |
63 | 62 | ||
@@ -75,26 +74,44 @@ static inline struct net *maybe_get_net(struct net *net) | |||
75 | 74 | ||
76 | static inline void put_net(struct net *net) | 75 | static inline void put_net(struct net *net) |
77 | { | 76 | { |
78 | #ifdef CONFIG_NET | ||
79 | if (atomic_dec_and_test(&net->count)) | 77 | if (atomic_dec_and_test(&net->count)) |
80 | __put_net(net); | 78 | __put_net(net); |
81 | #endif | ||
82 | } | 79 | } |
83 | 80 | ||
84 | static inline struct net *hold_net(struct net *net) | 81 | static inline struct net *hold_net(struct net *net) |
85 | { | 82 | { |
86 | #ifdef CONFIG_NET | ||
87 | atomic_inc(&net->use_count); | 83 | atomic_inc(&net->use_count); |
88 | #endif | ||
89 | return net; | 84 | return net; |
90 | } | 85 | } |
91 | 86 | ||
92 | static inline void release_net(struct net *net) | 87 | static inline void release_net(struct net *net) |
93 | { | 88 | { |
94 | #ifdef CONFIG_NET | ||
95 | atomic_dec(&net->use_count); | 89 | atomic_dec(&net->use_count); |
96 | #endif | ||
97 | } | 90 | } |
91 | #else | ||
92 | static inline struct net *get_net(struct net *net) | ||
93 | { | ||
94 | return net; | ||
95 | } | ||
96 | |||
97 | static inline void put_net(struct net *net) | ||
98 | { | ||
99 | } | ||
100 | |||
101 | static inline struct net *hold_net(struct net *net) | ||
102 | { | ||
103 | return net; | ||
104 | } | ||
105 | |||
106 | static inline void release_net(struct net *net) | ||
107 | { | ||
108 | } | ||
109 | |||
110 | static inline struct net *maybe_get_net(struct net *net) | ||
111 | { | ||
112 | return net; | ||
113 | } | ||
114 | #endif | ||
98 | 115 | ||
99 | #define for_each_net(VAR) \ | 116 | #define for_each_net(VAR) \ |
100 | list_for_each_entry(VAR, &net_namespace_list, list) | 117 | list_for_each_entry(VAR, &net_namespace_list, list) |
diff --git a/include/net/sock.h b/include/net/sock.h index 43fc3fa50d62..20de3fa7ae40 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -779,7 +779,7 @@ extern void FASTCALL(release_sock(struct sock *sk)); | |||
779 | 779 | ||
780 | extern struct sock *sk_alloc(struct net *net, int family, | 780 | extern struct sock *sk_alloc(struct net *net, int family, |
781 | gfp_t priority, | 781 | gfp_t priority, |
782 | struct proto *prot, int zero_it); | 782 | struct proto *prot); |
783 | extern void sk_free(struct sock *sk); | 783 | extern void sk_free(struct sock *sk); |
784 | extern struct sock *sk_clone(const struct sock *sk, | 784 | extern struct sock *sk_clone(const struct sock *sk, |
785 | const gfp_t priority); | 785 | const gfp_t priority); |
@@ -993,20 +993,6 @@ static inline void sock_graft(struct sock *sk, struct socket *parent) | |||
993 | write_unlock_bh(&sk->sk_callback_lock); | 993 | write_unlock_bh(&sk->sk_callback_lock); |
994 | } | 994 | } |
995 | 995 | ||
996 | static inline void sock_copy(struct sock *nsk, const struct sock *osk) | ||
997 | { | ||
998 | #ifdef CONFIG_SECURITY_NETWORK | ||
999 | void *sptr = nsk->sk_security; | ||
1000 | #endif | ||
1001 | |||
1002 | memcpy(nsk, osk, osk->sk_prot->obj_size); | ||
1003 | get_net(nsk->sk_net); | ||
1004 | #ifdef CONFIG_SECURITY_NETWORK | ||
1005 | nsk->sk_security = sptr; | ||
1006 | security_sk_clone(osk, nsk); | ||
1007 | #endif | ||
1008 | } | ||
1009 | |||
1010 | extern int sock_i_uid(struct sock *sk); | 996 | extern int sock_i_uid(struct sock *sk); |
1011 | extern unsigned long sock_i_ino(struct sock *sk); | 997 | extern unsigned long sock_i_ino(struct sock *sk); |
1012 | 998 | ||
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 7c0b5151d526..e0d37d6dc1f8 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
@@ -1044,7 +1044,7 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol) | |||
1044 | if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM) | 1044 | if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM) |
1045 | goto out; | 1045 | goto out; |
1046 | rc = -ENOMEM; | 1046 | rc = -ENOMEM; |
1047 | sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto, 1); | 1047 | sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto); |
1048 | if (!sk) | 1048 | if (!sk) |
1049 | goto out; | 1049 | goto out; |
1050 | rc = 0; | 1050 | rc = 0; |
diff --git a/net/atm/common.c b/net/atm/common.c index e166d9e0ffd9..eba09a04f6bf 100644 --- a/net/atm/common.c +++ b/net/atm/common.c | |||
@@ -133,7 +133,7 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family) | |||
133 | sock->sk = NULL; | 133 | sock->sk = NULL; |
134 | if (sock->type == SOCK_STREAM) | 134 | if (sock->type == SOCK_STREAM) |
135 | return -EINVAL; | 135 | return -EINVAL; |
136 | sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto, 1); | 136 | sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto); |
137 | if (!sk) | 137 | if (!sk) |
138 | return -ENOMEM; | 138 | return -ENOMEM; |
139 | sock_init_data(sock, sk); | 139 | sock_init_data(sock, sk); |
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 993e5c75e909..8378afd54b30 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -836,7 +836,8 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol) | |||
836 | return -ESOCKTNOSUPPORT; | 836 | return -ESOCKTNOSUPPORT; |
837 | } | 837 | } |
838 | 838 | ||
839 | if ((sk = sk_alloc(net, PF_AX25, GFP_ATOMIC, &ax25_proto, 1)) == NULL) | 839 | sk = sk_alloc(net, PF_AX25, GFP_ATOMIC, &ax25_proto); |
840 | if (sk == NULL) | ||
840 | return -ENOMEM; | 841 | return -ENOMEM; |
841 | 842 | ||
842 | ax25 = sk->sk_protinfo = ax25_create_cb(); | 843 | ax25 = sk->sk_protinfo = ax25_create_cb(); |
@@ -861,7 +862,8 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev) | |||
861 | struct sock *sk; | 862 | struct sock *sk; |
862 | ax25_cb *ax25, *oax25; | 863 | ax25_cb *ax25, *oax25; |
863 | 864 | ||
864 | if ((sk = sk_alloc(osk->sk_net, PF_AX25, GFP_ATOMIC, osk->sk_prot, 1)) == NULL) | 865 | sk = sk_alloc(osk->sk_net, PF_AX25, GFP_ATOMIC, osk->sk_prot); |
866 | if (sk == NULL) | ||
865 | return NULL; | 867 | return NULL; |
866 | 868 | ||
867 | if ((ax25 = ax25_create_cb()) == NULL) { | 869 | if ((ax25 = ax25_create_cb()) == NULL) { |
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index f718965f296c..9ebd3c64474d 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c | |||
@@ -213,7 +213,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol) | |||
213 | if (sock->type != SOCK_RAW) | 213 | if (sock->type != SOCK_RAW) |
214 | return -ESOCKTNOSUPPORT; | 214 | return -ESOCKTNOSUPPORT; |
215 | 215 | ||
216 | sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto, 1); | 216 | sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto); |
217 | if (!sk) | 217 | if (!sk) |
218 | return -ENOMEM; | 218 | return -ENOMEM; |
219 | 219 | ||
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index cf700c20d11e..783edab12ce8 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c | |||
@@ -204,7 +204,7 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol) | |||
204 | if (sock->type != SOCK_RAW) | 204 | if (sock->type != SOCK_RAW) |
205 | return -ESOCKTNOSUPPORT; | 205 | return -ESOCKTNOSUPPORT; |
206 | 206 | ||
207 | sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto, 1); | 207 | sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto); |
208 | if (!sk) | 208 | if (!sk) |
209 | return -ENOMEM; | 209 | return -ENOMEM; |
210 | 210 | ||
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 8825102c517c..14991323c273 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -645,7 +645,7 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol) | |||
645 | 645 | ||
646 | sock->ops = &hci_sock_ops; | 646 | sock->ops = &hci_sock_ops; |
647 | 647 | ||
648 | sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, 1); | 648 | sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto); |
649 | if (!sk) | 649 | if (!sk) |
650 | return -ENOMEM; | 650 | return -ENOMEM; |
651 | 651 | ||
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 1de2b6fbcac0..3292b956a7c4 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c | |||
@@ -255,7 +255,7 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol) | |||
255 | if (sock->type != SOCK_RAW) | 255 | if (sock->type != SOCK_RAW) |
256 | return -ESOCKTNOSUPPORT; | 256 | return -ESOCKTNOSUPPORT; |
257 | 257 | ||
258 | sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, 1); | 258 | sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto); |
259 | if (!sk) | 259 | if (!sk) |
260 | return -ENOMEM; | 260 | return -ENOMEM; |
261 | 261 | ||
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 6fbbae78b304..477e052b17b5 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -607,7 +607,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p | |||
607 | { | 607 | { |
608 | struct sock *sk; | 608 | struct sock *sk; |
609 | 609 | ||
610 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto, 1); | 610 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto); |
611 | if (!sk) | 611 | if (!sk) |
612 | return NULL; | 612 | return NULL; |
613 | 613 | ||
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 266b6972667d..c46d51035e77 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -287,7 +287,7 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int | |||
287 | struct rfcomm_dlc *d; | 287 | struct rfcomm_dlc *d; |
288 | struct sock *sk; | 288 | struct sock *sk; |
289 | 289 | ||
290 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &rfcomm_proto, 1); | 290 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &rfcomm_proto); |
291 | if (!sk) | 291 | if (!sk) |
292 | return NULL; | 292 | return NULL; |
293 | 293 | ||
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 82d0dfdfa7e2..93ad1aae3f38 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -421,7 +421,7 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro | |||
421 | { | 421 | { |
422 | struct sock *sk; | 422 | struct sock *sk; |
423 | 423 | ||
424 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto, 1); | 424 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto); |
425 | if (!sk) | 425 | if (!sk) |
426 | return NULL; | 426 | return NULL; |
427 | 427 | ||
diff --git a/net/core/dev.c b/net/core/dev.c index 91ece48e127e..be6cedab5aa8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1751,9 +1751,6 @@ DEFINE_PER_CPU(struct netif_rx_stats, netdev_rx_stat) = { 0, }; | |||
1751 | * | 1751 | * |
1752 | * return values: | 1752 | * return values: |
1753 | * NET_RX_SUCCESS (no congestion) | 1753 | * NET_RX_SUCCESS (no congestion) |
1754 | * NET_RX_CN_LOW (low congestion) | ||
1755 | * NET_RX_CN_MOD (moderate congestion) | ||
1756 | * NET_RX_CN_HIGH (high congestion) | ||
1757 | * NET_RX_DROP (packet was dropped) | 1754 | * NET_RX_DROP (packet was dropped) |
1758 | * | 1755 | * |
1759 | */ | 1756 | */ |
@@ -2001,6 +1998,21 @@ out: | |||
2001 | } | 1998 | } |
2002 | #endif | 1999 | #endif |
2003 | 2000 | ||
2001 | /** | ||
2002 | * netif_receive_skb - process receive buffer from network | ||
2003 | * @skb: buffer to process | ||
2004 | * | ||
2005 | * netif_receive_skb() is the main receive data processing function. | ||
2006 | * It always succeeds. The buffer may be dropped during processing | ||
2007 | * for congestion control or by the protocol layers. | ||
2008 | * | ||
2009 | * This function may only be called from softirq context and interrupts | ||
2010 | * should be enabled. | ||
2011 | * | ||
2012 | * Return values (usually ignored): | ||
2013 | * NET_RX_SUCCESS: no congestion | ||
2014 | * NET_RX_DROP: packet was dropped | ||
2015 | */ | ||
2004 | int netif_receive_skb(struct sk_buff *skb) | 2016 | int netif_receive_skb(struct sk_buff *skb) |
2005 | { | 2017 | { |
2006 | struct packet_type *ptype, *pt_prev; | 2018 | struct packet_type *ptype, *pt_prev; |
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 662e6ea1cecf..e9f0964ce70b 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
@@ -17,74 +17,13 @@ static DEFINE_MUTEX(net_mutex); | |||
17 | 17 | ||
18 | LIST_HEAD(net_namespace_list); | 18 | LIST_HEAD(net_namespace_list); |
19 | 19 | ||
20 | static struct kmem_cache *net_cachep; | ||
21 | |||
22 | struct net init_net; | 20 | struct net init_net; |
23 | EXPORT_SYMBOL_GPL(init_net); | 21 | EXPORT_SYMBOL_GPL(init_net); |
24 | 22 | ||
25 | static struct net *net_alloc(void) | ||
26 | { | ||
27 | return kmem_cache_zalloc(net_cachep, GFP_KERNEL); | ||
28 | } | ||
29 | |||
30 | static void net_free(struct net *net) | ||
31 | { | ||
32 | if (!net) | ||
33 | return; | ||
34 | |||
35 | if (unlikely(atomic_read(&net->use_count) != 0)) { | ||
36 | printk(KERN_EMERG "network namespace not free! Usage: %d\n", | ||
37 | atomic_read(&net->use_count)); | ||
38 | return; | ||
39 | } | ||
40 | |||
41 | kmem_cache_free(net_cachep, net); | ||
42 | } | ||
43 | |||
44 | static void cleanup_net(struct work_struct *work) | ||
45 | { | ||
46 | struct pernet_operations *ops; | ||
47 | struct net *net; | ||
48 | |||
49 | net = container_of(work, struct net, work); | ||
50 | |||
51 | mutex_lock(&net_mutex); | ||
52 | |||
53 | /* Don't let anyone else find us. */ | ||
54 | rtnl_lock(); | ||
55 | list_del(&net->list); | ||
56 | rtnl_unlock(); | ||
57 | |||
58 | /* Run all of the network namespace exit methods */ | ||
59 | list_for_each_entry_reverse(ops, &pernet_list, list) { | ||
60 | if (ops->exit) | ||
61 | ops->exit(net); | ||
62 | } | ||
63 | |||
64 | mutex_unlock(&net_mutex); | ||
65 | |||
66 | /* Ensure there are no outstanding rcu callbacks using this | ||
67 | * network namespace. | ||
68 | */ | ||
69 | rcu_barrier(); | ||
70 | |||
71 | /* Finally it is safe to free my network namespace structure */ | ||
72 | net_free(net); | ||
73 | } | ||
74 | |||
75 | |||
76 | void __put_net(struct net *net) | ||
77 | { | ||
78 | /* Cleanup the network namespace in process context */ | ||
79 | INIT_WORK(&net->work, cleanup_net); | ||
80 | schedule_work(&net->work); | ||
81 | } | ||
82 | EXPORT_SYMBOL_GPL(__put_net); | ||
83 | |||
84 | /* | 23 | /* |
85 | * setup_net runs the initializers for the network namespace object. | 24 | * setup_net runs the initializers for the network namespace object. |
86 | */ | 25 | */ |
87 | static int setup_net(struct net *net) | 26 | static __net_init int setup_net(struct net *net) |
88 | { | 27 | { |
89 | /* Must be called with net_mutex held */ | 28 | /* Must be called with net_mutex held */ |
90 | struct pernet_operations *ops; | 29 | struct pernet_operations *ops; |
@@ -117,6 +56,14 @@ out_undo: | |||
117 | goto out; | 56 | goto out; |
118 | } | 57 | } |
119 | 58 | ||
59 | #ifdef CONFIG_NET_NS | ||
60 | static struct kmem_cache *net_cachep; | ||
61 | |||
62 | static struct net *net_alloc(void) | ||
63 | { | ||
64 | return kmem_cache_zalloc(net_cachep, GFP_KERNEL); | ||
65 | } | ||
66 | |||
120 | struct net *copy_net_ns(unsigned long flags, struct net *old_net) | 67 | struct net *copy_net_ns(unsigned long flags, struct net *old_net) |
121 | { | 68 | { |
122 | struct net *new_net = NULL; | 69 | struct net *new_net = NULL; |
@@ -127,10 +74,6 @@ struct net *copy_net_ns(unsigned long flags, struct net *old_net) | |||
127 | if (!(flags & CLONE_NEWNET)) | 74 | if (!(flags & CLONE_NEWNET)) |
128 | return old_net; | 75 | return old_net; |
129 | 76 | ||
130 | #ifndef CONFIG_NET_NS | ||
131 | return ERR_PTR(-EINVAL); | ||
132 | #endif | ||
133 | |||
134 | err = -ENOMEM; | 77 | err = -ENOMEM; |
135 | new_net = net_alloc(); | 78 | new_net = net_alloc(); |
136 | if (!new_net) | 79 | if (!new_net) |
@@ -157,14 +100,78 @@ out: | |||
157 | return new_net; | 100 | return new_net; |
158 | } | 101 | } |
159 | 102 | ||
103 | static void net_free(struct net *net) | ||
104 | { | ||
105 | if (!net) | ||
106 | return; | ||
107 | |||
108 | if (unlikely(atomic_read(&net->use_count) != 0)) { | ||
109 | printk(KERN_EMERG "network namespace not free! Usage: %d\n", | ||
110 | atomic_read(&net->use_count)); | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | kmem_cache_free(net_cachep, net); | ||
115 | } | ||
116 | |||
117 | static void cleanup_net(struct work_struct *work) | ||
118 | { | ||
119 | struct pernet_operations *ops; | ||
120 | struct net *net; | ||
121 | |||
122 | net = container_of(work, struct net, work); | ||
123 | |||
124 | mutex_lock(&net_mutex); | ||
125 | |||
126 | /* Don't let anyone else find us. */ | ||
127 | rtnl_lock(); | ||
128 | list_del(&net->list); | ||
129 | rtnl_unlock(); | ||
130 | |||
131 | /* Run all of the network namespace exit methods */ | ||
132 | list_for_each_entry_reverse(ops, &pernet_list, list) { | ||
133 | if (ops->exit) | ||
134 | ops->exit(net); | ||
135 | } | ||
136 | |||
137 | mutex_unlock(&net_mutex); | ||
138 | |||
139 | /* Ensure there are no outstanding rcu callbacks using this | ||
140 | * network namespace. | ||
141 | */ | ||
142 | rcu_barrier(); | ||
143 | |||
144 | /* Finally it is safe to free my network namespace structure */ | ||
145 | net_free(net); | ||
146 | } | ||
147 | |||
148 | void __put_net(struct net *net) | ||
149 | { | ||
150 | /* Cleanup the network namespace in process context */ | ||
151 | INIT_WORK(&net->work, cleanup_net); | ||
152 | schedule_work(&net->work); | ||
153 | } | ||
154 | EXPORT_SYMBOL_GPL(__put_net); | ||
155 | |||
156 | #else | ||
157 | struct net *copy_net_ns(unsigned long flags, struct net *old_net) | ||
158 | { | ||
159 | if (flags & CLONE_NEWNET) | ||
160 | return ERR_PTR(-EINVAL); | ||
161 | return old_net; | ||
162 | } | ||
163 | #endif | ||
164 | |||
160 | static int __init net_ns_init(void) | 165 | static int __init net_ns_init(void) |
161 | { | 166 | { |
162 | int err; | 167 | int err; |
163 | 168 | ||
164 | printk(KERN_INFO "net_namespace: %zd bytes\n", sizeof(struct net)); | 169 | printk(KERN_INFO "net_namespace: %zd bytes\n", sizeof(struct net)); |
170 | #ifdef CONFIG_NET_NS | ||
165 | net_cachep = kmem_cache_create("net_namespace", sizeof(struct net), | 171 | net_cachep = kmem_cache_create("net_namespace", sizeof(struct net), |
166 | SMP_CACHE_BYTES, | 172 | SMP_CACHE_BYTES, |
167 | SLAB_PANIC, NULL); | 173 | SLAB_PANIC, NULL); |
174 | #endif | ||
168 | mutex_lock(&net_mutex); | 175 | mutex_lock(&net_mutex); |
169 | err = setup_net(&init_net); | 176 | err = setup_net(&init_net); |
170 | 177 | ||
@@ -187,29 +194,28 @@ static int register_pernet_operations(struct list_head *list, | |||
187 | struct net *net, *undo_net; | 194 | struct net *net, *undo_net; |
188 | int error; | 195 | int error; |
189 | 196 | ||
190 | error = 0; | ||
191 | list_add_tail(&ops->list, list); | 197 | list_add_tail(&ops->list, list); |
192 | for_each_net(net) { | 198 | if (ops->init) { |
193 | if (ops->init) { | 199 | for_each_net(net) { |
194 | error = ops->init(net); | 200 | error = ops->init(net); |
195 | if (error) | 201 | if (error) |
196 | goto out_undo; | 202 | goto out_undo; |
197 | } | 203 | } |
198 | } | 204 | } |
199 | out: | 205 | return 0; |
200 | return error; | ||
201 | 206 | ||
202 | out_undo: | 207 | out_undo: |
203 | /* If I have an error cleanup all namespaces I initialized */ | 208 | /* If I have an error cleanup all namespaces I initialized */ |
204 | list_del(&ops->list); | 209 | list_del(&ops->list); |
205 | for_each_net(undo_net) { | 210 | if (ops->exit) { |
206 | if (undo_net == net) | 211 | for_each_net(undo_net) { |
207 | goto undone; | 212 | if (undo_net == net) |
208 | if (ops->exit) | 213 | goto undone; |
209 | ops->exit(undo_net); | 214 | ops->exit(undo_net); |
215 | } | ||
210 | } | 216 | } |
211 | undone: | 217 | undone: |
212 | goto out; | 218 | return error; |
213 | } | 219 | } |
214 | 220 | ||
215 | static void unregister_pernet_operations(struct pernet_operations *ops) | 221 | static void unregister_pernet_operations(struct pernet_operations *ops) |
@@ -217,8 +223,8 @@ static void unregister_pernet_operations(struct pernet_operations *ops) | |||
217 | struct net *net; | 223 | struct net *net; |
218 | 224 | ||
219 | list_del(&ops->list); | 225 | list_del(&ops->list); |
220 | for_each_net(net) | 226 | if (ops->exit) |
221 | if (ops->exit) | 227 | for_each_net(net) |
222 | ops->exit(net); | 228 | ops->exit(net); |
223 | } | 229 | } |
224 | 230 | ||
diff --git a/net/core/sock.c b/net/core/sock.c index bba9949681ff..12ad2067a988 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -857,46 +857,43 @@ static inline void sock_lock_init(struct sock *sk) | |||
857 | af_family_keys + sk->sk_family); | 857 | af_family_keys + sk->sk_family); |
858 | } | 858 | } |
859 | 859 | ||
860 | /** | 860 | static void sock_copy(struct sock *nsk, const struct sock *osk) |
861 | * sk_alloc - All socket objects are allocated here | 861 | { |
862 | * @net: the applicable net namespace | 862 | #ifdef CONFIG_SECURITY_NETWORK |
863 | * @family: protocol family | 863 | void *sptr = nsk->sk_security; |
864 | * @priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc) | 864 | #endif |
865 | * @prot: struct proto associated with this new sock instance | 865 | |
866 | * @zero_it: if we should zero the newly allocated sock | 866 | memcpy(nsk, osk, osk->sk_prot->obj_size); |
867 | */ | 867 | #ifdef CONFIG_SECURITY_NETWORK |
868 | struct sock *sk_alloc(struct net *net, int family, gfp_t priority, | 868 | nsk->sk_security = sptr; |
869 | struct proto *prot, int zero_it) | 869 | security_sk_clone(osk, nsk); |
870 | #endif | ||
871 | } | ||
872 | |||
873 | static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority, | ||
874 | int family) | ||
870 | { | 875 | { |
871 | struct sock *sk = NULL; | 876 | struct sock *sk; |
872 | struct kmem_cache *slab = prot->slab; | 877 | struct kmem_cache *slab; |
873 | 878 | ||
879 | slab = prot->slab; | ||
874 | if (slab != NULL) | 880 | if (slab != NULL) |
875 | sk = kmem_cache_alloc(slab, priority); | 881 | sk = kmem_cache_alloc(slab, priority); |
876 | else | 882 | else |
877 | sk = kmalloc(prot->obj_size, priority); | 883 | sk = kmalloc(prot->obj_size, priority); |
878 | 884 | ||
879 | if (sk) { | 885 | if (sk != NULL) { |
880 | if (zero_it) { | ||
881 | memset(sk, 0, prot->obj_size); | ||
882 | sk->sk_family = family; | ||
883 | /* | ||
884 | * See comment in struct sock definition to understand | ||
885 | * why we need sk_prot_creator -acme | ||
886 | */ | ||
887 | sk->sk_prot = sk->sk_prot_creator = prot; | ||
888 | sock_lock_init(sk); | ||
889 | sk->sk_net = get_net(net); | ||
890 | } | ||
891 | |||
892 | if (security_sk_alloc(sk, family, priority)) | 886 | if (security_sk_alloc(sk, family, priority)) |
893 | goto out_free; | 887 | goto out_free; |
894 | 888 | ||
895 | if (!try_module_get(prot->owner)) | 889 | if (!try_module_get(prot->owner)) |
896 | goto out_free; | 890 | goto out_free_sec; |
897 | } | 891 | } |
892 | |||
898 | return sk; | 893 | return sk; |
899 | 894 | ||
895 | out_free_sec: | ||
896 | security_sk_free(sk); | ||
900 | out_free: | 897 | out_free: |
901 | if (slab != NULL) | 898 | if (slab != NULL) |
902 | kmem_cache_free(slab, sk); | 899 | kmem_cache_free(slab, sk); |
@@ -905,10 +902,53 @@ out_free: | |||
905 | return NULL; | 902 | return NULL; |
906 | } | 903 | } |
907 | 904 | ||
905 | static void sk_prot_free(struct proto *prot, struct sock *sk) | ||
906 | { | ||
907 | struct kmem_cache *slab; | ||
908 | struct module *owner; | ||
909 | |||
910 | owner = prot->owner; | ||
911 | slab = prot->slab; | ||
912 | |||
913 | security_sk_free(sk); | ||
914 | if (slab != NULL) | ||
915 | kmem_cache_free(slab, sk); | ||
916 | else | ||
917 | kfree(sk); | ||
918 | module_put(owner); | ||
919 | } | ||
920 | |||
921 | /** | ||
922 | * sk_alloc - All socket objects are allocated here | ||
923 | * @net: the applicable net namespace | ||
924 | * @family: protocol family | ||
925 | * @priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc) | ||
926 | * @prot: struct proto associated with this new sock instance | ||
927 | * @zero_it: if we should zero the newly allocated sock | ||
928 | */ | ||
929 | struct sock *sk_alloc(struct net *net, int family, gfp_t priority, | ||
930 | struct proto *prot) | ||
931 | { | ||
932 | struct sock *sk; | ||
933 | |||
934 | sk = sk_prot_alloc(prot, priority | __GFP_ZERO, family); | ||
935 | if (sk) { | ||
936 | sk->sk_family = family; | ||
937 | /* | ||
938 | * See comment in struct sock definition to understand | ||
939 | * why we need sk_prot_creator -acme | ||
940 | */ | ||
941 | sk->sk_prot = sk->sk_prot_creator = prot; | ||
942 | sock_lock_init(sk); | ||
943 | sk->sk_net = get_net(net); | ||
944 | } | ||
945 | |||
946 | return sk; | ||
947 | } | ||
948 | |||
908 | void sk_free(struct sock *sk) | 949 | void sk_free(struct sock *sk) |
909 | { | 950 | { |
910 | struct sk_filter *filter; | 951 | struct sk_filter *filter; |
911 | struct module *owner = sk->sk_prot_creator->owner; | ||
912 | 952 | ||
913 | if (sk->sk_destruct) | 953 | if (sk->sk_destruct) |
914 | sk->sk_destruct(sk); | 954 | sk->sk_destruct(sk); |
@@ -925,25 +965,22 @@ void sk_free(struct sock *sk) | |||
925 | printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n", | 965 | printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n", |
926 | __FUNCTION__, atomic_read(&sk->sk_omem_alloc)); | 966 | __FUNCTION__, atomic_read(&sk->sk_omem_alloc)); |
927 | 967 | ||
928 | security_sk_free(sk); | ||
929 | put_net(sk->sk_net); | 968 | put_net(sk->sk_net); |
930 | if (sk->sk_prot_creator->slab != NULL) | 969 | sk_prot_free(sk->sk_prot_creator, sk); |
931 | kmem_cache_free(sk->sk_prot_creator->slab, sk); | ||
932 | else | ||
933 | kfree(sk); | ||
934 | module_put(owner); | ||
935 | } | 970 | } |
936 | 971 | ||
937 | struct sock *sk_clone(const struct sock *sk, const gfp_t priority) | 972 | struct sock *sk_clone(const struct sock *sk, const gfp_t priority) |
938 | { | 973 | { |
939 | struct sock *newsk = sk_alloc(sk->sk_net, sk->sk_family, priority, sk->sk_prot, 0); | 974 | struct sock *newsk; |
940 | 975 | ||
976 | newsk = sk_prot_alloc(sk->sk_prot, priority, sk->sk_family); | ||
941 | if (newsk != NULL) { | 977 | if (newsk != NULL) { |
942 | struct sk_filter *filter; | 978 | struct sk_filter *filter; |
943 | 979 | ||
944 | sock_copy(newsk, sk); | 980 | sock_copy(newsk, sk); |
945 | 981 | ||
946 | /* SANITY */ | 982 | /* SANITY */ |
983 | get_net(newsk->sk_net); | ||
947 | sk_node_init(&newsk->sk_node); | 984 | sk_node_init(&newsk->sk_node); |
948 | sock_lock_init(newsk); | 985 | sock_lock_init(newsk); |
949 | bh_lock_sock(newsk); | 986 | bh_lock_sock(newsk); |
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index aabe98d9402f..57d574951838 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c | |||
@@ -474,7 +474,7 @@ static struct proto dn_proto = { | |||
474 | static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp) | 474 | static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp) |
475 | { | 475 | { |
476 | struct dn_scp *scp; | 476 | struct dn_scp *scp; |
477 | struct sock *sk = sk_alloc(net, PF_DECnet, gfp, &dn_proto, 1); | 477 | struct sock *sk = sk_alloc(net, PF_DECnet, gfp, &dn_proto); |
478 | 478 | ||
479 | if (!sk) | 479 | if (!sk) |
480 | goto out; | 480 | goto out; |
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 9cae16b4e0b7..f70df073c588 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
@@ -624,7 +624,7 @@ static int econet_create(struct net *net, struct socket *sock, int protocol) | |||
624 | sock->state = SS_UNCONNECTED; | 624 | sock->state = SS_UNCONNECTED; |
625 | 625 | ||
626 | err = -ENOBUFS; | 626 | err = -ENOBUFS; |
627 | sk = sk_alloc(net, PF_ECONET, GFP_KERNEL, &econet_proto, 1); | 627 | sk = sk_alloc(net, PF_ECONET, GFP_KERNEL, &econet_proto); |
628 | if (sk == NULL) | 628 | if (sk == NULL) |
629 | goto out; | 629 | goto out; |
630 | 630 | ||
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 621b128897d7..d2f22e74b267 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -323,7 +323,7 @@ lookup_protocol: | |||
323 | BUG_TRAP(answer_prot->slab != NULL); | 323 | BUG_TRAP(answer_prot->slab != NULL); |
324 | 324 | ||
325 | err = -ENOBUFS; | 325 | err = -ENOBUFS; |
326 | sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot, 1); | 326 | sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot); |
327 | if (sk == NULL) | 327 | if (sk == NULL) |
328 | goto out; | 328 | goto out; |
329 | 329 | ||
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 69d8c38ccd39..ca9590f4f520 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -1330,12 +1330,15 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1330 | cached_fack_count = 0; | 1330 | cached_fack_count = 0; |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | for (i=0; i<num_sacks; i++, sp++) { | 1333 | for (i = 0; i < num_sacks; i++) { |
1334 | struct sk_buff *skb; | 1334 | struct sk_buff *skb; |
1335 | __u32 start_seq = ntohl(sp->start_seq); | 1335 | __u32 start_seq = ntohl(sp->start_seq); |
1336 | __u32 end_seq = ntohl(sp->end_seq); | 1336 | __u32 end_seq = ntohl(sp->end_seq); |
1337 | int fack_count; | 1337 | int fack_count; |
1338 | int dup_sack = (found_dup_sack && (i == first_sack_index)); | 1338 | int dup_sack = (found_dup_sack && (i == first_sack_index)); |
1339 | int next_dup = (found_dup_sack && (i+1 == first_sack_index)); | ||
1340 | |||
1341 | sp++; | ||
1339 | 1342 | ||
1340 | if (!tcp_is_sackblock_valid(tp, dup_sack, start_seq, end_seq)) { | 1343 | if (!tcp_is_sackblock_valid(tp, dup_sack, start_seq, end_seq)) { |
1341 | if (dup_sack) { | 1344 | if (dup_sack) { |
@@ -1361,7 +1364,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1361 | flag |= FLAG_DATA_LOST; | 1364 | flag |= FLAG_DATA_LOST; |
1362 | 1365 | ||
1363 | tcp_for_write_queue_from(skb, sk) { | 1366 | tcp_for_write_queue_from(skb, sk) { |
1364 | int in_sack; | 1367 | int in_sack = 0; |
1365 | u8 sacked; | 1368 | u8 sacked; |
1366 | 1369 | ||
1367 | if (skb == tcp_send_head(sk)) | 1370 | if (skb == tcp_send_head(sk)) |
@@ -1380,7 +1383,23 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1380 | if (!before(TCP_SKB_CB(skb)->seq, end_seq)) | 1383 | if (!before(TCP_SKB_CB(skb)->seq, end_seq)) |
1381 | break; | 1384 | break; |
1382 | 1385 | ||
1383 | in_sack = tcp_match_skb_to_sack(sk, skb, start_seq, end_seq); | 1386 | dup_sack = (found_dup_sack && (i == first_sack_index)); |
1387 | |||
1388 | /* Due to sorting DSACK may reside within this SACK block! */ | ||
1389 | if (next_dup) { | ||
1390 | u32 dup_start = ntohl(sp->start_seq); | ||
1391 | u32 dup_end = ntohl(sp->end_seq); | ||
1392 | |||
1393 | if (before(TCP_SKB_CB(skb)->seq, dup_end)) { | ||
1394 | in_sack = tcp_match_skb_to_sack(sk, skb, dup_start, dup_end); | ||
1395 | if (in_sack > 0) | ||
1396 | dup_sack = 1; | ||
1397 | } | ||
1398 | } | ||
1399 | |||
1400 | /* DSACK info lost if out-of-mem, try SACK still */ | ||
1401 | if (in_sack <= 0) | ||
1402 | in_sack = tcp_match_skb_to_sack(sk, skb, start_seq, end_seq); | ||
1384 | if (in_sack < 0) | 1403 | if (in_sack < 0) |
1385 | break; | 1404 | break; |
1386 | 1405 | ||
@@ -2059,7 +2078,7 @@ static void tcp_update_scoreboard(struct sock *sk) | |||
2059 | if (!tcp_skb_timedout(sk, skb)) | 2078 | if (!tcp_skb_timedout(sk, skb)) |
2060 | break; | 2079 | break; |
2061 | 2080 | ||
2062 | if (!(TCP_SKB_CB(skb)->sacked&TCPCB_TAGBITS)) { | 2081 | if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_SACKED_ACKED|TCPCB_LOST))) { |
2063 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; | 2082 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; |
2064 | tp->lost_out += tcp_skb_pcount(skb); | 2083 | tp->lost_out += tcp_skb_pcount(skb); |
2065 | tcp_verify_retransmit_hint(tp, skb); | 2084 | tcp_verify_retransmit_hint(tp, skb); |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 1b1caf3aa1c1..ecbd38894fdd 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -162,7 +162,7 @@ lookup_protocol: | |||
162 | BUG_TRAP(answer_prot->slab != NULL); | 162 | BUG_TRAP(answer_prot->slab != NULL); |
163 | 163 | ||
164 | err = -ENOBUFS; | 164 | err = -ENOBUFS; |
165 | sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot, 1); | 165 | sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot); |
166 | if (sk == NULL) | 166 | if (sk == NULL) |
167 | goto out; | 167 | goto out; |
168 | 168 | ||
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index 29b063d43120..a195a66e0cc7 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c | |||
@@ -1381,7 +1381,7 @@ static int ipx_create(struct net *net, struct socket *sock, int protocol) | |||
1381 | goto out; | 1381 | goto out; |
1382 | 1382 | ||
1383 | rc = -ENOMEM; | 1383 | rc = -ENOMEM; |
1384 | sk = sk_alloc(net, PF_IPX, GFP_KERNEL, &ipx_proto, 1); | 1384 | sk = sk_alloc(net, PF_IPX, GFP_KERNEL, &ipx_proto); |
1385 | if (!sk) | 1385 | if (!sk) |
1386 | goto out; | 1386 | goto out; |
1387 | #ifdef IPX_REFCNT_DEBUG | 1387 | #ifdef IPX_REFCNT_DEBUG |
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 0328ae2654f4..48ce59a6e026 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -1078,7 +1078,7 @@ static int irda_create(struct net *net, struct socket *sock, int protocol) | |||
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | /* Allocate networking socket */ | 1080 | /* Allocate networking socket */ |
1081 | sk = sk_alloc(net, PF_IRDA, GFP_ATOMIC, &irda_proto, 1); | 1081 | sk = sk_alloc(net, PF_IRDA, GFP_ATOMIC, &irda_proto); |
1082 | if (sk == NULL) | 1082 | if (sk == NULL) |
1083 | return -ENOMEM; | 1083 | return -ENOMEM; |
1084 | 1084 | ||
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index 2f9f8dce5a69..e0eab5927c4f 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c | |||
@@ -731,15 +731,25 @@ dev_irnet_ioctl(struct inode * inode, | |||
731 | /* Get termios */ | 731 | /* Get termios */ |
732 | case TCGETS: | 732 | case TCGETS: |
733 | DEBUG(FS_INFO, "Get termios.\n"); | 733 | DEBUG(FS_INFO, "Get termios.\n"); |
734 | #ifndef TCGETS2 | ||
734 | if(kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) | 735 | if(kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) |
735 | break; | 736 | break; |
737 | #else | ||
738 | if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) | ||
739 | break; | ||
740 | #endif | ||
736 | err = 0; | 741 | err = 0; |
737 | break; | 742 | break; |
738 | /* Set termios */ | 743 | /* Set termios */ |
739 | case TCSETSF: | 744 | case TCSETSF: |
740 | DEBUG(FS_INFO, "Set termios.\n"); | 745 | DEBUG(FS_INFO, "Set termios.\n"); |
746 | #ifndef TCGETS2 | ||
741 | if(user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) | 747 | if(user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) |
742 | break; | 748 | break; |
749 | #else | ||
750 | if(user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) | ||
751 | break; | ||
752 | #endif | ||
743 | err = 0; | 753 | err = 0; |
744 | break; | 754 | break; |
745 | 755 | ||
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 43e01c8d382b..aef664580355 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
@@ -216,7 +216,7 @@ static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio) | |||
216 | { | 216 | { |
217 | struct sock *sk; | 217 | struct sock *sk; |
218 | 218 | ||
219 | sk = sk_alloc(&init_net, PF_IUCV, prio, &iucv_proto, 1); | 219 | sk = sk_alloc(&init_net, PF_IUCV, prio, &iucv_proto); |
220 | if (!sk) | 220 | if (!sk) |
221 | return NULL; | 221 | return NULL; |
222 | 222 | ||
diff --git a/net/key/af_key.c b/net/key/af_key.c index 266f112c38c2..10c89d47f685 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -152,7 +152,7 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol) | |||
152 | return -EPROTONOSUPPORT; | 152 | return -EPROTONOSUPPORT; |
153 | 153 | ||
154 | err = -ENOMEM; | 154 | err = -ENOMEM; |
155 | sk = sk_alloc(net, PF_KEY, GFP_KERNEL, &key_proto, 1); | 155 | sk = sk_alloc(net, PF_KEY, GFP_KERNEL, &key_proto); |
156 | if (sk == NULL) | 156 | if (sk == NULL) |
157 | goto out; | 157 | goto out; |
158 | 158 | ||
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c index 8ebc2769dfda..5c0b484237c8 100644 --- a/net/llc/llc_conn.c +++ b/net/llc/llc_conn.c | |||
@@ -869,7 +869,7 @@ static void llc_sk_init(struct sock* sk) | |||
869 | */ | 869 | */ |
870 | struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority, struct proto *prot) | 870 | struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority, struct proto *prot) |
871 | { | 871 | { |
872 | struct sock *sk = sk_alloc(net, family, priority, prot, 1); | 872 | struct sock *sk = sk_alloc(net, family, priority, prot); |
873 | 873 | ||
874 | if (!sk) | 874 | if (!sk) |
875 | goto out; | 875 | goto out; |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 4f994c0fb3f8..260171255576 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -396,7 +396,7 @@ static int __netlink_create(struct net *net, struct socket *sock, | |||
396 | 396 | ||
397 | sock->ops = &netlink_ops; | 397 | sock->ops = &netlink_ops; |
398 | 398 | ||
399 | sk = sk_alloc(net, PF_NETLINK, GFP_KERNEL, &netlink_proto, 1); | 399 | sk = sk_alloc(net, PF_NETLINK, GFP_KERNEL, &netlink_proto); |
400 | if (!sk) | 400 | if (!sk) |
401 | return -ENOMEM; | 401 | return -ENOMEM; |
402 | 402 | ||
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 3a4d479ea64e..972250c974f1 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c | |||
@@ -423,7 +423,8 @@ static int nr_create(struct net *net, struct socket *sock, int protocol) | |||
423 | if (sock->type != SOCK_SEQPACKET || protocol != 0) | 423 | if (sock->type != SOCK_SEQPACKET || protocol != 0) |
424 | return -ESOCKTNOSUPPORT; | 424 | return -ESOCKTNOSUPPORT; |
425 | 425 | ||
426 | if ((sk = sk_alloc(net, PF_NETROM, GFP_ATOMIC, &nr_proto, 1)) == NULL) | 426 | sk = sk_alloc(net, PF_NETROM, GFP_ATOMIC, &nr_proto); |
427 | if (sk == NULL) | ||
427 | return -ENOMEM; | 428 | return -ENOMEM; |
428 | 429 | ||
429 | nr = nr_sk(sk); | 430 | nr = nr_sk(sk); |
@@ -465,7 +466,8 @@ static struct sock *nr_make_new(struct sock *osk) | |||
465 | if (osk->sk_type != SOCK_SEQPACKET) | 466 | if (osk->sk_type != SOCK_SEQPACKET) |
466 | return NULL; | 467 | return NULL; |
467 | 468 | ||
468 | if ((sk = sk_alloc(osk->sk_net, PF_NETROM, GFP_ATOMIC, osk->sk_prot, 1)) == NULL) | 469 | sk = sk_alloc(osk->sk_net, PF_NETROM, GFP_ATOMIC, osk->sk_prot); |
470 | if (sk == NULL) | ||
469 | return NULL; | 471 | return NULL; |
470 | 472 | ||
471 | nr = nr_sk(sk); | 473 | nr = nr_sk(sk); |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d0936506b731..4cb2dfba0993 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -995,7 +995,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol) | |||
995 | sock->state = SS_UNCONNECTED; | 995 | sock->state = SS_UNCONNECTED; |
996 | 996 | ||
997 | err = -ENOBUFS; | 997 | err = -ENOBUFS; |
998 | sk = sk_alloc(net, PF_PACKET, GFP_KERNEL, &packet_proto, 1); | 998 | sk = sk_alloc(net, PF_PACKET, GFP_KERNEL, &packet_proto); |
999 | if (sk == NULL) | 999 | if (sk == NULL) |
1000 | goto out; | 1000 | goto out; |
1001 | 1001 | ||
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 509defe53ee5..ed2d65cd8010 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -513,7 +513,8 @@ static int rose_create(struct net *net, struct socket *sock, int protocol) | |||
513 | if (sock->type != SOCK_SEQPACKET || protocol != 0) | 513 | if (sock->type != SOCK_SEQPACKET || protocol != 0) |
514 | return -ESOCKTNOSUPPORT; | 514 | return -ESOCKTNOSUPPORT; |
515 | 515 | ||
516 | if ((sk = sk_alloc(net, PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL) | 516 | sk = sk_alloc(net, PF_ROSE, GFP_ATOMIC, &rose_proto); |
517 | if (sk == NULL) | ||
517 | return -ENOMEM; | 518 | return -ENOMEM; |
518 | 519 | ||
519 | rose = rose_sk(sk); | 520 | rose = rose_sk(sk); |
@@ -551,7 +552,8 @@ static struct sock *rose_make_new(struct sock *osk) | |||
551 | if (osk->sk_type != SOCK_SEQPACKET) | 552 | if (osk->sk_type != SOCK_SEQPACKET) |
552 | return NULL; | 553 | return NULL; |
553 | 554 | ||
554 | if ((sk = sk_alloc(osk->sk_net, PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL) | 555 | sk = sk_alloc(osk->sk_net, PF_ROSE, GFP_ATOMIC, &rose_proto); |
556 | if (sk == NULL) | ||
555 | return NULL; | 557 | return NULL; |
556 | 558 | ||
557 | rose = rose_sk(sk); | 559 | rose = rose_sk(sk); |
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c index c680017f5c8e..d6389450c4bf 100644 --- a/net/rxrpc/af_rxrpc.c +++ b/net/rxrpc/af_rxrpc.c | |||
@@ -627,7 +627,7 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol) | |||
627 | sock->ops = &rxrpc_rpc_ops; | 627 | sock->ops = &rxrpc_rpc_ops; |
628 | sock->state = SS_UNCONNECTED; | 628 | sock->state = SS_UNCONNECTED; |
629 | 629 | ||
630 | sk = sk_alloc(net, PF_RXRPC, GFP_KERNEL, &rxrpc_proto, 1); | 630 | sk = sk_alloc(net, PF_RXRPC, GFP_KERNEL, &rxrpc_proto); |
631 | if (!sk) | 631 | if (!sk) |
632 | return -ENOMEM; | 632 | return -ENOMEM; |
633 | 633 | ||
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index eb4deaf58914..7f31ff638bc6 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -631,7 +631,7 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk, | |||
631 | struct ipv6_pinfo *newnp, *np = inet6_sk(sk); | 631 | struct ipv6_pinfo *newnp, *np = inet6_sk(sk); |
632 | struct sctp6_sock *newsctp6sk; | 632 | struct sctp6_sock *newsctp6sk; |
633 | 633 | ||
634 | newsk = sk_alloc(sk->sk_net, PF_INET6, GFP_KERNEL, sk->sk_prot, 1); | 634 | newsk = sk_alloc(sk->sk_net, PF_INET6, GFP_KERNEL, sk->sk_prot); |
635 | if (!newsk) | 635 | if (!newsk) |
636 | goto out; | 636 | goto out; |
637 | 637 | ||
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index f5cd96f5fe74..40c1a47d1b8d 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -552,7 +552,8 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk, | |||
552 | { | 552 | { |
553 | struct inet_sock *inet = inet_sk(sk); | 553 | struct inet_sock *inet = inet_sk(sk); |
554 | struct inet_sock *newinet; | 554 | struct inet_sock *newinet; |
555 | struct sock *newsk = sk_alloc(sk->sk_net, PF_INET, GFP_KERNEL, sk->sk_prot, 1); | 555 | struct sock *newsk = sk_alloc(sk->sk_net, PF_INET, GFP_KERNEL, |
556 | sk->sk_prot); | ||
556 | 557 | ||
557 | if (!newsk) | 558 | if (!newsk) |
558 | goto out; | 559 | goto out; |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index e36b4b5a5222..6b792265dc06 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -201,7 +201,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol) | |||
201 | return -EPROTOTYPE; | 201 | return -EPROTOTYPE; |
202 | } | 202 | } |
203 | 203 | ||
204 | sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto, 1); | 204 | sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto); |
205 | if (!sk) { | 205 | if (!sk) { |
206 | tipc_deleteport(ref); | 206 | tipc_deleteport(ref); |
207 | return -ENOMEM; | 207 | return -ENOMEM; |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 9163ec526c2a..515e7a692f9b 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -602,7 +602,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock) | |||
602 | if (atomic_read(&unix_nr_socks) >= 2*get_max_files()) | 602 | if (atomic_read(&unix_nr_socks) >= 2*get_max_files()) |
603 | goto out; | 603 | goto out; |
604 | 604 | ||
605 | sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto, 1); | 605 | sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto); |
606 | if (!sk) | 606 | if (!sk) |
607 | goto out; | 607 | goto out; |
608 | 608 | ||
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index fc416f9606a9..92cfe8e3e0b8 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -472,7 +472,7 @@ static struct proto x25_proto = { | |||
472 | static struct sock *x25_alloc_socket(struct net *net) | 472 | static struct sock *x25_alloc_socket(struct net *net) |
473 | { | 473 | { |
474 | struct x25_sock *x25; | 474 | struct x25_sock *x25; |
475 | struct sock *sk = sk_alloc(net, AF_X25, GFP_ATOMIC, &x25_proto, 1); | 475 | struct sock *sk = sk_alloc(net, AF_X25, GFP_ATOMIC, &x25_proto); |
476 | 476 | ||
477 | if (!sk) | 477 | if (!sk) |
478 | goto out; | 478 | goto out; |