net/smc/smc_sysctl.c
Source file repositories/reference/linux-study-clean/net/smc/smc_sysctl.c
File Facts
- System
- Linux kernel
- Corpus path
net/smc/smc_sysctl.c- Extension
.c- Size
- 6997 bytes
- Lines
- 267
- 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/init.hlinux/sysctl.hlinux/bpf.hnet/net_namespace.hsmc.hsmc_core.hsmc_llc.hsmc_sysctl.hsmc_hs_bpf.h
Detected Declarations
function smc_net_replace_smc_hs_ctrlfunction proc_smc_hs_ctrlfunction smc_sysctl_net_initfunction smc_sysctl_net_exit
Annotated Snippet
if (!ctrl) {
rcu_read_unlock();
return -EINVAL;
}
/* no change, just return */
if (ctrl == rcu_dereference(net->smc.hs_ctrl)) {
rcu_read_unlock();
return 0;
}
if (!bpf_try_module_get(ctrl, ctrl->owner)) {
rcu_read_unlock();
return -EBUSY;
}
}
/* xhcg old ctrl with the new one atomically */
ctrl = unrcu_pointer(xchg(&net->smc.hs_ctrl, RCU_INITIALIZER(ctrl)));
/* release old ctrl */
if (ctrl)
bpf_module_put(ctrl, ctrl->owner);
rcu_read_unlock();
return 0;
}
static int proc_smc_hs_ctrl(const struct ctl_table *ctl, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
struct net *net = container_of(ctl->data, struct net, smc.hs_ctrl);
char val[SMC_HS_CTRL_NAME_MAX];
const struct ctl_table tbl = {
.data = val,
.maxlen = SMC_HS_CTRL_NAME_MAX,
};
struct smc_hs_ctrl *ctrl;
int ret;
rcu_read_lock();
ctrl = rcu_dereference(net->smc.hs_ctrl);
if (ctrl)
memcpy(val, ctrl->name, sizeof(ctrl->name));
else
val[0] = '\0';
rcu_read_unlock();
ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
if (ret)
return ret;
if (write)
ret = smc_net_replace_smc_hs_ctrl(net, val);
return ret;
}
#endif /* CONFIG_SMC_HS_CTRL_BPF */
static struct ctl_table smc_table[] = {
{
.procname = "autocorking_size",
.data = &init_net.smc.sysctl_autocorking_size,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_douintvec,
},
{
.procname = "smcr_buf_type",
.data = &init_net.smc.sysctl_smcr_buf_type,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_douintvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO,
},
{
.procname = "smcr_testlink_time",
.data = &init_net.smc.sysctl_smcr_testlink_time,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_jiffies,
},
{
.procname = "wmem",
.data = &init_net.smc.sysctl_wmem,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &min_sndbuf,
.extra2 = &max_sndbuf,
},
{
.procname = "rmem",
.data = &init_net.smc.sysctl_rmem,
Annotation
- Immediate include surface: `linux/init.h`, `linux/sysctl.h`, `linux/bpf.h`, `net/net_namespace.h`, `smc.h`, `smc_core.h`, `smc_llc.h`, `smc_sysctl.h`.
- Detected declarations: `function smc_net_replace_smc_hs_ctrl`, `function proc_smc_hs_ctrl`, `function smc_sysctl_net_init`, `function smc_sysctl_net_exit`.
- 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.