net/mptcp/sched.c
Source file repositories/reference/linux-study-clean/net/mptcp/sched.c
File Facts
- System
- Linux kernel
- Corpus path
net/mptcp/sched.c- Extension
.c- Size
- 4593 bytes
- Lines
- 216
- 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/kernel.hlinux/module.hlinux/list.hlinux/rculist.hlinux/spinlock.hprotocol.h
Detected Declarations
function mptcp_sched_default_get_sendfunction mptcp_sched_default_get_retransfunction list_for_each_entry_rcufunction tcp_get_available_congestion_controlfunction mptcp_validate_schedulerfunction mptcp_register_schedulerfunction mptcp_unregister_schedulerfunction mptcp_sched_initfunction mptcp_init_schedfunction mptcp_release_schedfunction mptcp_subflow_set_scheduledfunction mptcp_sched_get_sendfunction mptcp_for_each_subflowfunction mptcp_sched_get_retransfunction mptcp_for_each_subflow
Annotated Snippet
if (!strcmp(sched->name, name)) {
ret = sched;
break;
}
}
return ret;
}
/* Build string with list of available scheduler values.
* Similar to tcp_get_available_congestion_control()
*/
void mptcp_get_available_schedulers(char *buf, size_t maxlen)
{
struct mptcp_sched_ops *sched;
size_t offs = 0;
rcu_read_lock();
list_for_each_entry_rcu(sched, &mptcp_sched_list, list) {
offs += snprintf(buf + offs, maxlen - offs,
"%s%s",
offs == 0 ? "" : " ", sched->name);
if (WARN_ON_ONCE(offs >= maxlen))
break;
}
rcu_read_unlock();
}
int mptcp_validate_scheduler(struct mptcp_sched_ops *sched)
{
if (!sched->get_send) {
pr_err("%s does not implement required ops\n", sched->name);
return -EINVAL;
}
return 0;
}
int mptcp_register_scheduler(struct mptcp_sched_ops *sched)
{
int ret;
ret = mptcp_validate_scheduler(sched);
if (ret)
return ret;
spin_lock(&mptcp_sched_list_lock);
if (mptcp_sched_find(sched->name)) {
spin_unlock(&mptcp_sched_list_lock);
return -EEXIST;
}
list_add_tail_rcu(&sched->list, &mptcp_sched_list);
spin_unlock(&mptcp_sched_list_lock);
pr_debug("%s registered\n", sched->name);
return 0;
}
void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched)
{
if (sched == &mptcp_sched_default)
return;
spin_lock(&mptcp_sched_list_lock);
list_del_rcu(&sched->list);
spin_unlock(&mptcp_sched_list_lock);
}
void mptcp_sched_init(void)
{
mptcp_register_scheduler(&mptcp_sched_default);
}
int mptcp_init_sched(struct mptcp_sock *msk,
struct mptcp_sched_ops *sched)
{
if (!sched)
sched = &mptcp_sched_default;
if (!bpf_try_module_get(sched, sched->owner))
return -EBUSY;
msk->sched = sched;
if (msk->sched->init)
msk->sched->init(msk);
pr_debug("sched=%s\n", msk->sched->name);
return 0;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/list.h`, `linux/rculist.h`, `linux/spinlock.h`, `protocol.h`.
- Detected declarations: `function mptcp_sched_default_get_send`, `function mptcp_sched_default_get_retrans`, `function list_for_each_entry_rcu`, `function tcp_get_available_congestion_control`, `function mptcp_validate_scheduler`, `function mptcp_register_scheduler`, `function mptcp_unregister_scheduler`, `function mptcp_sched_init`, `function mptcp_init_sched`, `function mptcp_release_sched`.
- 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.