struct sock — network layer representation of sockets
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;
atomic_t sk_drops;
int sk_rcvlowat;
struct sk_buff_head sk_error_queue;
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_omem_alloc;
int sk_sndbuf;
int sk_wmem_queued;
atomic_t sk_wmem_alloc;
struct sk_buff * sk_send_head;
struct sk_buff_head sk_write_queue;
__s32 sk_peek_off;
int sk_write_pending;
__u32 sk_dst_pending_confirm;
long sk_sndtimeo;
struct timer_list sk_timer;
__u32 sk_priority;
__u32 sk_mark;
u32 sk_pacing_rate;
u32 sk_max_pacing_rate;
struct page_frag sk_frag;
netdev_features_t sk_route_caps;
netdev_features_t sk_route_nocaps;
int sk_gso_type;
unsigned int sk_gso_max_size;
gfp_t sk_allocation;
__u32 sk_txhash;
#ifdef __BIG_ENDIAN_BITFIELD
#define SK_FL_PROTO_SHIFT 16
#define SK_FL_PROTO_MASK 0x00ff0000
#define SK_FL_TYPE_SHIFT 0
#define SK_FL_TYPE_MASK 0x0000ffff
#else
#define SK_FL_PROTO_SHIFT 8
#define SK_FL_PROTO_MASK 0x0000ff00
#define SK_FL_TYPE_SHIFT 16
#define SK_FL_TYPE_MASK 0xffff0000
#endif
unsigned int sk_padding:1;
unsigned int sk_kern_sock:1;
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
u16 sk_gso_max_segs;
unsigned long sk_lingertime;
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;
struct pid * sk_peer_pid;
const struct cred * sk_peer_cred;
long sk_rcvtimeo;
ktime_t sk_stamp;
u16 sk_tsflags;
u8 sk_shutdown;
u32 sk_tskey;
struct socket * sk_socket;
void * sk_user_data;
#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;
}; struct sock_common __sk_commonshared layout with inet_timewait_sock
socket_lock_t sk_locksynchronizer
atomic_t sk_dropsraw/udp drops counter
int sk_rcvlowat
SO_RCVLOWAT setting
struct sk_buff_head sk_error_queuerarely used
struct sk_buff_head sk_receive_queueincoming packets
struct {unnamed_struct}anonymous
struct xfrm_policy __rcu * sk_policy[2]flow policy
struct dst_entry * sk_rx_dstreceive input route used by early demux
struct dst_entry __rcu * sk_dst_cachedestination cache
atomic_t sk_omem_alloc"o“ is ”option“ or ”other"
int sk_sndbufsize of send buffer in bytes
int sk_wmem_queuedpersistent queue size
atomic_t sk_wmem_alloctransmit queue bytes committed
struct sk_buff * sk_send_headfront of stuff to transmit
struct sk_buff_head sk_write_queuePacket sending queue
__s32 sk_peek_offcurrent peek_offset value
int sk_write_pendinga write to stream socket waits to start
__u32 sk_dst_pending_confirmneed to confirm neighbour
long sk_sndtimeo
SO_SNDTIMEO setting
struct timer_list sk_timersock cleanup timer
__u32 sk_priority
SO_PRIORITY setting
__u32 sk_markgeneric packet mark
u32 sk_pacing_ratePacing rate (if supported by transport/packet scheduler)
u32 sk_max_pacing_rate
Maximum pacing rate (SO_MAX_PACING_RATE)
struct page_frag sk_fragcached page frag
netdev_features_t sk_route_caps
route capabilities (e.g. NETIF_F_TSO)
netdev_features_t sk_route_nocapsforbidden route capabilities (e.g NETIF_F_GSO_MASK)
int sk_gso_type
GSO type (e.g. SKB_GSO_TCPV4)
unsigned int sk_gso_max_sizeMaximum GSO segment size to build
gfp_t sk_allocationallocation mode
__u32 sk_txhashcomputed flow hash for use on transmit
unsigned int:1 sk_paddingunused element for alignment
unsigned int:1 sk_kern_sockTrue if sock is using kernel lock classes
unsigned int:1 sk_no_check_tx
SO_NO_CHECK setting, set checksum in TX packets
unsigned int:1 sk_no_check_rxallow zero checksum in RX packets
unsigned int:4 sk_userlocks
SO_SNDBUF and SO_RCVBUF settings
unsigned int:8 sk_protocolwhich protocol this socket belongs in this network family
unsigned int:16 sk_type
socket type (SOCK_STREAM, etc)
u16 sk_gso_max_segsMaximum number of GSO segments
unsigned long sk_lingertime
SO_LINGER l_linger setting
struct proto * sk_prot_creatorsk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
rwlock_t sk_callback_lockused with the callbacks in the end of this struct
int sk_errlast error
int sk_err_softerrors that don't cause failure but are the cause of a persistent failure not just 'timed out'
u32 sk_ack_backlogcurrent listen backlog
u32 sk_max_ack_backlog
listen backlog set in listen
struct pid * sk_peer_pidstruct pid for this socket's peer
const struct cred * sk_peer_cred
SO_PEERCRED setting
long sk_rcvtimeo
SO_RCVTIMEO setting
ktime_t sk_stamptime stamp of last packet received
u16 sk_tsflagsSO_TIMESTAMPING socket options
u8 sk_shutdown
mask of SEND_SHUTDOWN and/or RCV_SHUTDOWN
u32 sk_tskeycounter to disambiguate concurrent tstamp requests
struct socket * sk_socketIdentd and reporting IO signals
void * sk_user_dataRPC layer private data
void * sk_securityused by security modules
struct sock_cgroup_data sk_cgrp_datacgroup data for this cgroup
struct mem_cgroup * sk_memcgthis socket's memory cgroup association
void (*)(struct sock *sk) sk_state_changecallback to indicate change in the state of the sock
void (*)(struct sock *sk) sk_data_readycallback to indicate there is data to be processed
void (*)(struct sock *sk) sk_write_spacecallback to indicate there is bf sending space available
void (*)(struct sock *sk) sk_error_report
callback to indicate errors (e.g. MSG_ERRQUEUE)
int (*)(struct sock *sk,struct sk_buff *skb) sk_backlog_rcvcallback to process the backlog
void (*)(struct sock *sk) sk_destructcalled at sock freeing time, i.e. when all refcnt == 0
struct sock_reuseport __rcu * sk_reuseport_cbreuseport group container
struct rcu_head sk_rcuused during RCU grace period