STRUCT SOCK_COMMON(9)
π NAME π
struct sock_common β the minimal network layer representation of sockets, bestie. Like, it's the kernel API manual page for it, and yes we're gonna get through all of it together π«Ά
β¨ SYNOPSIS β¨
okay so here's the whole struct, literally every line, do not touch:
struct sock_common {
union {
__addrpair skc_addrpair;
struct {
__be32 skc_daddr;
__be32 skc_rcv_saddr;
};
};
union {
unsigned int skc_hash;
__u16 skc_u16hashes[2];
};
union {
__portpair skc_portpair;
struct {
__be16 skc_dport;
__u16 skc_num;
};
};
unsigned short skc_family;
volatile unsigned char skc_state;
unsigned char skc_reuse:4;
unsigned char skc_reuseport:1;
unsigned char skc_ipv6only:1;
unsigned char skc_net_refcnt:1;
unsigned char skc_bypass_prot_mem:1;
int skc_bound_dev_if;
union {
struct hlist_node skc_bind_node;
struct hlist_node skc_portaddr_node;
};
struct proto *skc_prot;
possible_net_t skc_net;
#if IS_ENABLED(CONFIG_IPV6);
struct in6_addr skc_v6_daddr;
struct in6_addr skc_v6_rcv_saddr;
#endif;
atomic64_t skc_cookie;
union {
unsigned long skc_flags;
struct sock *skc_listener;
struct inet_timewait_death_row *skc_tw_dr;
};
union {
struct hlist_node skc_node;
struct hlist_nulls_node skc_nulls_node;
};
unsigned short skc_tx_queue_mapping;
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING;
unsigned short skc_rx_queue_mapping;
#endif;
union {
int skc_incoming_cpu;
u32 skc_rcv_wnd;
u32 skc_tw_rcv_nxt;
};
refcount_t skc_refcnt;
};
π Members π
the whole cast, one by one, no skips π
{unnamed_union}β anonymous, it's giving mysteriousskc_addrpairβ 8-byte-aligned__u64union ofskc_daddr&skc_rcv_saddr{unnamed_struct}β anonymousskc_daddrβ foreign IPv4 addrskc_rcv_saddrβ bound local IPv4 addr{unnamed_union}β anonymousskc_hashβ hash value used with various protocol lookup tablesskc_u16hashesβ twou16hash values used by UDP lookup tables{unnamed_union}β anonymousskc_portpairβ__u32union ofskc_dport&skc_num{unnamed_struct}β anonymousskc_dportβ placeholder forinet_dport/tw_dportskc_numβ placeholder forinet_num/tw_numskc_familyβ network address familyskc_stateβ connection stateskc_reuseβSO_REUSEADDRsettingskc_reuseportβSO_REUSEPORTsettingskc_ipv6onlyβ socket is IPV6 onlyskc_net_refcntβ socket is using net ref countingskc_bypass_prot_memβ bypass the per-protocol memory accounting for skbskc_bound_dev_ifβ bound device index if != 0{unnamed_union}β anonymousskc_bind_nodeβ bind hash linkage for various protocol lookup tablesskc_portaddr_nodeβ second hash linkage for UDPskc_protβ protocol handlers inside a network familyskc_netβ reference to the network namespace of this socketskc_v6_daddrβ IPV6 destination addressskc_v6_rcv_saddrβ IPV6 source addressskc_cookieβ socket's cookie value{unnamed_union}β anonymousskc_flagsβ place holder forsk_flagsSO_LINGER(l_onoff),SO_BROADCAST,SO_KEEPALIVE,SO_OOBINLINEsettings,SO_TIMESTAMPINGsettingsskc_listenerβ connection request listener socket (akarsk_listener) [union withskc_flags]skc_tw_drβ (akatw_dr) ptr tostruct inet_timewait_death_row[union withskc_flags]{unnamed_union}β anonymousskc_nodeβ main hash linkage for various protocol lookup tablesskc_nulls_nodeβ main hash linkage for TCPskc_tx_queue_mappingβ tx queue number for this connectionskc_rx_queue_mappingβ rx queue number for this connection{unnamed_union}β anonymousskc_incoming_cpuβ record/match cpu processing incoming packetsskc_rcv_wndβ (akarsk_rcv_wnd) TCP receive window size (possibly scaled) [union withskc_incoming_cpu]skc_tw_rcv_nxtβ (akatw_rcv_nxt) TCP window next expected seq number [union withskc_incoming_cpu]skc_refcntβ reference count
π DESCRIPTION π
so like, this is the minimal network layer representation of sockets β the header for struct sock and struct inet_timewait_sock, no cap. that's the whole vibe. it's the blueprint, the main character energy of the network stack π
π SEE ALSO π
the whole friend group, go say hi π«
Kernel file ./include/net/sock.h struct sock(9), sk_user_data_is_nocopy(9), __locked_read_sk_user_data_with_flags(9), __rcu_dereference_sk_user_data_with_flags(9), sk_for_each_entry_offset_rcu(9), SOCK_CONNECT_BIND(9), lock_sock_fast(9), unlock_sock_fast(9), sk_wmem_alloc_get(9), sk_rmem_alloc_get(9), sk_has_allocations(9), skwq_has_sleeper(9), sock_poll_wait(9), sk_page_frag(9), _sock_tx_timestamp(9), sk_eat_skb(9)
and that's the whole page slay π
this one lives in ./include/net, it's the October 2026 edition, and it's officially titled struct sock_common(9) β go off, king ππ¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms