net/smc/smc_hs_bpf.c
Source file repositories/reference/linux-study-clean/net/smc/smc_hs_bpf.c
File Facts
- System
- Linux kernel
- Corpus path
net/smc/smc_hs_bpf.c- Extension
.c- Size
- 3397 bytes
- Lines
- 141
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf_verifier.hlinux/bpf.hlinux/btf.hlinux/rculist.hsmc_hs_bpf.h
Detected Declarations
function smc_hs_ctrl_regfunction smc_hs_ctrl_unregfunction list_for_each_entry_rcufunction __smc_bpf_stub_set_tcp_optionfunction __smc_bpf_stub_set_tcp_option_condfunction smc_bpf_hs_ctrl_initfunction smc_bpf_hs_ctrl_regfunction smc_bpf_hs_ctrl_unregfunction smc_bpf_hs_ctrl_init_memberfunction bpf_smc_hs_func_protofunction bpf_smc_hs_ctrl_init
Annotated Snippet
static int __smc_bpf_stub_set_tcp_option(struct tcp_sock *tp) { return 1; }
static int __smc_bpf_stub_set_tcp_option_cond(const struct tcp_sock *tp,
struct inet_request_sock *ireq)
{
return 1;
}
static struct smc_hs_ctrl __smc_bpf_hs_ctrl = {
.syn_option = __smc_bpf_stub_set_tcp_option,
.synack_option = __smc_bpf_stub_set_tcp_option_cond,
};
static int smc_bpf_hs_ctrl_init(struct btf *btf) { return 0; }
static int smc_bpf_hs_ctrl_reg(void *kdata, struct bpf_link *link)
{
if (link)
return -EOPNOTSUPP;
return smc_hs_ctrl_reg(kdata);
}
static void smc_bpf_hs_ctrl_unreg(void *kdata, struct bpf_link *link)
{
smc_hs_ctrl_unreg(kdata);
}
static int smc_bpf_hs_ctrl_init_member(const struct btf_type *t,
const struct btf_member *member,
void *kdata, const void *udata)
{
const struct smc_hs_ctrl *u_ctrl;
struct smc_hs_ctrl *k_ctrl;
u32 moff;
u_ctrl = (const struct smc_hs_ctrl *)udata;
k_ctrl = (struct smc_hs_ctrl *)kdata;
moff = __btf_member_bit_offset(t, member) / 8;
switch (moff) {
case offsetof(struct smc_hs_ctrl, name):
if (bpf_obj_name_cpy(k_ctrl->name, u_ctrl->name,
sizeof(u_ctrl->name)) <= 0)
return -EINVAL;
return 1;
case offsetof(struct smc_hs_ctrl, flags):
if (u_ctrl->flags & ~SMC_HS_CTRL_ALL_FLAGS)
return -EINVAL;
k_ctrl->flags = u_ctrl->flags;
return 1;
default:
break;
}
return 0;
}
static const struct bpf_func_proto *
bpf_smc_hs_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
{
return bpf_base_func_proto(func_id, prog);
}
static const struct bpf_verifier_ops smc_bpf_verifier_ops = {
.get_func_proto = bpf_smc_hs_func_proto,
.is_valid_access = bpf_tracing_btf_ctx_access,
};
static struct bpf_struct_ops bpf_smc_hs_ctrl_ops = {
.name = "smc_hs_ctrl",
.init = smc_bpf_hs_ctrl_init,
.reg = smc_bpf_hs_ctrl_reg,
.unreg = smc_bpf_hs_ctrl_unreg,
.cfi_stubs = &__smc_bpf_hs_ctrl,
.verifier_ops = &smc_bpf_verifier_ops,
.init_member = smc_bpf_hs_ctrl_init_member,
.owner = THIS_MODULE,
};
int bpf_smc_hs_ctrl_init(void)
{
return register_bpf_struct_ops(&bpf_smc_hs_ctrl_ops, smc_hs_ctrl);
}
Annotation
- Immediate include surface: `linux/bpf_verifier.h`, `linux/bpf.h`, `linux/btf.h`, `linux/rculist.h`, `smc_hs_bpf.h`.
- Detected declarations: `function smc_hs_ctrl_reg`, `function smc_hs_ctrl_unreg`, `function list_for_each_entry_rcu`, `function __smc_bpf_stub_set_tcp_option`, `function __smc_bpf_stub_set_tcp_option_cond`, `function smc_bpf_hs_ctrl_init`, `function smc_bpf_hs_ctrl_reg`, `function smc_bpf_hs_ctrl_unreg`, `function smc_bpf_hs_ctrl_init_member`, `function bpf_smc_hs_func_proto`.
- 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.
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.