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_family __sk_common.skc_family #define sk_state __sk_common.skc_state #define sk_reuse __sk_common.skc_reuse #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 socket_lock_t sk_lock; struct sk_buff_head sk_receive_queue; struct sk_backlog; #define sk_rmem_alloc sk_backlog.rmem_alloc int sk_forward_alloc; #ifdef CONFIG_RPS __u32 sk_rxhash; #endif atomic_t sk_drops; int sk_rcvbuf; struct sk_filter __rcu * sk_filter; struct socket_wq __rcu * sk_wq; #ifdef CONFIG_NET_DMA struct sk_buff_head sk_async_wait_queue; #endif #ifdef CONFIG_XFRM struct xfrm_policy * sk_policy[2]; #endif unsigned long sk_flags; struct dst_entry * sk_dst_cache; spinlock_t sk_dst_lock; atomic_t sk_wmem_alloc; atomic_t sk_omem_alloc; int sk_sndbuf; struct sk_buff_head sk_write_queue; unsigned int sk_shutdown:2; unsigned int sk_no_check:2; unsigned int sk_userlocks:4; unsigned int sk_protocol:8; unsigned int sk_type:16; int sk_wmem_queued; gfp_t sk_allocation; int sk_route_caps; int sk_route_nocaps; int sk_gso_type; unsigned int sk_gso_max_size; 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; unsigned short sk_ack_backlog; unsigned short sk_max_ack_backlog; __u32 sk_priority; struct pid * sk_peer_pid; const struct cred * sk_peer_cred; long sk_rcvtimeo; long sk_sndtimeo; void * sk_protinfo; struct timer_list sk_timer; ktime_t sk_stamp; struct socket * sk_socket; void * sk_user_data; struct page * sk_sndmsg_page; struct sk_buff * sk_send_head; __u32 sk_sndmsg_off; int sk_write_pending; #ifdef CONFIG_SECURITY void * sk_security; #endif __u32 sk_mark; u32 sk_classid; void (* sk_state_change) (struct sock *sk); void (* sk_data_ready) (struct sock *sk, int bytes); 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); #ifdef CONFIG_TNK #endif };
shared layout with inet_timewait_sock
synchronizer
incoming packets
always used with the per-socket spinlock held
space allocated forward
flow hash received from netif layer
raw/udp drops counter
size of receive buffer in bytes
socket filtering instructions
sock wait queue and async head
DMA copied packets
flow policy
SO_LINGER
(l_onoff), SO_BROADCAST
, SO_KEEPALIVE
,
SO_OOBINLINE
settings, SO_TIMESTAMPING
settings
destination cache
destination cache lock
transmit queue bytes committed
"o“ is ”option“ or ”other"
size of send buffer in bytes
Packet sending queue
mask of SEND_SHUTDOWN
and/or RCV_SHUTDOWN
SO_NO_CHECK
setting, wether or not checkup packets
SO_SNDBUF
and SO_RCVBUF
settings
which protocol this socket belongs in this network family
socket type (SOCK_STREAM
, etc)
persistent queue size
allocation mode
route capabilities (e.g. NETIF_F_TSO
)
forbidden route capabilities (e.g NETIF_F_GSO_MASK)
GSO type (e.g. SKB_GSO_TCPV4
)
Maximum GSO segment size to build
SO_RCVLOWAT
setting
SO_LINGER
l_linger setting
rarely used
sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
used with the callbacks in the end of this struct
last error
errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
current listen backlog
listen backlog set in listen
SO_PRIORITY
setting
struct pid for this socket's peer
SO_PEERCRED
setting
SO_RCVTIMEO
setting
SO_SNDTIMEO
setting
private area, net family specific, when not using slab
sock cleanup timer
time stamp of last packet received
Identd and reporting IO signals
RPC layer private data
cached page for sendmsg
front of stuff to transmit
cached offset for sendmsg
a write to stream socket waits to start
used by security modules
generic packet mark
this socket's cgroup classid
callback to indicate change in the state of the sock
callback to indicate there is data to be processed
callback to indicate there is bf sending space available
callback to indicate errors (e.g. MSG_ERRQUEUE
)
callback to process the backlog
called at sock freeing time, i.e. when all refcnt == 0