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_dontcopy_begin __sk_common.skc_dontcopy_begin
16 #define sk_dontcopy_end __sk_common.skc_dontcopy_end
17 #define sk_hash __sk_common.skc_hash
18 #define sk_portpair __sk_common.skc_portpair
19 #define sk_num __sk_common.skc_num
20 #define sk_dport __sk_common.skc_dport
21 #define sk_addrpair __sk_common.skc_addrpair
22 #define sk_daddr __sk_common.skc_daddr
23 #define sk_rcv_saddr __sk_common.skc_rcv_saddr
24 #define sk_family __sk_common.skc_family
25 #define sk_state __sk_common.skc_state
26 #define sk_reuse __sk_common.skc_reuse
27 #define sk_reuseport __sk_common.skc_reuseport
28 #define sk_bound_dev_if __sk_common.skc_bound_dev_if
29 #define sk_bind_node __sk_common.skc_bind_node
30 #define sk_prot __sk_common.skc_prot
31 #define sk_net __sk_common.skc_net
32 #define sk_v6_daddr __sk_common.skc_v6_daddr
33 #define sk_v6_rcv_saddr __sk_common.skc_v6_rcv_saddr
34 socket_lock_t sk_lock;
35 struct sk_buff_head sk_receive_queue;
36 struct sk_backlog;
37 #define sk_rmem_alloc sk_backlog.rmem_alloc
38 int sk_forward_alloc;
39 #ifdef CONFIG_RPS
40 __u32 sk_rxhash;
41 #endif
42 #ifdef CONFIG_NET_RX_BUSY_POLL
43 unsigned int sk_napi_id;
44 unsigned int sk_ll_usec;
45 #endif
46 atomic_t sk_drops;
47 int sk_rcvbuf;
48 struct sk_filter __rcu * sk_filter;
49 struct socket_wq __rcu * sk_wq;
50 #ifdef CONFIG_NET_DMA_RH_KABI
51 #ifdef CONFIG_XFRM
52 struct xfrm_policy * sk_policy[2];
53 #endif
54 unsigned long sk_flags;
55 struct dst_entry * sk_rx_dst;
56 struct dst_entry __rcu * sk_dst_cache;
57 RH_KABI_DEPRECATE(spinlock_t# sk_dst_lock)atomic_t sk_wmem_alloc;
58 atomic_t sk_omem_alloc;
59 int sk_sndbuf;
60 struct sk_buff_head sk_write_queue;
61 unsigned int sk_shutdown:2;
62 #ifdef __GENKSYMS__
63 #else
64 #endif
65 #define SK_PROTOCOL_MAX U8_MAX
66 int sk_wmem_queued;
67 gfp_t sk_allocation;
68 u32 sk_pacing_rate;
69 netdev_features_t sk_route_caps;
70 netdev_features_t sk_route_nocaps;
71 int sk_gso_type;
72 unsigned int sk_gso_max_size;
73 u16 sk_gso_max_segs;
74 int sk_rcvlowat;
75 unsigned long sk_lingertime;
76 struct sk_buff_head sk_error_queue;
77 struct proto * sk_prot_creator;
78 rwlock_t sk_callback_lock;
79 int sk_err;
80 int sk_err_soft;
81 unsigned short sk_ack_backlog;
82 unsigned short sk_max_ack_backlog;
83 __u32 sk_priority;
84 #if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
85 __u32 sk_cgrp_prioidx;
86 #endif
87 struct pid * sk_peer_pid;
88 const struct cred * sk_peer_cred;
89 long sk_rcvtimeo;
90 long sk_sndtimeo;
91 void * sk_protinfo;
92 struct timer_list sk_timer;
93 ktime_t sk_stamp;
94 struct socket * sk_socket;
95 void * sk_user_data;
96 struct page_frag sk_frag;
97 struct sk_buff * sk_send_head;
98 __s32 sk_peek_off;
99 int sk_write_pending;
100 #ifdef CONFIG_SECURITY
101 void * sk_security;
102 #endif
103 __u32 sk_mark;
104 u32 sk_classid;
105 struct cg_proto * sk_cgrp;
106 void (* sk_state_change) (struct sock *sk);
107 void (* sk_data_ready) (struct sock *sk, int bytes);
108 void (* sk_write_space) (struct sock *sk);
109 void (* sk_error_report) (struct sock *sk);
110 int (* sk_backlog_rcv) (struct sock *sk,struct sk_buff *skb);
111 void (* sk_destruct) (struct sock *sk);
112 #else
113 };
114
116 __sk_common
117 shared layout with inet_timewait_sock
118
119 sk_lock
120 synchronizer
121
122 sk_receive_queue
123 incoming packets
124
125 sk_backlog
126 always used with the per-socket spinlock held
127
128 sk_forward_alloc
129 space allocated forward
130
131 sk_rxhash
132 flow hash received from netif layer
133
134 sk_napi_id
135 id of the last napi context to receive data for sk
136
137 sk_ll_usec
138 usecs to busypoll when there is no data
139
140 sk_drops
141 raw/udp drops counter
142
143 sk_rcvbuf
144 size of receive buffer in bytes
145
146 sk_filter
147 socket filtering instructions
148
149 sk_wq
150 sock wait queue and async head
151
152 sk_policy[2]
153 flow policy
154
155 sk_flags
156 SO_LINGER (l_onoff), SO_BROADCAST, SO_KEEPALIVE, SO_OOBINLINE
157 settings, SO_TIMESTAMPING settings
158
159 sk_rx_dst
160 receive input route used by early demux
161
162 sk_dst_cache
163 destination cache
164
165 sk_wmem_alloc
166 transmit queue bytes committed
167
168 sk_omem_alloc
169 "o“ is ”option“ or ”other"
170
171 sk_sndbuf
172 size of send buffer in bytes
173
174 sk_write_queue
175 Packet sending queue
176
177 sk_shutdown
178 mask of SEND_SHUTDOWN and/or RCV_SHUTDOWN
179
180 sk_wmem_queued
181 persistent queue size
182
183 sk_allocation
184 allocation mode
185
186 sk_pacing_rate
187 Pacing rate (if supported by transport/packet scheduler)
188
189 sk_route_caps
190 route capabilities (e.g. NETIF_F_TSO)
191
192 sk_route_nocaps
193 forbidden route capabilities (e.g NETIF_F_GSO_MASK)
194
195 sk_gso_type
196 GSO type (e.g. SKB_GSO_TCPV4)
197
198 sk_gso_max_size
199 Maximum GSO segment size to build
200
201 sk_gso_max_segs
202 Maximum number of GSO segments
203
204 sk_rcvlowat
205 SO_RCVLOWAT setting
206
207 sk_lingertime
208 SO_LINGER l_linger setting
209
210 sk_error_queue
211 rarely used
212
213 sk_prot_creator
214 sk_prot of original sock creator (see ipv6_setsockopt,
215 IPV6_ADDRFORM for instance)
216
217 sk_callback_lock
218 used with the callbacks in the end of this struct
219
220 sk_err
221 last error
222
223 sk_err_soft
224 errors that don't cause failure but are the cause of a persistent
225 failure not just 'timed out'
226
227 sk_ack_backlog
228 current listen backlog
229
230 sk_max_ack_backlog
231 listen backlog set in listen
232
233 sk_priority
234 SO_PRIORITY setting
235
236 sk_cgrp_prioidx
237 socket group's priority map index
238
239 sk_peer_pid
240 struct pid for this socket's peer
241
242 sk_peer_cred
243 SO_PEERCRED setting
244
245 sk_rcvtimeo
246 SO_RCVTIMEO setting
247
248 sk_sndtimeo
249 SO_SNDTIMEO setting
250
251 sk_protinfo
252 private area, net family specific, when not using slab
253
254 sk_timer
255 sock cleanup timer
256
257 sk_stamp
258 time stamp of last packet received
259
260 sk_socket
261 Identd and reporting IO signals
262
263 sk_user_data
264 RPC layer private data
265
266 sk_frag
267 cached page frag
268
269 sk_send_head
270 front of stuff to transmit
271
272 sk_peek_off
273 current peek_offset value
274
275 sk_write_pending
276 a write to stream socket waits to start
277
278 sk_security
279 used by security modules
280
281 sk_mark
282 generic packet mark
283
284 sk_classid
285 this socket's cgroup classid
286
287 sk_cgrp
288 this socket's cgroup-specific proto data
289
290 sk_state_change
291 callback to indicate change in the state of the sock
292
293 sk_data_ready
294 callback to indicate there is data to be processed
295
296 sk_write_space
297 callback to indicate there is bf sending space available
298
299 sk_error_report
300 callback to indicate errors (e.g. MSG_ERRQUEUE)
301
302 sk_backlog_rcv
303 callback to process the backlog
304
305 sk_destruct
306 called at sock freeing time, i.e. when all refcnt == 0
307
309Kernel Hackers Manual 3.10 June 2019 STRUCT SOCK(9)