---
name: "struct_sock"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/struct_sock"
---

# struct\_sock(9)

network layer representation of sockets

## NAME

struct\_sock - network layer representation of sockets

## SYNOPSIS

```
struct sock {
  struct sock_common __sk_common;
#define sk_node			__sk_common.skc_node
#define sk_nulls_node		__sk_common.skc_nulls_node
#define sk_refcnt		__sk_common.skc_refcnt
#define sk_tx_queue_mapping	__sk_common.skc_tx_queue_mapping
#define sk_dontcopy_begin	__sk_common.skc_dontcopy_begin
#define sk_dontcopy_end		__sk_common.skc_dontcopy_end
#define sk_hash			__sk_common.skc_hash
#define sk_portpair		__sk_common.skc_portpair
#define sk_num			__sk_common.skc_num
#define sk_dport		__sk_common.skc_dport
#define sk_addrpair		__sk_common.skc_addrpair
#define sk_daddr		__sk_common.skc_daddr
#define sk_rcv_saddr		__sk_common.skc_rcv_saddr
#define sk_family		__sk_common.skc_family
#define sk_state		__sk_common.skc_state
#define sk_reuse		__sk_common.skc_reuse
#define sk_reuseport		__sk_common.skc_reuseport
#define sk_ipv6only		__sk_common.skc_ipv6only
#define sk_net_refcnt		__sk_common.skc_net_refcnt
#define sk_bound_dev_if		__sk_common.skc_bound_dev_if
#define sk_bind_node		__sk_common.skc_bind_node
#define sk_prot			__sk_common.skc_prot
#define sk_net			__sk_common.skc_net
#define sk_v6_daddr		__sk_common.skc_v6_daddr
#define sk_v6_rcv_saddr	__sk_common.skc_v6_rcv_saddr
#define sk_cookie		__sk_common.skc_cookie
#define sk_incoming_cpu		__sk_common.skc_incoming_cpu
#define sk_flags		__sk_common.skc_flags
#define sk_rxhash		__sk_common.skc_rxhash
  socket_lock_t sk_lock;
  struct sk_buff_head sk_receive_queue;
  struct {unnamed_struct};
#ifdef CONFIG_XFRM
  struct xfrm_policy __rcu * sk_policy[2];
#endif
  struct dst_entry * sk_rx_dst;
  struct dst_entry __rcu * sk_dst_cache;
  atomic_t sk_wmem_alloc;
  atomic_t sk_omem_alloc;
  int sk_sndbuf;
  struct sk_buff_head sk_write_queue;
  unsigned int sk_padding:2;
  unsigned int sk_no_check_tx:1;
  unsigned int sk_no_check_rx:1;
  unsigned int sk_userlocks:4;
  unsigned int sk_protocol:8;
  unsigned int sk_type:16;
#define SK_PROTOCOL_MAX U8_MAX
  int sk_wmem_queued;
  gfp_t sk_allocation;
  u32 sk_pacing_rate;
  u32 sk_max_pacing_rate;
  netdev_features_t sk_route_caps;
  netdev_features_t sk_route_nocaps;
  int sk_gso_type;
  unsigned int sk_gso_max_size;
  u16 sk_gso_max_segs;
  int sk_rcvlowat;
  unsigned long sk_lingertime;
  struct sk_buff_head sk_error_queue;
  struct proto * sk_prot_creator;
  rwlock_t sk_callback_lock;
  int sk_err;
  int sk_err_soft;
  u32 sk_ack_backlog;
  u32 sk_max_ack_backlog;
  __u32 sk_priority;
  __u32 sk_mark;
  struct pid * sk_peer_pid;
  const struct cred * sk_peer_cred;
  long sk_rcvtimeo;
  long sk_sndtimeo;
  struct timer_list sk_timer;
  ktime_t sk_stamp;
#if BITS_PER_LONG==32
  seqlock_t sk_stamp_seq;
#endif
  u16 sk_tsflags;
  u8 sk_shutdown;
  u32 sk_tskey;
  struct socket * sk_socket;
  void * sk_user_data;
  struct page_frag sk_frag;
  struct sk_buff * sk_send_head;
  __s32 sk_peek_off;
  int sk_write_pending;
#ifdef CONFIG_SECURITY
  void * sk_security;
#endif
  struct sock_cgroup_data sk_cgrp_data;
  struct mem_cgroup * sk_memcg;
  void (* sk_state_change) (struct sock *sk);
  void (* sk_data_ready) (struct sock *sk);
  void (* sk_write_space) (struct sock *sk);
  void (* sk_error_report) (struct sock *sk);
  int (* sk_backlog_rcv) (struct sock *sk,struct sk_buff *skb);
  void (* sk_destruct) (struct sock *sk);
  struct sock_reuseport __rcu * sk_reuseport_cb;
  struct rcu_head sk_rcu;
};
```

## MEMBERS

\_\_sk\_common

shared layout with inet\_timewait\_sock

sk\_lock

synchronizer

sk\_receive\_queue

incoming packets

{unnamed\_struct}

anonymous

sk\_policy\[2\]

flow policy

sk\_rx\_dst

receive input route used by early demux

sk\_dst\_cache

destination cache

sk\_wmem\_alloc

transmit queue bytes committed

sk\_omem\_alloc

"o“ is ”option“ or ”other"

sk\_sndbuf

size of send buffer in bytes

sk\_write\_queue

Packet sending queue

sk\_padding

unused element for alignment

sk\_no\_check\_tx

**SO\_NO\_CHECK** setting, set checksum in TX packets

sk\_no\_check\_rx

allow zero checksum in RX packets

sk\_userlocks

**SO\_SNDBUF** and **SO\_RCVBUF** settings

sk\_protocol

which protocol this socket belongs in this network family

sk\_type

socket type (**SOCK\_STREAM**, etc)

sk\_wmem\_queued

persistent queue size

sk\_allocation

allocation mode

sk\_pacing\_rate

Pacing rate (if supported by transport/packet scheduler)

sk\_max\_pacing\_rate

Maximum pacing rate (**SO\_MAX\_PACING\_RATE**)

sk\_route\_caps

route capabilities (e.g. **NETIF\_F\_TSO**)

sk\_route\_nocaps

forbidden route capabilities (e.g NETIF\_F\_GSO\_MASK)

sk\_gso\_type

GSO type (e.g. **SKB\_GSO\_TCPV4**)

sk\_gso\_max\_size

Maximum GSO segment size to build

sk\_gso\_max\_segs

Maximum number of GSO segments

sk\_rcvlowat

**SO\_RCVLOWAT** setting

sk\_lingertime

**SO\_LINGER** l\_linger setting

sk\_error\_queue

rarely used

sk\_prot\_creator

sk\_prot of original sock creator (see ipv6\_setsockopt, IPV6\_ADDRFORM for instance)

sk\_callback\_lock

used with the callbacks in the end of this struct

sk\_err

last error

sk\_err\_soft

errors that don't cause failure but are the cause of a persistent failure not just 'timed out'

sk\_ack\_backlog

current listen backlog

sk\_max\_ack\_backlog

listen backlog set in **listen**

sk\_priority

**SO\_PRIORITY** setting

sk\_mark

generic packet mark

sk\_peer\_pid

struct pid for this socket's peer

sk\_peer\_cred

**SO\_PEERCRED** setting

sk\_rcvtimeo

**SO\_RCVTIMEO** setting

sk\_sndtimeo

**SO\_SNDTIMEO** setting

sk\_timer

sock cleanup timer

sk\_stamp

time stamp of last packet received

sk\_stamp\_seq

lock for accessing sk\_stamp on 32 bit architectures only

sk\_tsflags

SO\_TIMESTAMPING socket options

sk\_shutdown

mask of **SEND\_SHUTDOWN** and/or **RCV\_SHUTDOWN**

sk\_tskey

counter to disambiguate concurrent tstamp requests

sk\_socket

Identd and reporting IO signals

sk\_user\_data

RPC layer private data

sk\_frag

cached page frag

sk\_send\_head

front of stuff to transmit

sk\_peek\_off

current peek\_offset value

sk\_write\_pending

a write to stream socket waits to start

sk\_security

used by security modules

sk\_cgrp\_data

cgroup data for this cgroup

sk\_memcg

this socket's memory cgroup association

sk\_state\_change

callback to indicate change in the state of the sock

sk\_data\_ready

callback to indicate there is data to be processed

sk\_write\_space

callback to indicate there is bf sending space available

sk\_error\_report

callback to indicate errors (e.g. **MSG\_ERRQUEUE**)

sk\_backlog\_rcv

callback to process the backlog

sk\_destruct

called at sock freeing time, i.e. when all refcnt == 0

sk\_reuseport\_cb

reuseport group container

sk\_rcu

used during RCU grace period

## COPYRIGHT
