include/net/udp.h
Source file repositories/reference/linux-study-clean/include/net/udp.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/udp.h- Extension
.h- Size
- 18561 bytes
- Lines
- 657
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hlinux/bug.hnet/inet_sock.hnet/gso.hnet/sock.hnet/snmp.hnet/ip.hlinux/ipv6.hlinux/seq_file.hlinux/poll.hlinux/indirect_call_wrapper.hlinux/math.h
Detected Declarations
struct udp_skb_cbstruct udp_hslotstruct udp_hslot_mainstruct udp_tablestruct sk_buffstruct udp_dev_scratchstruct udp_seq_afinfostruct udp_iter_statestruct sk_psockfunction udp_hashslot2function udp_table_hash4_initfunction udp_hashed4function udp_hash4_slot_sizefunction udp_has_hash4function udp_hash4_incfunction udp_hashed4function udp_hash4_slot_sizefunction udp_has_hash4function udp_hash4_incfunction udp_hash4_decfunction __udp_lib_checksum_completefunction udp_lib_checksum_completefunction udp_csum_outgoingfunction udp_csumfunction udp_v4_checkfunction udp_csum_pull_headerfunction udp_lib_init_sockfunction udp_drops_incfunction udp_lib_hashfunction udp_lib_closefunction udp_lib_hash4function udp_flow_src_portfunction udp_rqueue_getfunction udp_sk_bound_dev_eqfunction udp_skb_lenfunction udp_skb_csum_unnecessaryfunction udp_skb_is_linearfunction udp_skb_lenfunction udp_skb_csum_unnecessaryfunction udp_skb_is_linearfunction copy_linear_skbfunction offloadfunction udp_post_segment_fix_csum
Annotated Snippet
struct udp_skb_cb {
union {
struct inet_skb_parm h4;
#if IS_ENABLED(CONFIG_IPV6)
struct inet6_skb_parm h6;
#endif
} header;
};
#define UDP_SKB_CB(__skb) ((struct udp_skb_cb *)((__skb)->cb))
/**
* struct udp_hslot - UDP hash slot used by udp_table.hash/hash4
*
* @head: head of list of sockets
* @nulls_head: head of list of sockets, only used by hash4
* @count: number of sockets in 'head' list
* @lock: spinlock protecting changes to head/count
*/
struct udp_hslot {
union {
struct hlist_head head;
/* hash4 uses hlist_nulls to avoid moving wrongly onto another
* hlist, because rehash() can happen with lookup().
*/
struct hlist_nulls_head nulls_head;
};
int count;
spinlock_t lock;
} __aligned(2 * sizeof(long));
/**
* struct udp_hslot_main - UDP hash slot used by udp_table.hash2
*
* @hslot: basic hash slot
* @hash4_cnt: number of sockets in hslot4 of the same
* (local port, local address)
*/
struct udp_hslot_main {
struct udp_hslot hslot; /* must be the first member */
#if !IS_ENABLED(CONFIG_BASE_SMALL)
u32 hash4_cnt;
#endif
} __aligned(2 * sizeof(long));
#define UDP_HSLOT_MAIN(__hslot) ((struct udp_hslot_main *)(__hslot))
/**
* struct udp_table - UDP table
*
* @hash: hash table, sockets are hashed on (local port)
* @hash2: hash table, sockets are hashed on (local port, local address)
* @hash4: hash table, connected sockets are hashed on
* (local port, local address, remote port, remote address)
* @mask: number of slots in hash tables, minus 1
* @log: log2(number of slots in hash table)
*/
struct udp_table {
struct udp_hslot *hash;
struct udp_hslot_main *hash2;
#if !IS_ENABLED(CONFIG_BASE_SMALL)
struct udp_hslot *hash4;
#endif
unsigned int mask;
unsigned int log;
};
extern struct udp_table udp_table;
static inline struct udp_hslot *udp_hashslot(struct udp_table *table,
const struct net *net,
unsigned int num)
{
return &table->hash[udp_hashfn(net, num, table->mask)];
}
/*
* For secondary hash, net_hash_mix() is performed before calling
* udp_hashslot2(), this explains difference with udp_hashslot()
*/
static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
unsigned int hash)
{
return &table->hash2[hash & table->mask].hslot;
}
#if IS_ENABLED(CONFIG_BASE_SMALL)
static inline void udp_table_hash4_init(struct udp_table *table)
{
}
static inline struct udp_hslot *udp_hashslot4(struct udp_table *table,
unsigned int hash)
Annotation
- Immediate include surface: `linux/list.h`, `linux/bug.h`, `net/inet_sock.h`, `net/gso.h`, `net/sock.h`, `net/snmp.h`, `net/ip.h`, `linux/ipv6.h`.
- Detected declarations: `struct udp_skb_cb`, `struct udp_hslot`, `struct udp_hslot_main`, `struct udp_table`, `struct sk_buff`, `struct udp_dev_scratch`, `struct udp_seq_afinfo`, `struct udp_iter_state`, `struct sk_psock`, `function udp_hashslot2`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.