net/sunrpc/svcsock.c
Source file repositories/reference/linux-study-clean/net/sunrpc/svcsock.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/svcsock.c- Extension
.c- Size
- 44379 bytes
- Lines
- 1698
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/sched.hlinux/module.hlinux/errno.hlinux/fcntl.hlinux/net.hlinux/in.hlinux/inet.hlinux/udp.hlinux/tcp.hlinux/unistd.hlinux/slab.hlinux/netdevice.hlinux/skbuff.hlinux/file.hlinux/freezer.hlinux/bvec.hnet/sock.hnet/checksum.hnet/ip.hnet/ipv6.hnet/udp.hnet/tcp.hnet/tcp_states.hnet/tls_prot.hnet/handshake.hlinux/uaccess.hlinux/highmem.hasm/ioctls.hlinux/key.hlinux/sunrpc/types.hlinux/sunrpc/clnt.h
Detected Declarations
function svc_reclassify_socketfunction svc_reclassify_socketfunction svc_set_cmsg_datafunction svc_sock_result_payloadfunction svc_one_sock_namefunction svc_tcp_sock_process_cmsgfunction svc_tcp_sock_recv_cmsgfunction tls_get_record_typefunction svc_tcp_sock_recvmsgfunction svc_flush_bvecfunction svc_flush_bvecfunction svc_sock_setbufsizefunction svc_sock_secure_portfunction svc_data_readyfunction svc_write_spacefunction svc_tcp_has_wspacefunction svc_tcp_kill_temp_xprtfunction svc_tcp_handshake_donefunction svc_tcp_handshakefunction svc_udp_get_dest_address4function svc_udp_get_dest_address6function svc_udp_get_dest_addressfunction svc_udp_recvfromfunction svc_udp_sendtofunction svc_udp_has_wspacefunction svc_udp_kill_temp_xprtfunction svc_udp_initfunction svc_tcp_listen_data_readyfunction svc_tcp_state_changefunction svc_tcp_restore_pagesfunction svc_tcp_save_pagesfunction svc_tcp_clear_pagesfunction svc_tcp_read_markerfunction receive_cb_replyfunction svc_tcp_fragment_receivedfunction svc_tcp_recvfromfunction svc_tcp_sendmsgfunction svc_tcp_sendtofunction svc_init_xprt_sockfunction svc_cleanup_xprt_sockfunction svc_tcp_initfunction svc_sock_update_bufsfunction svc_sock_sendpagesfunction svc_addsockfunction svc_sock_detachfunction svc_tcp_sock_detachfunction svc_sock_freeexport svc_addsock
Annotated Snippet
tls_get_record_type(sock->sk, &u.cmsg) == TLS_RECORD_TYPE_ALERT) {
iov_iter_revert(&msg.msg_iter, ret);
ret = svc_tcp_sock_process_cmsg(sock, &msg, &u.cmsg, -EAGAIN);
}
return ret;
}
static int
svc_tcp_sock_recvmsg(struct svc_sock *svsk, struct msghdr *msg)
{
int ret;
struct socket *sock = svsk->sk_sock;
ret = sock_recvmsg(sock, msg, MSG_DONTWAIT);
if (msg->msg_flags & MSG_CTRUNC) {
msg->msg_flags &= ~(MSG_CTRUNC | MSG_EOR);
if (ret == 0 || ret == -EIO)
ret = svc_tcp_sock_recv_cmsg(sock, &msg->msg_flags);
}
return ret;
}
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static void svc_flush_bvec(const struct bio_vec *bvec, size_t size, size_t seek)
{
struct bvec_iter bi = {
.bi_size = size + seek,
};
struct bio_vec bv;
bvec_iter_advance(bvec, &bi, seek & PAGE_MASK);
for_each_bvec(bv, bvec, bi, bi)
flush_dcache_page(bv.bv_page);
}
#else
static inline void svc_flush_bvec(const struct bio_vec *bvec, size_t size,
size_t seek)
{
}
#endif
/*
* Read from @rqstp's transport socket. The incoming message fills whole
* pages in @rqstp's rq_pages array until the last page of the message
* has been received into a partial page.
*/
static ssize_t svc_tcp_read_msg(struct svc_rqst *rqstp, size_t buflen,
size_t seek)
{
struct svc_sock *svsk =
container_of(rqstp->rq_xprt, struct svc_sock, sk_xprt);
struct bio_vec *bvec = rqstp->rq_bvec;
struct msghdr msg = { NULL };
unsigned int i;
ssize_t len;
size_t t;
clear_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
for (i = 0, t = 0; t < buflen; i++, t += PAGE_SIZE)
bvec_set_page(&bvec[i], rqstp->rq_pages[i], PAGE_SIZE, 0);
iov_iter_bvec(&msg.msg_iter, ITER_DEST, bvec, i, buflen);
if (seek) {
iov_iter_advance(&msg.msg_iter, seek);
buflen -= seek;
}
len = svc_tcp_sock_recvmsg(svsk, &msg);
if (len > 0)
svc_flush_bvec(bvec, len, seek);
/* If we read a full record, then assume there may be more
* data to read (stream based sockets only!)
*/
if (len == buflen)
set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
return len;
}
/*
* Set socket snd and rcv buffer lengths
*/
static void svc_sock_setbufsize(struct svc_sock *svsk, unsigned int nreqs)
{
unsigned int max_mesg = svsk->sk_xprt.xpt_server->sv_max_mesg;
struct socket *sock = svsk->sk_sock;
nreqs = min(nreqs, INT_MAX / 2 / max_mesg);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/sched.h`, `linux/module.h`, `linux/errno.h`, `linux/fcntl.h`, `linux/net.h`, `linux/in.h`, `linux/inet.h`.
- Detected declarations: `function svc_reclassify_socket`, `function svc_reclassify_socket`, `function svc_set_cmsg_data`, `function svc_sock_result_payload`, `function svc_one_sock_name`, `function svc_tcp_sock_process_cmsg`, `function svc_tcp_sock_recv_cmsg`, `function tls_get_record_type`, `function svc_tcp_sock_recvmsg`, `function svc_flush_bvec`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.