diff options
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 100 |
1 files changed, 59 insertions, 41 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 659d968d95c5..21a02f7e4f45 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -57,7 +57,7 @@ | |||
57 | #include <linux/rculist_nulls.h> | 57 | #include <linux/rculist_nulls.h> |
58 | #include <linux/poll.h> | 58 | #include <linux/poll.h> |
59 | 59 | ||
60 | #include <asm/atomic.h> | 60 | #include <linux/atomic.h> |
61 | #include <net/dst.h> | 61 | #include <net/dst.h> |
62 | #include <net/checksum.h> | 62 | #include <net/checksum.h> |
63 | 63 | ||
@@ -105,10 +105,8 @@ struct net; | |||
105 | 105 | ||
106 | /** | 106 | /** |
107 | * struct sock_common - minimal network layer representation of sockets | 107 | * struct sock_common - minimal network layer representation of sockets |
108 | * @skc_node: main hash linkage for various protocol lookup tables | 108 | * @skc_daddr: Foreign IPv4 addr |
109 | * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol | 109 | * @skc_rcv_saddr: Bound local IPv4 addr |
110 | * @skc_refcnt: reference count | ||
111 | * @skc_tx_queue_mapping: tx queue number for this connection | ||
112 | * @skc_hash: hash value used with various protocol lookup tables | 110 | * @skc_hash: hash value used with various protocol lookup tables |
113 | * @skc_u16hashes: two u16 hash values used by UDP lookup tables | 111 | * @skc_u16hashes: two u16 hash values used by UDP lookup tables |
114 | * @skc_family: network address family | 112 | * @skc_family: network address family |
@@ -119,20 +117,20 @@ struct net; | |||
119 | * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol | 117 | * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol |
120 | * @skc_prot: protocol handlers inside a network family | 118 | * @skc_prot: protocol handlers inside a network family |
121 | * @skc_net: reference to the network namespace of this socket | 119 | * @skc_net: reference to the network namespace of this socket |
120 | * @skc_node: main hash linkage for various protocol lookup tables | ||
121 | * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol | ||
122 | * @skc_tx_queue_mapping: tx queue number for this connection | ||
123 | * @skc_refcnt: reference count | ||
122 | * | 124 | * |
123 | * This is the minimal network layer representation of sockets, the header | 125 | * This is the minimal network layer representation of sockets, the header |
124 | * for struct sock and struct inet_timewait_sock. | 126 | * for struct sock and struct inet_timewait_sock. |
125 | */ | 127 | */ |
126 | struct sock_common { | 128 | struct sock_common { |
127 | /* | 129 | /* skc_daddr and skc_rcv_saddr must be grouped : |
128 | * first fields are not copied in sock_copy() | 130 | * cf INET_MATCH() and INET_TW_MATCH() |
129 | */ | 131 | */ |
130 | union { | 132 | __be32 skc_daddr; |
131 | struct hlist_node skc_node; | 133 | __be32 skc_rcv_saddr; |
132 | struct hlist_nulls_node skc_nulls_node; | ||
133 | }; | ||
134 | atomic_t skc_refcnt; | ||
135 | int skc_tx_queue_mapping; | ||
136 | 134 | ||
137 | union { | 135 | union { |
138 | unsigned int skc_hash; | 136 | unsigned int skc_hash; |
@@ -150,6 +148,18 @@ struct sock_common { | |||
150 | #ifdef CONFIG_NET_NS | 148 | #ifdef CONFIG_NET_NS |
151 | struct net *skc_net; | 149 | struct net *skc_net; |
152 | #endif | 150 | #endif |
151 | /* | ||
152 | * fields between dontcopy_begin/dontcopy_end | ||
153 | * are not copied in sock_copy() | ||
154 | */ | ||
155 | int skc_dontcopy_begin[0]; | ||
156 | union { | ||
157 | struct hlist_node skc_node; | ||
158 | struct hlist_nulls_node skc_nulls_node; | ||
159 | }; | ||
160 | int skc_tx_queue_mapping; | ||
161 | atomic_t skc_refcnt; | ||
162 | int skc_dontcopy_end[0]; | ||
153 | }; | 163 | }; |
154 | 164 | ||
155 | /** | 165 | /** |
@@ -232,7 +242,8 @@ struct sock { | |||
232 | #define sk_refcnt __sk_common.skc_refcnt | 242 | #define sk_refcnt __sk_common.skc_refcnt |
233 | #define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping | 243 | #define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping |
234 | 244 | ||
235 | #define sk_copy_start __sk_common.skc_hash | 245 | #define sk_dontcopy_begin __sk_common.skc_dontcopy_begin |
246 | #define sk_dontcopy_end __sk_common.skc_dontcopy_end | ||
236 | #define sk_hash __sk_common.skc_hash | 247 | #define sk_hash __sk_common.skc_hash |
237 | #define sk_family __sk_common.skc_family | 248 | #define sk_family __sk_common.skc_family |
238 | #define sk_state __sk_common.skc_state | 249 | #define sk_state __sk_common.skc_state |
@@ -241,59 +252,67 @@ struct sock { | |||
241 | #define sk_bind_node __sk_common.skc_bind_node | 252 | #define sk_bind_node __sk_common.skc_bind_node |
242 | #define sk_prot __sk_common.skc_prot | 253 | #define sk_prot __sk_common.skc_prot |
243 | #define sk_net __sk_common.skc_net | 254 | #define sk_net __sk_common.skc_net |
244 | kmemcheck_bitfield_begin(flags); | ||
245 | unsigned int sk_shutdown : 2, | ||
246 | sk_no_check : 2, | ||
247 | sk_userlocks : 4, | ||
248 | sk_protocol : 8, | ||
249 | sk_type : 16; | ||
250 | kmemcheck_bitfield_end(flags); | ||
251 | int sk_rcvbuf; | ||
252 | socket_lock_t sk_lock; | 255 | socket_lock_t sk_lock; |
256 | struct sk_buff_head sk_receive_queue; | ||
253 | /* | 257 | /* |
254 | * The backlog queue is special, it is always used with | 258 | * The backlog queue is special, it is always used with |
255 | * the per-socket spinlock held and requires low latency | 259 | * the per-socket spinlock held and requires low latency |
256 | * access. Therefore we special case it's implementation. | 260 | * access. Therefore we special case it's implementation. |
261 | * Note : rmem_alloc is in this structure to fill a hole | ||
262 | * on 64bit arches, not because its logically part of | ||
263 | * backlog. | ||
257 | */ | 264 | */ |
258 | struct { | 265 | struct { |
259 | struct sk_buff *head; | 266 | atomic_t rmem_alloc; |
260 | struct sk_buff *tail; | 267 | int len; |
261 | int len; | 268 | struct sk_buff *head; |
269 | struct sk_buff *tail; | ||
262 | } sk_backlog; | 270 | } sk_backlog; |
271 | #define sk_rmem_alloc sk_backlog.rmem_alloc | ||
272 | int sk_forward_alloc; | ||
273 | #ifdef CONFIG_RPS | ||
274 | __u32 sk_rxhash; | ||
275 | #endif | ||
276 | atomic_t sk_drops; | ||
277 | int sk_rcvbuf; | ||
278 | |||
279 | struct sk_filter __rcu *sk_filter; | ||
263 | struct socket_wq *sk_wq; | 280 | struct socket_wq *sk_wq; |
264 | struct dst_entry *sk_dst_cache; | 281 | |
282 | #ifdef CONFIG_NET_DMA | ||
283 | struct sk_buff_head sk_async_wait_queue; | ||
284 | #endif | ||
285 | |||
265 | #ifdef CONFIG_XFRM | 286 | #ifdef CONFIG_XFRM |
266 | struct xfrm_policy *sk_policy[2]; | 287 | struct xfrm_policy *sk_policy[2]; |
267 | #endif | 288 | #endif |
289 | unsigned long sk_flags; | ||
290 | struct dst_entry *sk_dst_cache; | ||
268 | spinlock_t sk_dst_lock; | 291 | spinlock_t sk_dst_lock; |
269 | atomic_t sk_rmem_alloc; | ||
270 | atomic_t sk_wmem_alloc; | 292 | atomic_t sk_wmem_alloc; |
271 | atomic_t sk_omem_alloc; | 293 | atomic_t sk_omem_alloc; |
272 | int sk_sndbuf; | 294 | int sk_sndbuf; |
273 | struct sk_buff_head sk_receive_queue; | ||
274 | struct sk_buff_head sk_write_queue; | 295 | struct sk_buff_head sk_write_queue; |
275 | #ifdef CONFIG_NET_DMA | 296 | kmemcheck_bitfield_begin(flags); |
276 | struct sk_buff_head sk_async_wait_queue; | 297 | unsigned int sk_shutdown : 2, |
277 | #endif | 298 | sk_no_check : 2, |
299 | sk_userlocks : 4, | ||
300 | sk_protocol : 8, | ||
301 | sk_type : 16; | ||
302 | kmemcheck_bitfield_end(flags); | ||
278 | int sk_wmem_queued; | 303 | int sk_wmem_queued; |
279 | int sk_forward_alloc; | ||
280 | gfp_t sk_allocation; | 304 | gfp_t sk_allocation; |
281 | int sk_route_caps; | 305 | int sk_route_caps; |
282 | int sk_route_nocaps; | 306 | int sk_route_nocaps; |
283 | int sk_gso_type; | 307 | int sk_gso_type; |
284 | unsigned int sk_gso_max_size; | 308 | unsigned int sk_gso_max_size; |
285 | int sk_rcvlowat; | 309 | int sk_rcvlowat; |
286 | #ifdef CONFIG_RPS | ||
287 | __u32 sk_rxhash; | ||
288 | #endif | ||
289 | unsigned long sk_flags; | ||
290 | unsigned long sk_lingertime; | 310 | unsigned long sk_lingertime; |
291 | struct sk_buff_head sk_error_queue; | 311 | struct sk_buff_head sk_error_queue; |
292 | struct proto *sk_prot_creator; | 312 | struct proto *sk_prot_creator; |
293 | rwlock_t sk_callback_lock; | 313 | rwlock_t sk_callback_lock; |
294 | int sk_err, | 314 | int sk_err, |
295 | sk_err_soft; | 315 | sk_err_soft; |
296 | atomic_t sk_drops; | ||
297 | unsigned short sk_ack_backlog; | 316 | unsigned short sk_ack_backlog; |
298 | unsigned short sk_max_ack_backlog; | 317 | unsigned short sk_max_ack_backlog; |
299 | __u32 sk_priority; | 318 | __u32 sk_priority; |
@@ -301,7 +320,6 @@ struct sock { | |||
301 | const struct cred *sk_peer_cred; | 320 | const struct cred *sk_peer_cred; |
302 | long sk_rcvtimeo; | 321 | long sk_rcvtimeo; |
303 | long sk_sndtimeo; | 322 | long sk_sndtimeo; |
304 | struct sk_filter __rcu *sk_filter; | ||
305 | void *sk_protinfo; | 323 | void *sk_protinfo; |
306 | struct timer_list sk_timer; | 324 | struct timer_list sk_timer; |
307 | ktime_t sk_stamp; | 325 | ktime_t sk_stamp; |
@@ -509,9 +527,6 @@ static __inline__ void sk_add_bind_node(struct sock *sk, | |||
509 | #define sk_nulls_for_each_from(__sk, node) \ | 527 | #define sk_nulls_for_each_from(__sk, node) \ |
510 | if (__sk && ({ node = &(__sk)->sk_nulls_node; 1; })) \ | 528 | if (__sk && ({ node = &(__sk)->sk_nulls_node; 1; })) \ |
511 | hlist_nulls_for_each_entry_from(__sk, node, sk_nulls_node) | 529 | hlist_nulls_for_each_entry_from(__sk, node, sk_nulls_node) |
512 | #define sk_for_each_continue(__sk, node) \ | ||
513 | if (__sk && ({ node = &(__sk)->sk_node; 1; })) \ | ||
514 | hlist_for_each_entry_continue(__sk, node, sk_node) | ||
515 | #define sk_for_each_safe(__sk, node, tmp, list) \ | 530 | #define sk_for_each_safe(__sk, node, tmp, list) \ |
516 | hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node) | 531 | hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node) |
517 | #define sk_for_each_bound(__sk, node, list) \ | 532 | #define sk_for_each_bound(__sk, node, list) \ |
@@ -754,6 +769,7 @@ struct proto { | |||
754 | void (*unhash)(struct sock *sk); | 769 | void (*unhash)(struct sock *sk); |
755 | void (*rehash)(struct sock *sk); | 770 | void (*rehash)(struct sock *sk); |
756 | int (*get_port)(struct sock *sk, unsigned short snum); | 771 | int (*get_port)(struct sock *sk, unsigned short snum); |
772 | void (*clear_sk)(struct sock *sk, int size); | ||
757 | 773 | ||
758 | /* Keeping track of sockets in use */ | 774 | /* Keeping track of sockets in use */ |
759 | #ifdef CONFIG_PROC_FS | 775 | #ifdef CONFIG_PROC_FS |
@@ -852,6 +868,8 @@ static inline void __sk_prot_rehash(struct sock *sk) | |||
852 | sk->sk_prot->hash(sk); | 868 | sk->sk_prot->hash(sk); |
853 | } | 869 | } |
854 | 870 | ||
871 | void sk_prot_clear_portaddr_nulls(struct sock *sk, int size); | ||
872 | |||
855 | /* About 10 seconds */ | 873 | /* About 10 seconds */ |
856 | #define SOCK_DESTROY_TIME (10*HZ) | 874 | #define SOCK_DESTROY_TIME (10*HZ) |
857 | 875 | ||