net/tipc/socket.c
Source file repositories/reference/linux-study-clean/net/tipc/socket.c
File Facts
- System
- Linux kernel
- Corpus path
net/tipc/socket.c- Extension
.c- Size
- 107047 bytes
- Lines
- 4015
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/rhashtable.hlinux/sched/signal.hlinux/uio.htrace/events/sock.hcore.hname_table.hnode.hlink.hname_distr.hsocket.hbcast.hnetlink.hgroup.htrace.h
Detected Declarations
struct sockaddr_pairstruct tipc_sockfunction tsk_own_nodefunction tsk_peer_nodefunction tsk_peer_portfunction tsk_unreliablefunction tsk_set_unreliablefunction tsk_unreturnablefunction tsk_set_unreturnablefunction tsk_importancefunction tsk_set_importancefunction tsk_conn_congfunction tsk_blocksfunction tsk_adv_blocksfunction tsk_incfunction tsk_set_naglefunction tsk_advance_rx_queuefunction tipc_sk_respondfunction tsk_rej_rx_queuefunction tipc_sk_connectedfunction tipc_sk_type_connectionlessfunction tsk_peer_msgfunction tipc_set_sk_statefunction tipc_sk_sock_errfunction tipc_sk_createfunction tipc_sk_callbackfunction __tipc_shutdownfunction tipc_releasefunction __tipc_bindfunction tipc_sk_bindfunction tipc_bindfunction unchangingfunction tipc_pollfunction tipc_sendmsgfunction tipc_send_group_msgfunction tipc_sendmsgfunction tipc_sendmsgfunction tipc_sendmsgfunction tipc_sendmsgfunction tipc_sk_mcast_rcvfunction tipc_sk_push_backlogfunction tipc_sk_conn_proto_rcvfunction tipc_sendmsgfunction __tipc_sendmsgfunction tipc_sendstreamfunction __tipc_sendstreamfunction tipc_send_packetfunction tipc_sk_finish_conn
Annotated Snippet
static const struct proto_ops packet_ops;
static const struct proto_ops stream_ops;
static const struct proto_ops msg_ops;
static struct proto tipc_proto;
static const struct rhashtable_params tsk_rht_params;
static u32 tsk_own_node(struct tipc_sock *tsk)
{
return msg_prevnode(&tsk->phdr);
}
static u32 tsk_peer_node(struct tipc_sock *tsk)
{
return msg_destnode(&tsk->phdr);
}
static u32 tsk_peer_port(struct tipc_sock *tsk)
{
return msg_destport(&tsk->phdr);
}
static bool tsk_unreliable(struct tipc_sock *tsk)
{
return msg_src_droppable(&tsk->phdr) != 0;
}
static void tsk_set_unreliable(struct tipc_sock *tsk, bool unreliable)
{
msg_set_src_droppable(&tsk->phdr, unreliable ? 1 : 0);
}
static bool tsk_unreturnable(struct tipc_sock *tsk)
{
return msg_dest_droppable(&tsk->phdr) != 0;
}
static void tsk_set_unreturnable(struct tipc_sock *tsk, bool unreturnable)
{
msg_set_dest_droppable(&tsk->phdr, unreturnable ? 1 : 0);
}
static int tsk_importance(struct tipc_sock *tsk)
{
return msg_importance(&tsk->phdr);
}
static struct tipc_sock *tipc_sk(const struct sock *sk)
{
return container_of(sk, struct tipc_sock, sk);
}
int tsk_set_importance(struct sock *sk, int imp)
{
if (imp > TIPC_CRITICAL_IMPORTANCE)
return -EINVAL;
msg_set_importance(&tipc_sk(sk)->phdr, (u32)imp);
return 0;
}
static bool tsk_conn_cong(struct tipc_sock *tsk)
{
return tsk->snt_unacked > tsk->snd_win;
}
static u16 tsk_blocks(int len)
{
return ((len / FLOWCTL_BLK_SZ) + 1);
}
/* tsk_blocks(): translate a buffer size in bytes to number of
* advertisable blocks, taking into account the ratio truesize(len)/len
* We can trust that this ratio is always < 4 for len >= FLOWCTL_BLK_SZ
*/
static u16 tsk_adv_blocks(int len)
{
return len / FLOWCTL_BLK_SZ / 4;
}
/* tsk_inc(): increment counter for sent or received data
* - If block based flow control is not supported by peer we
* fall back to message based ditto, incrementing the counter
*/
static u16 tsk_inc(struct tipc_sock *tsk, int msglen)
{
if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL))
return ((msglen / FLOWCTL_BLK_SZ) + 1);
return 1;
}
/* tsk_set_nagle - enable/disable nagle property by manipulating maxnagle
Annotation
- Immediate include surface: `linux/rhashtable.h`, `linux/sched/signal.h`, `linux/uio.h`, `trace/events/sock.h`, `core.h`, `name_table.h`, `node.h`, `link.h`.
- Detected declarations: `struct sockaddr_pair`, `struct tipc_sock`, `function tsk_own_node`, `function tsk_peer_node`, `function tsk_peer_port`, `function tsk_unreliable`, `function tsk_set_unreliable`, `function tsk_unreturnable`, `function tsk_set_unreturnable`, `function tsk_importance`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.