net/tipc/topsrv.c
Source file repositories/reference/linux-study-clean/net/tipc/topsrv.c
File Facts
- System
- Linux kernel
- Corpus path
net/tipc/topsrv.c- Extension
.c- Size
- 18988 bytes
- Lines
- 734
- 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
subscr.htopsrv.hcore.hsocket.haddr.hmsg.hbearer.hnet/sock.hlinux/module.htrace/events/sock.h
Detected Declarations
struct tipc_topsrvstruct tipc_connstruct outqueue_entryfunction connectedfunction tipc_conn_kref_releasefunction conn_putfunction conn_getfunction tipc_conn_closefunction tipc_conn_delete_subfunction tipc_conn_send_to_sockfunction tipc_conn_send_workfunction tipc_conn_send_workfunction tipc_send_workfunction tipc_conn_rcv_subfunction tipc_conn_rcv_from_sockfunction tipc_conn_recv_workfunction tipc_recv_workfunction tipc_topsrv_acceptfunction tipc_topsrv_acceptfunction tipc_topsrv_create_listenerfunction tipc_topsrv_kern_subscrfunction tipc_topsrv_kern_unsubscrfunction tipc_topsrv_kern_evtfunction tipc_topsrv_work_startfunction tipc_topsrv_work_stopfunction tipc_topsrv_startfunction tipc_topsrv_stopfunction tipc_topsrv_init_netfunction tipc_topsrv_exit_net
Annotated Snippet
struct tipc_topsrv {
struct idr conn_idr;
spinlock_t idr_lock; /* for idr list */
int idr_in_use;
struct net *net;
struct work_struct awork;
struct workqueue_struct *rcv_wq;
struct workqueue_struct *send_wq;
struct socket *listener;
char name[TIPC_SERVER_NAME_LEN];
};
/**
* struct tipc_conn - TIPC connection structure
* @kref: reference counter to connection object
* @conid: connection identifier
* @sock: socket handler associated with connection
* @flags: indicates connection state
* @server: pointer to connected server
* @sub_list: list to all pertaining subscriptions
* @sub_lock: lock protecting the subscription list
* @rwork: receive work item
* @outqueue: pointer to first outbound message in queue
* @outqueue_lock: control access to the outqueue
* @swork: send work item
*/
struct tipc_conn {
struct kref kref;
int conid;
struct socket *sock;
unsigned long flags;
struct tipc_topsrv *server;
struct list_head sub_list;
spinlock_t sub_lock; /* for subscription list */
struct work_struct rwork;
struct list_head outqueue;
spinlock_t outqueue_lock; /* for outqueue */
struct work_struct swork;
};
/* An entry waiting to be sent */
struct outqueue_entry {
bool inactive;
struct tipc_event evt;
struct list_head list;
};
static void tipc_conn_recv_work(struct work_struct *work);
static void tipc_conn_send_work(struct work_struct *work);
static void tipc_topsrv_kern_evt(struct net *net, struct tipc_event *evt);
static void tipc_conn_delete_sub(struct tipc_conn *con, struct tipc_subscr *s);
static bool connected(struct tipc_conn *con)
{
return con && test_bit(CF_CONNECTED, &con->flags);
}
static void tipc_conn_kref_release(struct kref *kref)
{
struct tipc_conn *con = container_of(kref, struct tipc_conn, kref);
struct tipc_topsrv *s = con->server;
struct outqueue_entry *e, *safe;
spin_lock_bh(&s->idr_lock);
idr_remove(&s->conn_idr, con->conid);
s->idr_in_use--;
spin_unlock_bh(&s->idr_lock);
if (con->sock)
sock_release(con->sock);
spin_lock_bh(&con->outqueue_lock);
list_for_each_entry_safe(e, safe, &con->outqueue, list) {
list_del(&e->list);
kfree(e);
}
spin_unlock_bh(&con->outqueue_lock);
kfree(con);
}
static void conn_put(struct tipc_conn *con)
{
kref_put(&con->kref, tipc_conn_kref_release);
}
static void conn_get(struct tipc_conn *con)
{
kref_get(&con->kref);
}
static void tipc_conn_close(struct tipc_conn *con)
Annotation
- Immediate include surface: `subscr.h`, `topsrv.h`, `core.h`, `socket.h`, `addr.h`, `msg.h`, `bearer.h`, `net/sock.h`.
- Detected declarations: `struct tipc_topsrv`, `struct tipc_conn`, `struct outqueue_entry`, `function connected`, `function tipc_conn_kref_release`, `function conn_put`, `function conn_get`, `function tipc_conn_close`, `function tipc_conn_delete_sub`, `function tipc_conn_send_to_sock`.
- 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.