fs/smb/server/transport_tcp.c
Source file repositories/reference/linux-study-clean/fs/smb/server/transport_tcp.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/server/transport_tcp.c- Extension
.c- Size
- 16540 bytes
- Lines
- 685
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/freezer.hsmb_common.hserver.hauth.hconnection.htransport_tcp.h
Detected Declarations
struct interfacestruct tcp_transportfunction ksmbd_tcp_nodelayfunction ksmbd_tcp_reuseaddrfunction ksmbd_tcp_free_transportfunction free_transportfunction kvec_array_initfunction get_conn_iovecfunction ksmbd_tcp_new_connectionfunction ksmbd_kthread_fnfunction hash_for_each_possiblefunction ksmbd_tcp_run_kthreadfunction ksmbd_tcp_readvfunction ksmbd_tcp_readfunction ksmbd_tcp_writevfunction ksmbd_tcp_disconnectfunction tcp_destroy_socketfunction create_socketfunction ksmbd_netdev_eventfunction ksmbd_tcp_initfunction tcp_stop_kthreadfunction ksmbd_tcp_destroyfunction list_for_each_entry_safefunction ksmbd_tcp_set_interfaces
Annotated Snippet
struct interface {
struct task_struct *ksmbd_kthread;
struct socket *ksmbd_socket;
struct list_head entry;
char *name;
int state;
};
static LIST_HEAD(iface_list);
static int bind_additional_ifaces;
struct tcp_transport {
struct ksmbd_transport transport;
struct socket *sock;
struct kvec *iov;
unsigned int nr_iov;
};
static const struct ksmbd_transport_ops ksmbd_tcp_transport_ops;
static void tcp_stop_kthread(struct task_struct *kthread);
static struct interface *alloc_iface(char *ifname);
static void ksmbd_tcp_disconnect(struct ksmbd_transport *t);
#define KSMBD_TRANS(t) (&(t)->transport)
#define TCP_TRANS(t) ((struct tcp_transport *)container_of(t, \
struct tcp_transport, transport))
static inline void ksmbd_tcp_nodelay(struct socket *sock)
{
tcp_sock_set_nodelay(sock->sk);
}
static inline void ksmbd_tcp_reuseaddr(struct socket *sock)
{
sock_set_reuseaddr(sock->sk);
}
static struct tcp_transport *alloc_transport(struct socket *client_sk)
{
struct tcp_transport *t;
struct ksmbd_conn *conn;
t = kzalloc_obj(*t, KSMBD_DEFAULT_GFP);
if (!t)
return NULL;
t->sock = client_sk;
conn = ksmbd_conn_alloc();
if (!conn) {
kfree(t);
return NULL;
}
#if IS_ENABLED(CONFIG_IPV6)
if (client_sk->sk->sk_family == AF_INET6) {
memcpy(&conn->inet6_addr, &client_sk->sk->sk_v6_daddr, 16);
conn->inet_hash = ipv6_addr_hash(&client_sk->sk->sk_v6_daddr);
} else {
conn->inet_addr = inet_sk(client_sk->sk)->inet_daddr;
conn->inet_hash = ipv4_addr_hash(inet_sk(client_sk->sk)->inet_daddr);
}
#else
conn->inet_addr = inet_sk(client_sk->sk)->inet_daddr;
conn->inet_hash = ipv4_addr_hash(inet_sk(client_sk->sk)->inet_daddr);
#endif
down_write(&conn_list_lock);
hash_add(conn_list, &conn->hlist, conn->inet_hash);
up_write(&conn_list_lock);
conn->transport = KSMBD_TRANS(t);
KSMBD_TRANS(t)->conn = conn;
KSMBD_TRANS(t)->ops = &ksmbd_tcp_transport_ops;
return t;
}
static void ksmbd_tcp_free_transport(struct ksmbd_transport *kt)
{
struct tcp_transport *t = TCP_TRANS(kt);
sock_release(t->sock);
kfree(t->iov);
kfree(t);
}
static void free_transport(struct tcp_transport *t)
{
kernel_sock_shutdown(t->sock, SHUT_RDWR);
ksmbd_conn_free(KSMBD_TRANS(t)->conn);
Annotation
- Immediate include surface: `linux/freezer.h`, `smb_common.h`, `server.h`, `auth.h`, `connection.h`, `transport_tcp.h`.
- Detected declarations: `struct interface`, `struct tcp_transport`, `function ksmbd_tcp_nodelay`, `function ksmbd_tcp_reuseaddr`, `function ksmbd_tcp_free_transport`, `function free_transport`, `function kvec_array_init`, `function get_conn_iovec`, `function ksmbd_tcp_new_connection`, `function ksmbd_kthread_fn`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.