tools/testing/selftests/bpf/progs/mptcp_subflow.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/mptcp_subflow.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/mptcp_subflow.c- Extension
.c- Size
- 3014 bytes
- Lines
- 129
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
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_tracing_net.hmptcp_bpf.h
Detected Declarations
function mptcp_subflowfunction _check_getsockopt_subflow_markfunction mptcp_for_each_subflowfunction _check_getsockopt_subflow_ccfunction mptcp_for_each_subflowfunction _getsockopt_subflow
Annotated Snippet
if (ssk->sk_mark != ++i) {
ctx->retval = -2;
break;
}
}
return 1;
}
static int _check_getsockopt_subflow_cc(struct mptcp_sock *msk, struct bpf_sockopt *ctx)
{
struct mptcp_subflow_context *subflow;
mptcp_for_each_subflow(msk, subflow) {
struct inet_connection_sock *icsk;
struct sock *ssk;
ssk = mptcp_subflow_tcp_sock(bpf_core_cast(subflow,
struct mptcp_subflow_context));
icsk = bpf_core_cast(ssk, struct inet_connection_sock);
if (ssk->sk_mark == 2 &&
__builtin_memcmp(icsk->icsk_ca_ops->name, cc, TCP_CA_NAME_MAX)) {
ctx->retval = -2;
break;
}
}
return 1;
}
SEC("cgroup/getsockopt")
int _getsockopt_subflow(struct bpf_sockopt *ctx)
{
struct bpf_sock *sk = ctx->sk;
struct mptcp_sock *msk;
if (bpf_get_current_pid_tgid() >> 32 != pid)
return 1;
if (!sk || sk->protocol != IPPROTO_MPTCP ||
(!(ctx->level == SOL_SOCKET && ctx->optname == SO_MARK) &&
!(ctx->level == SOL_TCP && ctx->optname == TCP_CONGESTION)))
return 1;
msk = bpf_core_cast(sk, struct mptcp_sock);
if (msk->pm.extra_subflows != 1) {
ctx->retval = -1;
return 1;
}
if (ctx->optname == SO_MARK)
return _check_getsockopt_subflow_mark(msk, ctx);
return _check_getsockopt_subflow_cc(msk, ctx);
}
Annotation
- Immediate include surface: `bpf_tracing_net.h`, `mptcp_bpf.h`.
- Detected declarations: `function mptcp_subflow`, `function _check_getsockopt_subflow_mark`, `function mptcp_for_each_subflow`, `function _check_getsockopt_subflow_cc`, `function mptcp_for_each_subflow`, `function _getsockopt_subflow`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.