net/mptcp/pm_userspace.c
Source file repositories/reference/linux-study-clean/net/mptcp/pm_userspace.c
File Facts
- System
- Linux kernel
- Corpus path
net/mptcp/pm_userspace.c- Extension
.c- Size
- 16542 bytes
- Lines
- 701
- 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
protocol.hmib.hmptcp_pm_gen.h
Detected Declarations
struct id_bitmapfunction Copyrightfunction list_for_each_entry_safefunction mptcp_userspace_pm_lookup_addrfunction mptcp_for_each_userspace_pm_addrfunction mptcp_userspace_pm_append_new_local_addrfunction mptcp_userspace_pm_delete_local_addrfunction mptcp_userspace_pm_lookup_addr_by_idfunction mptcp_for_each_userspace_pm_addrfunction mptcp_userspace_pm_get_local_idfunction mptcp_userspace_pm_is_backupfunction mptcp_pm_nl_announce_doitfunction mptcp_userspace_pm_remove_id_zero_addressfunction mptcp_pm_remove_addr_entryfunction mptcp_pm_nl_remove_doitfunction mptcp_pm_nl_subflow_create_doitfunction mptcp_for_each_subflowfunction mptcp_pm_nl_subflow_destroy_doitfunction mptcp_userspace_pm_set_flagsfunction mptcp_userspace_pm_dump_addrfunction mptcp_userspace_pm_get_addrfunction mptcp_pm_userspace_register
Annotated Snippet
struct id_bitmap {
DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
} *bitmap;
const struct genl_info *info = genl_info_dump(cb);
struct mptcp_pm_addr_entry *entry;
struct mptcp_sock *msk;
int ret = -EINVAL;
struct sock *sk;
BUILD_BUG_ON(sizeof(struct id_bitmap) > sizeof(cb->ctx));
bitmap = (struct id_bitmap *)cb->ctx;
msk = mptcp_userspace_pm_get_sock(info);
if (!msk)
return ret;
sk = (struct sock *)msk;
lock_sock(sk);
spin_lock_bh(&msk->pm.lock);
mptcp_for_each_userspace_pm_addr(msk, entry) {
if (test_bit(entry->addr.id, bitmap->map))
continue;
if (mptcp_pm_genl_fill_addr(msg, cb, entry) < 0)
break;
__set_bit(entry->addr.id, bitmap->map);
}
spin_unlock_bh(&msk->pm.lock);
release_sock(sk);
ret = msg->len;
sock_put(sk);
return ret;
}
int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
struct genl_info *info)
{
struct mptcp_pm_addr_entry *entry;
struct mptcp_sock *msk;
int ret = -EINVAL;
struct sock *sk;
msk = mptcp_userspace_pm_get_sock(info);
if (!msk)
return ret;
sk = (struct sock *)msk;
lock_sock(sk);
spin_lock_bh(&msk->pm.lock);
entry = mptcp_userspace_pm_lookup_addr_by_id(msk, id);
if (entry) {
*addr = *entry;
ret = 0;
}
spin_unlock_bh(&msk->pm.lock);
release_sock(sk);
sock_put(sk);
return ret;
}
static struct mptcp_pm_ops mptcp_pm_userspace = {
.name = "userspace",
.owner = THIS_MODULE,
};
void __init mptcp_pm_userspace_register(void)
{
mptcp_pm_register(&mptcp_pm_userspace);
}
Annotation
- Immediate include surface: `protocol.h`, `mib.h`, `mptcp_pm_gen.h`.
- Detected declarations: `struct id_bitmap`, `function Copyright`, `function list_for_each_entry_safe`, `function mptcp_userspace_pm_lookup_addr`, `function mptcp_for_each_userspace_pm_addr`, `function mptcp_userspace_pm_append_new_local_addr`, `function mptcp_userspace_pm_delete_local_addr`, `function mptcp_userspace_pm_lookup_addr_by_id`, `function mptcp_for_each_userspace_pm_addr`, `function mptcp_userspace_pm_get_local_id`.
- 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.