net/mptcp/pm_netlink.c
Source file repositories/reference/linux-study-clean/net/mptcp/pm_netlink.c
File Facts
- System
- Linux kernel
- Corpus path
net/mptcp/pm_netlink.c- Extension
.c- Size
- 15788 bytes
- Lines
- 647
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
protocol.hmptcp_pm_gen.h
Detected Declarations
function mptcp_pm_family_to_addrfunction mptcp_pm_parse_pm_addr_attrfunction mptcp_pm_parse_addrfunction mptcp_pm_parse_entryfunction mptcp_nl_fill_addrfunction mptcp_pm_get_addrfunction mptcp_pm_nl_get_addr_doitfunction mptcp_pm_genl_fill_addrfunction mptcp_pm_dump_addrfunction mptcp_pm_nl_get_addr_dumpitfunction mptcp_pm_set_flagsfunction mptcp_pm_nl_set_flags_doitfunction mptcp_nl_mcast_sendfunction mptcp_userspace_pm_activefunction mptcp_event_add_subflowfunction mptcp_event_put_token_and_sskfunction mptcp_event_sub_establishedfunction mptcp_event_sub_closedfunction mptcp_event_createdfunction mptcp_event_addr_removedfunction mptcp_event_addr_announcedfunction mptcp_event_pm_listenerfunction mptcp_eventfunction mptcp_pm_nl_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Multipath TCP
*
* Copyright (c) 2020, Red Hat, Inc.
*/
#define pr_fmt(fmt) "MPTCP: " fmt
#include "protocol.h"
#include "mptcp_pm_gen.h"
#define MPTCP_PM_CMD_GRP_OFFSET 0
#define MPTCP_PM_EV_GRP_OFFSET 1
static const struct genl_multicast_group mptcp_pm_mcgrps[] = {
[MPTCP_PM_CMD_GRP_OFFSET] = { .name = MPTCP_PM_CMD_GRP_NAME, },
[MPTCP_PM_EV_GRP_OFFSET] = { .name = MPTCP_PM_EV_GRP_NAME,
.flags = GENL_MCAST_CAP_NET_ADMIN,
},
};
static int mptcp_pm_family_to_addr(int family)
{
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
if (family == AF_INET6)
return MPTCP_PM_ADDR_ATTR_ADDR6;
#endif
return MPTCP_PM_ADDR_ATTR_ADDR4;
}
static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[],
const struct nlattr *attr,
struct genl_info *info,
struct mptcp_addr_info *addr,
bool require_family)
{
int err, addr_addr;
if (!attr) {
GENL_SET_ERR_MSG(info, "missing address info");
return -EINVAL;
}
/* no validation needed - was already done via nested policy */
err = nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr,
mptcp_pm_address_nl_policy, info->extack);
if (err)
return err;
if (tb[MPTCP_PM_ADDR_ATTR_ID])
addr->id = nla_get_u8(tb[MPTCP_PM_ADDR_ATTR_ID]);
if (!tb[MPTCP_PM_ADDR_ATTR_FAMILY]) {
if (!require_family)
return 0;
NL_SET_ERR_MSG_ATTR(info->extack, attr,
"missing family");
return -EINVAL;
}
addr->family = nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_FAMILY]);
if (addr->family != AF_INET
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
&& addr->family != AF_INET6
#endif
) {
NL_SET_ERR_MSG_ATTR(info->extack, attr,
"unknown address family");
return -EINVAL;
}
addr_addr = mptcp_pm_family_to_addr(addr->family);
if (!tb[addr_addr]) {
NL_SET_ERR_MSG_ATTR(info->extack, attr,
"missing address data");
return -EINVAL;
}
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
if (addr->family == AF_INET6)
addr->addr6 = nla_get_in6_addr(tb[addr_addr]);
else
#endif
addr->addr.s_addr = nla_get_in_addr(tb[addr_addr]);
if (tb[MPTCP_PM_ADDR_ATTR_PORT])
addr->port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]));
return 0;
}
Annotation
- Immediate include surface: `protocol.h`, `mptcp_pm_gen.h`.
- Detected declarations: `function mptcp_pm_family_to_addr`, `function mptcp_pm_parse_pm_addr_attr`, `function mptcp_pm_parse_addr`, `function mptcp_pm_parse_entry`, `function mptcp_nl_fill_addr`, `function mptcp_pm_get_addr`, `function mptcp_pm_nl_get_addr_doit`, `function mptcp_pm_genl_fill_addr`, `function mptcp_pm_dump_addr`, `function mptcp_pm_nl_get_addr_dumpit`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.