net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
Source file repositories/reference/linux-study-clean/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c- Extension
.c- Size
- 30313 bytes
- Lines
- 1024
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/slab.hlinux/spinlock.hlinux/unaligned.hrdma/ib_verbs.hrdma/rdma_cm.hlinux/sunrpc/xdr.hlinux/sunrpc/debug.hlinux/sunrpc/rpc_rdma.hlinux/sunrpc/svc_rdma.hxprt_rdma.htrace/events/rpcrdma.h
Detected Declarations
function svc_rdma_next_recv_ctxtfunction svc_rdma_recv_ctxt_allocfunction svc_rdma_recv_ctxt_destroyfunction svc_rdma_recv_ctxts_destroyfunction orfunction svc_rdma_recv_ctxt_putfunction svc_rdma_release_ctxtfunction svc_rdma_refresh_recvsfunction svc_rdma_post_recvsfunction svc_rdma_wc_receivefunction emptyfunction svc_rdma_build_arg_xdrfunction xdr_count_read_segmentsfunction xdr_check_read_listfunction xdr_check_write_chunkfunction xdr_count_write_chunksfunction xdr_check_write_listfunction xdr_check_reply_chunkfunction svc_rdma_get_inv_rkeyfunction pcl_for_each_segmentfunction pcl_for_each_segmentfunction pcl_for_each_segmentfunction pcl_for_each_segmentfunction svc_rdma_xdr_decode_reqfunction svc_rdma_send_errorfunction svc_rdma_is_reverse_direction_replyfunction chunkfunction svc_rdma_read_complete_multiplefunction svc_rdma_read_complete_pzrcfunction svc_rdma_read_completefunction svc_rdma_recvfrom
Annotated Snippet
if (position) {
if (position & 3)
return false;
++rctxt->rc_read_pcl.cl_count;
} else {
++rctxt->rc_call_pcl.cl_count;
}
p = xdr_inline_decode(&rctxt->rc_stream, sizeof(*p));
if (!p)
return false;
}
return true;
}
/* Sanity check the Read list.
*
* Sanity checks:
* - Read list does not overflow Receive buffer.
* - Chunk size limited by largest NFS data payload.
*
* Return values:
* %true: Read list is valid. @rctxt's xdr_stream is updated
* to point to the first byte past the Read list.
* %false: Read list is corrupt. @rctxt's xdr_stream is left
* in an unknown state.
*/
static bool xdr_check_read_list(struct svc_rdma_recv_ctxt *rctxt)
{
__be32 *p;
p = xdr_inline_decode(&rctxt->rc_stream, sizeof(*p));
if (!p)
return false;
if (!xdr_count_read_segments(rctxt, p))
return false;
if (!pcl_alloc_call(rctxt, p))
return false;
return pcl_alloc_read(rctxt, p);
}
static bool xdr_check_write_chunk(struct svc_rdma_recv_ctxt *rctxt)
{
u32 segcount;
__be32 *p;
if (xdr_stream_decode_u32(&rctxt->rc_stream, &segcount))
return false;
/* Before trusting the segcount value enough to use it in
* a computation, perform a simple range check. This is an
* arbitrary but sensible limit (ie, not architectural).
*/
if (unlikely(segcount > rctxt->rc_maxpages))
return false;
p = xdr_inline_decode(&rctxt->rc_stream,
segcount * rpcrdma_segment_maxsz * sizeof(*p));
return p != NULL;
}
/**
* xdr_count_write_chunks - Count number of Write chunks in Write list
* @rctxt: Received header and decoding state
* @p: start of an un-decoded Write list
*
* Before allocating anything, ensure the ingress Write list is
* safe to use.
*
* Return values:
* %true: Write list is valid. @rctxt's xdr_stream is updated
* to point to the first byte past the Write list, and
* the number of Write chunks is in rc_write_pcl.cl_count.
* %false: Write list is corrupt. @rctxt's xdr_stream is left
* in an indeterminate state.
*/
static bool xdr_count_write_chunks(struct svc_rdma_recv_ctxt *rctxt, __be32 *p)
{
rctxt->rc_write_pcl.cl_count = 0;
while (xdr_item_is_present(p)) {
if (!xdr_check_write_chunk(rctxt))
return false;
++rctxt->rc_write_pcl.cl_count;
p = xdr_inline_decode(&rctxt->rc_stream, sizeof(*p));
if (!p)
return false;
}
return true;
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/spinlock.h`, `linux/unaligned.h`, `rdma/ib_verbs.h`, `rdma/rdma_cm.h`, `linux/sunrpc/xdr.h`, `linux/sunrpc/debug.h`, `linux/sunrpc/rpc_rdma.h`.
- Detected declarations: `function svc_rdma_next_recv_ctxt`, `function svc_rdma_recv_ctxt_alloc`, `function svc_rdma_recv_ctxt_destroy`, `function svc_rdma_recv_ctxts_destroy`, `function or`, `function svc_rdma_recv_ctxt_put`, `function svc_rdma_release_ctxt`, `function svc_rdma_refresh_recvs`, `function svc_rdma_post_recvs`, `function svc_rdma_wc_receive`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.