1STRUCT SOCK(9) Linux Networking STRUCT SOCK(9)
2
3
4
6 struct_sock - network layer representation of sockets
7
9 struct sock {
10 struct sock_common __sk_common;
11 #define sk_node __sk_common.skc_node
12 #define sk_nulls_node __sk_common.skc_nulls_node
13 #define sk_refcnt __sk_common.skc_refcnt
14 #define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping
15 #define sk_copy_start __sk_common.skc_hash
16 #define sk_hash __sk_common.skc_hash
17 #define sk_family __sk_common.skc_family
18 #define sk_state __sk_common.skc_state
19 #define sk_reuse __sk_common.skc_reuse
20 #define sk_bound_dev_if __sk_common.skc_bound_dev_if
21 #define sk_bind_node __sk_common.skc_bind_node
22 #define sk_prot __sk_common.skc_prot
23 #define sk_net __sk_common.skc_net
24 unsigned int sk_shutdown:2;
25 unsigned int sk_no_check:2;
26 unsigned int sk_userlocks:4;
27 unsigned int sk_protocol:8;
28 unsigned int sk_type:16;
29 int sk_rcvbuf;
30 socket_lock_t sk_lock;
31 struct sk_backlog;
32 struct socket_wq * sk_wq;
33 struct dst_entry * sk_dst_cache;
34 #ifdef CONFIG_XFRM
35 struct xfrm_policy * sk_policy[2];
36 #endif
37 spinlock_t sk_dst_lock;
38 atomic_t sk_rmem_alloc;
39 atomic_t sk_wmem_alloc;
40 atomic_t sk_omem_alloc;
41 int sk_sndbuf;
42 struct sk_buff_head sk_receive_queue;
43 struct sk_buff_head sk_write_queue;
44 #ifdef CONFIG_NET_DMA
45 struct sk_buff_head sk_async_wait_queue;
46 #endif
47 int sk_wmem_queued;
48 int sk_forward_alloc;
49 gfp_t sk_allocation;
50 int sk_route_caps;
51 int sk_route_nocaps;
52 int sk_gso_type;
53 unsigned int sk_gso_max_size;
54 int sk_rcvlowat;
55 #ifdef CONFIG_RPS
56 __u32 sk_rxhash;
57 #endif
58 unsigned long sk_flags;
59 unsigned long sk_lingertime;
60 struct sk_buff_head sk_error_queue;
61 struct proto * sk_prot_creator;
62 rwlock_t sk_callback_lock;
63 int sk_err;
64 int sk_err_soft;
65 atomic_t sk_drops;
66 unsigned short sk_ack_backlog;
67 unsigned short sk_max_ack_backlog;
68 __u32 sk_priority;
69 struct ucred sk_peercred;
70 long sk_rcvtimeo;
71 long sk_sndtimeo;
72 struct sk_filter * sk_filter;
73 void * sk_protinfo;
74 struct timer_list sk_timer;
75 ktime_t sk_stamp;
76 struct socket * sk_socket;
77 void * sk_user_data;
78 struct page * sk_sndmsg_page;
79 struct sk_buff * sk_send_head;
80 __u32 sk_sndmsg_off;
81 int sk_write_pending;
82 #ifdef CONFIG_SECURITY
83 void * sk_security;
84 #endif
85 __u32 sk_mark;
86 void (* sk_state_change) (struct sock *sk);
87 void (* sk_data_ready) (struct sock *sk, int bytes);
88 void (* sk_write_space) (struct sock *sk);
89 void (* sk_error_report) (struct sock *sk);
90 int (* sk_backlog_rcv) (struct sock *sk,struct sk_buff *skb);
91 void (* sk_destruct) (struct sock *sk);
92 };
93
95 __sk_common
96 shared layout with inet_timewait_sock
97
98 sk_shutdown
99 mask of SEND_SHUTDOWN and/or RCV_SHUTDOWN
100
101 sk_no_check
102
103 SO_NO_CHECK setting, wether or not checkup packets
104
105 sk_userlocks
106
107 SO_SNDBUF and SO_RCVBUF settings
108
109 sk_protocol
110 which protocol this socket belongs in this network family
111
112 sk_type
113 socket type (SOCK_STREAM, etc)
114
115 sk_rcvbuf
116 size of receive buffer in bytes
117
118 sk_lock
119 synchronizer
120
121 sk_backlog
122 always used with the per-socket spinlock held
123
124 sk_wq
125 sock wait queue and async head
126
127 sk_dst_cache
128 destination cache
129
130 sk_policy[2]
131 flow policy
132
133 sk_dst_lock
134 destination cache lock
135
136 sk_rmem_alloc
137 receive queue bytes committed
138
139 sk_wmem_alloc
140 transmit queue bytes committed
141
142 sk_omem_alloc
143 "o“ is ”option“ or ”other"
144
145 sk_sndbuf
146 size of send buffer in bytes
147
148 sk_receive_queue
149 incoming packets
150
151 sk_write_queue
152 Packet sending queue
153
154 sk_async_wait_queue
155 DMA copied packets
156
157 sk_wmem_queued
158 persistent queue size
159
160 sk_forward_alloc
161 space allocated forward
162
163 sk_allocation
164 allocation mode
165
166 sk_route_caps
167 route capabilities (e.g. NETIF_F_TSO)
168
169 sk_route_nocaps
170 forbidden route capabilities (e.g NETIF_F_GSO_MASK)
171
172 sk_gso_type
173 GSO type (e.g. SKB_GSO_TCPV4)
174
175 sk_gso_max_size
176 Maximum GSO segment size to build
177
178 sk_rcvlowat
179
180 SO_RCVLOWAT setting
181
182 sk_rxhash
183 flow hash received from netif layer
184
185 sk_flags
186
187 SO_LINGER (l_onoff), SO_BROADCAST, SO_KEEPALIVE, SO_OOBINLINE
188 settings, SO_TIMESTAMPING settings
189
190 sk_lingertime
191
192 SO_LINGER l_linger setting
193
194 sk_error_queue
195 rarely used
196
197 sk_prot_creator
198 sk_prot of original sock creator (see ipv6_setsockopt,
199 IPV6_ADDRFORM for instance)
200
201 sk_callback_lock
202 used with the callbacks in the end of this struct
203
204 sk_err
205 last error
206
207 sk_err_soft
208 errors that don't cause failure but are the cause of a persistent
209 failure not just 'timed out'
210
211 sk_drops
212 raw/udp drops counter
213
214 sk_ack_backlog
215 current listen backlog
216
217 sk_max_ack_backlog
218 listen backlog set in listen
219
220 sk_priority
221
222 SO_PRIORITY setting
223
224 sk_peercred
225
226 SO_PEERCRED setting
227
228 sk_rcvtimeo
229
230 SO_RCVTIMEO setting
231
232 sk_sndtimeo
233
234 SO_SNDTIMEO setting
235
236 sk_filter
237 socket filtering instructions
238
239 sk_protinfo
240 private area, net family specific, when not using slab
241
242 sk_timer
243 sock cleanup timer
244
245 sk_stamp
246 time stamp of last packet received
247
248 sk_socket
249 Identd and reporting IO signals
250
251 sk_user_data
252 RPC layer private data
253
254 sk_sndmsg_page
255 cached page for sendmsg
256
257 sk_send_head
258 front of stuff to transmit
259
260 sk_sndmsg_off
261 cached offset for sendmsg
262
263 sk_write_pending
264 a write to stream socket waits to start
265
266 sk_security
267 used by security modules
268
269 sk_mark
270 generic packet mark
271
272 sk_state_change
273 callback to indicate change in the state of the sock
274
275 sk_data_ready
276 callback to indicate there is data to be processed
277
278 sk_write_space
279 callback to indicate there is bf sending space available
280
281 sk_error_report
282 callback to indicate errors (e.g. MSG_ERRQUEUE)
283
284 sk_backlog_rcv
285 callback to process the backlog
286
287 sk_destruct
288 called at sock freeing time, i.e. when all refcnt == 0
289
291Kernel Hackers Manual 2.6. November 2011 STRUCT SOCK(9)