1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct sock</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Networking and Network Devices APIs"><link rel="up" href="ch01s02.html" title="Socket Buffer Functions"><link rel="prev" href="API-struct-sock-common.html" title="struct sock_common"><link rel="next" href="API-sk-nulls-for-each-entry-offset.html" title="sk_nulls_for_each_entry_offset"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct sock</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-sock-common.html">Prev</a>&#160;</td><th width="60%" align="center">Socket Buffer Functions</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-sk-nulls-for-each-entry-offset.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-sock"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct sock &#8212; 
2     network layer representation of sockets
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting">
4struct sock {
5  struct sock_common __sk_common;
6#define sk_node			__sk_common.skc_node
7#define sk_nulls_node		__sk_common.skc_nulls_node
8#define sk_refcnt		__sk_common.skc_refcnt
9#define sk_tx_queue_mapping	__sk_common.skc_tx_queue_mapping
10#define sk_dontcopy_begin	__sk_common.skc_dontcopy_begin
11#define sk_dontcopy_end		__sk_common.skc_dontcopy_end
12#define sk_hash			__sk_common.skc_hash
13#define sk_portpair		__sk_common.skc_portpair
14#define sk_num			__sk_common.skc_num
15#define sk_dport		__sk_common.skc_dport
16#define sk_addrpair		__sk_common.skc_addrpair
17#define sk_daddr		__sk_common.skc_daddr
18#define sk_rcv_saddr		__sk_common.skc_rcv_saddr
19#define sk_family		__sk_common.skc_family
20#define sk_state		__sk_common.skc_state
21#define sk_reuse		__sk_common.skc_reuse
22#define sk_reuseport		__sk_common.skc_reuseport
23#define sk_ipv6only		__sk_common.skc_ipv6only
24#define sk_bound_dev_if		__sk_common.skc_bound_dev_if
25#define sk_bind_node		__sk_common.skc_bind_node
26#define sk_prot			__sk_common.skc_prot
27#define sk_net			__sk_common.skc_net
28#define sk_v6_daddr		__sk_common.skc_v6_daddr
29#define sk_v6_rcv_saddr	__sk_common.skc_v6_rcv_saddr
30#define sk_cookie		__sk_common.skc_cookie
31  socket_lock_t sk_lock;
32  struct sk_buff_head sk_receive_queue;
33  struct sk_backlog;
34#define sk_rmem_alloc sk_backlog.rmem_alloc
35  int sk_forward_alloc;
36#ifdef CONFIG_RPS
37  __u32 sk_rxhash;
38#endif
39  u16 sk_incoming_cpu;
40  __u32 sk_txhash;
41#ifdef CONFIG_NET_RX_BUSY_POLL
42  unsigned int sk_napi_id;
43  unsigned int sk_ll_usec;
44#endif
45  atomic_t sk_drops;
46  int sk_rcvbuf;
47  struct sk_filter __rcu * sk_filter;
48  struct socket_wq __rcu * sk_wq;
49#ifdef CONFIG_XFRM
50  struct xfrm_policy * sk_policy[2];
51#endif
52  unsigned long sk_flags;
53  struct dst_entry * sk_rx_dst;
54  struct dst_entry __rcu * sk_dst_cache;
55  spinlock_t sk_dst_lock;
56  atomic_t sk_wmem_alloc;
57  atomic_t sk_omem_alloc;
58  int sk_sndbuf;
59  struct sk_buff_head sk_write_queue;
60  unsigned int sk_shutdown:2;
61  unsigned int sk_no_check_tx:1;
62  unsigned int sk_no_check_rx:1;
63  unsigned int sk_userlocks:4;
64  unsigned int sk_protocol:8;
65#define SK_PROTOCOL_MAX U8_MAX
66  int sk_wmem_queued;
67  gfp_t sk_allocation;
68  u32 sk_pacing_rate;
69  u32 sk_max_pacing_rate;
70  netdev_features_t sk_route_caps;
71  netdev_features_t sk_route_nocaps;
72  int sk_gso_type;
73  unsigned int sk_gso_max_size;
74  u16 sk_gso_max_segs;
75  int sk_rcvlowat;
76  unsigned long sk_lingertime;
77  struct sk_buff_head sk_error_queue;
78  struct proto * sk_prot_creator;
79  rwlock_t sk_callback_lock;
80  int sk_err;
81  int sk_err_soft;
82  u32 sk_ack_backlog;
83  u32 sk_max_ack_backlog;
84  __u32 sk_priority;
85#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
86  __u32 sk_cgrp_prioidx;
87#endif
88  struct pid * sk_peer_pid;
89  const struct cred * sk_peer_cred;
90  long sk_rcvtimeo;
91  long sk_sndtimeo;
92  void * sk_protinfo;
93  struct timer_list sk_timer;
94  ktime_t sk_stamp;
95  u16 sk_tsflags;
96  u32 sk_tskey;
97  struct socket * sk_socket;
98  void * sk_user_data;
99  struct page_frag sk_frag;
100  struct sk_buff * sk_send_head;
101  __s32 sk_peek_off;
102  int sk_write_pending;
103#ifdef CONFIG_SECURITY
104  void * sk_security;
105#endif
106  __u32 sk_mark;
107  u32 sk_classid;
108  struct cg_proto * sk_cgrp;
109  void (* sk_state_change) (struct sock *sk);
110  void (* sk_data_ready) (struct sock *sk);
111  void (* sk_write_space) (struct sock *sk);
112  void (* sk_error_report) (struct sock *sk);
113  int (* sk_backlog_rcv) (struct sock *sk,struct sk_buff *skb);
114  void (* sk_destruct) (struct sock *sk);
115};  </pre></div><div class="refsect1"><a name="idp1095809716"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">__sk_common</span></dt><dd><p>
116   shared layout with inet_timewait_sock
117      </p></dd><dt><span class="term">sk_lock</span></dt><dd><p>
118   synchronizer
119      </p></dd><dt><span class="term">sk_receive_queue</span></dt><dd><p>
120   incoming packets
121      </p></dd><dt><span class="term">sk_backlog</span></dt><dd><p>
122   always used with the per-socket spinlock held
123      </p></dd><dt><span class="term">sk_forward_alloc</span></dt><dd><p>
124   space allocated forward
125      </p></dd><dt><span class="term">sk_rxhash</span></dt><dd><p>
126   flow hash received from netif layer
127      </p></dd><dt><span class="term">sk_incoming_cpu</span></dt><dd><p>
128   record cpu processing incoming packets
129      </p></dd><dt><span class="term">sk_txhash</span></dt><dd><p>
130   computed flow hash for use on transmit
131      </p></dd><dt><span class="term">sk_napi_id</span></dt><dd><p>
132   id of the last napi context to receive data for sk
133      </p></dd><dt><span class="term">sk_ll_usec</span></dt><dd><p>
134   usecs to busypoll when there is no data
135      </p></dd><dt><span class="term">sk_drops</span></dt><dd><p>
136   raw/udp drops counter
137      </p></dd><dt><span class="term">sk_rcvbuf</span></dt><dd><p>
138   size of receive buffer in bytes
139      </p></dd><dt><span class="term">sk_filter</span></dt><dd><p>
140   socket filtering instructions
141      </p></dd><dt><span class="term">sk_wq</span></dt><dd><p>
142   sock wait queue and async head
143      </p></dd><dt><span class="term">sk_policy[2]</span></dt><dd><p>
144   flow policy
145      </p></dd><dt><span class="term">sk_flags</span></dt><dd><p>
146   <code class="constant">SO_LINGER</code> (l_onoff), <code class="constant">SO_BROADCAST</code>, <code class="constant">SO_KEEPALIVE</code>,
147   <code class="constant">SO_OOBINLINE</code> settings, <code class="constant">SO_TIMESTAMPING</code> settings
148      </p></dd><dt><span class="term">sk_rx_dst</span></dt><dd><p>
149   receive input route used by early demux
150      </p></dd><dt><span class="term">sk_dst_cache</span></dt><dd><p>
151   destination cache
152      </p></dd><dt><span class="term">sk_dst_lock</span></dt><dd><p>
153   destination cache lock
154      </p></dd><dt><span class="term">sk_wmem_alloc</span></dt><dd><p>
155   transmit queue bytes committed
156      </p></dd><dt><span class="term">sk_omem_alloc</span></dt><dd><p>
157   "o<span class="quote">&#8220;<span class="quote"> is </span>&#8221;</span>option<span class="quote">&#8220;<span class="quote"> or </span>&#8221;</span>other"
158      </p></dd><dt><span class="term">sk_sndbuf</span></dt><dd><p>
159   size of send buffer in bytes
160      </p></dd><dt><span class="term">sk_write_queue</span></dt><dd><p>
161   Packet sending queue
162      </p></dd><dt><span class="term">sk_shutdown</span></dt><dd><p>
163   mask of <code class="constant">SEND_SHUTDOWN</code> and/or <code class="constant">RCV_SHUTDOWN</code>
164      </p></dd><dt><span class="term">sk_no_check_tx</span></dt><dd><p>
165   <code class="constant">SO_NO_CHECK</code> setting, set checksum in TX packets
166      </p></dd><dt><span class="term">sk_no_check_rx</span></dt><dd><p>
167   allow zero checksum in RX packets
168      </p></dd><dt><span class="term">sk_userlocks</span></dt><dd><p>
169   <code class="constant">SO_SNDBUF</code> and <code class="constant">SO_RCVBUF</code> settings
170      </p></dd><dt><span class="term">sk_protocol</span></dt><dd><p>
171   which protocol this socket belongs in this network family
172      </p></dd><dt><span class="term">sk_wmem_queued</span></dt><dd><p>
173   persistent queue size
174      </p></dd><dt><span class="term">sk_allocation</span></dt><dd><p>
175   allocation mode
176      </p></dd><dt><span class="term">sk_pacing_rate</span></dt><dd><p>
177   Pacing rate (if supported by transport/packet scheduler)
178      </p></dd><dt><span class="term">sk_max_pacing_rate</span></dt><dd><p>
179   Maximum pacing rate (<code class="constant">SO_MAX_PACING_RATE</code>)
180      </p></dd><dt><span class="term">sk_route_caps</span></dt><dd><p>
181   route capabilities (e.g. <code class="constant">NETIF_F_TSO</code>)
182      </p></dd><dt><span class="term">sk_route_nocaps</span></dt><dd><p>
183   forbidden route capabilities (e.g NETIF_F_GSO_MASK)
184      </p></dd><dt><span class="term">sk_gso_type</span></dt><dd><p>
185   GSO type (e.g. <code class="constant">SKB_GSO_TCPV4</code>)
186      </p></dd><dt><span class="term">sk_gso_max_size</span></dt><dd><p>
187   Maximum GSO segment size to build
188      </p></dd><dt><span class="term">sk_gso_max_segs</span></dt><dd><p>
189   Maximum number of GSO segments
190      </p></dd><dt><span class="term">sk_rcvlowat</span></dt><dd><p>
191   <code class="constant">SO_RCVLOWAT</code> setting
192      </p></dd><dt><span class="term">sk_lingertime</span></dt><dd><p>
193   <code class="constant">SO_LINGER</code> l_linger setting
194      </p></dd><dt><span class="term">sk_error_queue</span></dt><dd><p>
195   rarely used
196      </p></dd><dt><span class="term">sk_prot_creator</span></dt><dd><p>
197   sk_prot of original sock creator (see ipv6_setsockopt,
198   IPV6_ADDRFORM for instance)
199      </p></dd><dt><span class="term">sk_callback_lock</span></dt><dd><p>
200   used with the callbacks in the end of this struct
201      </p></dd><dt><span class="term">sk_err</span></dt><dd><p>
202   last error
203      </p></dd><dt><span class="term">sk_err_soft</span></dt><dd><p>
204   errors that don't cause failure but are the cause of a
205   persistent failure not just 'timed out'
206      </p></dd><dt><span class="term">sk_ack_backlog</span></dt><dd><p>
207   current listen backlog
208      </p></dd><dt><span class="term">sk_max_ack_backlog</span></dt><dd><p>
209   listen backlog set in <code class="function">listen</code>
210      </p></dd><dt><span class="term">sk_priority</span></dt><dd><p>
211   <code class="constant">SO_PRIORITY</code> setting
212      </p></dd><dt><span class="term">sk_cgrp_prioidx</span></dt><dd><p>
213   socket group's priority map index
214      </p></dd><dt><span class="term">sk_peer_pid</span></dt><dd><p>
215   <span class="structname">struct pid</span> for this socket's peer
216      </p></dd><dt><span class="term">sk_peer_cred</span></dt><dd><p>
217   <code class="constant">SO_PEERCRED</code> setting
218      </p></dd><dt><span class="term">sk_rcvtimeo</span></dt><dd><p>
219   <code class="constant">SO_RCVTIMEO</code> setting
220      </p></dd><dt><span class="term">sk_sndtimeo</span></dt><dd><p>
221   <code class="constant">SO_SNDTIMEO</code> setting
222      </p></dd><dt><span class="term">sk_protinfo</span></dt><dd><p>
223   private area, net family specific, when not using slab
224      </p></dd><dt><span class="term">sk_timer</span></dt><dd><p>
225   sock cleanup timer
226      </p></dd><dt><span class="term">sk_stamp</span></dt><dd><p>
227   time stamp of last packet received
228      </p></dd><dt><span class="term">sk_tsflags</span></dt><dd><p>
229   SO_TIMESTAMPING socket options
230      </p></dd><dt><span class="term">sk_tskey</span></dt><dd><p>
231   counter to disambiguate concurrent tstamp requests
232      </p></dd><dt><span class="term">sk_socket</span></dt><dd><p>
233   Identd and reporting IO signals
234      </p></dd><dt><span class="term">sk_user_data</span></dt><dd><p>
235   RPC layer private data
236      </p></dd><dt><span class="term">sk_frag</span></dt><dd><p>
237   cached page frag
238      </p></dd><dt><span class="term">sk_send_head</span></dt><dd><p>
239   front of stuff to transmit
240      </p></dd><dt><span class="term">sk_peek_off</span></dt><dd><p>
241   current peek_offset value
242      </p></dd><dt><span class="term">sk_write_pending</span></dt><dd><p>
243   a write to stream socket waits to start
244      </p></dd><dt><span class="term">sk_security</span></dt><dd><p>
245   used by security modules
246      </p></dd><dt><span class="term">sk_mark</span></dt><dd><p>
247   generic packet mark
248      </p></dd><dt><span class="term">sk_classid</span></dt><dd><p>
249   this socket's cgroup classid
250      </p></dd><dt><span class="term">sk_cgrp</span></dt><dd><p>
251   this socket's cgroup-specific proto data
252      </p></dd><dt><span class="term">sk_state_change</span></dt><dd><p>
253   callback to indicate change in the state of the sock
254      </p></dd><dt><span class="term">sk_data_ready</span></dt><dd><p>
255   callback to indicate there is data to be processed
256      </p></dd><dt><span class="term">sk_write_space</span></dt><dd><p>
257   callback to indicate there is bf sending space available
258      </p></dd><dt><span class="term">sk_error_report</span></dt><dd><p>
259   callback to indicate errors (e.g. <code class="constant">MSG_ERRQUEUE</code>)
260      </p></dd><dt><span class="term">sk_backlog_rcv</span></dt><dd><p>
261   callback to process the backlog
262      </p></dd><dt><span class="term">sk_destruct</span></dt><dd><p>
263   called at sock freeing time, i.e. when all refcnt == 0
264      </p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-struct-sock-common.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch01s02.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-sk-nulls-for-each-entry-offset.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct sock_common</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">sk_nulls_for_each_entry_offset</span></td></tr></table></div></body></html>
265