Documentation/networking/kcm.rst
Source file repositories/reference/linux-study-clean/Documentation/networking/kcm.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/networking/kcm.rst- Extension
.rst- Size
- 10917 bytes
- Lines
- 291
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
bpf.hbpf_helpers.h
Detected Declarations
struct kcm_clonestruct kcm_attachstruct kcm_unattachfunction setsockopt
Annotated Snippet
struct kcm_clone {
int fd;
};
struct kcm_clone info;
memset(&info, 0, sizeof(info));
err = ioctl(kcmfd, SIOCKCMCLONE, &info);
if (!err)
newkcmfd = info.fd;
Attach transport sockets
------------------------
Attaching of transport sockets to a multiplexor is performed by calling an
ioctl on a KCM socket for the multiplexor. e.g.::
/* From linux/kcm.h */
struct kcm_attach {
int fd;
int bpf_fd;
};
struct kcm_attach info;
memset(&info, 0, sizeof(info));
info.fd = tcpfd;
info.bpf_fd = bpf_prog_fd;
ioctl(kcmfd, SIOCKCMATTACH, &info);
The kcm_attach structure contains:
- fd: file descriptor for TCP socket being attached
- bpf_prog_fd: file descriptor for compiled BPF program downloaded
Unattach transport sockets
--------------------------
Unattaching a transport socket from a multiplexor is straightforward. An
"unattach" ioctl is done with the kcm_unattach structure as the argument::
/* From linux/kcm.h */
struct kcm_unattach {
int fd;
};
struct kcm_unattach info;
memset(&info, 0, sizeof(info));
info.fd = cfd;
ioctl(fd, SIOCKCMUNATTACH, &info);
Disabling receive on KCM socket
-------------------------------
A setsockopt is used to disable or enable receiving on a KCM socket.
When receive is disabled, any pending messages in the socket's
receive buffer are moved to other sockets. This feature is useful
if an application thread knows that it will be doing a lot of
work on a request and won't be able to service new messages for a
while. Example use::
int val = 1;
Annotation
- Immediate include surface: `bpf.h`, `bpf_helpers.h`.
- Detected declarations: `struct kcm_clone`, `struct kcm_attach`, `struct kcm_unattach`, `function setsockopt`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
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.