net/bridge/br_mrp_netlink.c
Source file repositories/reference/linux-study-clean/net/bridge/br_mrp_netlink.c
File Facts
- System
- Linux kernel
- Corpus path
net/bridge/br_mrp_netlink.c- Extension
.c- Size
- 16395 bytes
- Lines
- 572
- 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
net/genetlink.huapi/linux/mrp_bridge.hbr_private.hbr_private_mrp.h
Detected Declarations
function br_mrp_instance_parsefunction br_mrp_port_state_parsefunction br_mrp_port_role_parsefunction br_mrp_ring_state_parsefunction br_mrp_ring_role_parsefunction br_mrp_start_test_parsefunction br_mrp_in_state_parsefunction br_mrp_in_role_parsefunction br_mrp_start_in_test_parsefunction br_mrp_parsefunction br_mrp_fill_infofunction hlist_for_each_entry_rcufunction br_mrp_ring_port_openfunction br_mrp_in_port_open
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <net/genetlink.h>
#include <uapi/linux/mrp_bridge.h>
#include "br_private.h"
#include "br_private_mrp.h"
static const struct nla_policy br_mrp_policy[IFLA_BRIDGE_MRP_MAX + 1] = {
[IFLA_BRIDGE_MRP_UNSPEC] = { .type = NLA_REJECT },
[IFLA_BRIDGE_MRP_INSTANCE] = { .type = NLA_NESTED },
[IFLA_BRIDGE_MRP_PORT_STATE] = { .type = NLA_NESTED },
[IFLA_BRIDGE_MRP_PORT_ROLE] = { .type = NLA_NESTED },
[IFLA_BRIDGE_MRP_RING_STATE] = { .type = NLA_NESTED },
[IFLA_BRIDGE_MRP_RING_ROLE] = { .type = NLA_NESTED },
[IFLA_BRIDGE_MRP_START_TEST] = { .type = NLA_NESTED },
[IFLA_BRIDGE_MRP_IN_ROLE] = { .type = NLA_NESTED },
[IFLA_BRIDGE_MRP_IN_STATE] = { .type = NLA_NESTED },
[IFLA_BRIDGE_MRP_START_IN_TEST] = { .type = NLA_NESTED },
};
static const struct nla_policy
br_mrp_instance_policy[IFLA_BRIDGE_MRP_INSTANCE_MAX + 1] = {
[IFLA_BRIDGE_MRP_INSTANCE_UNSPEC] = { .type = NLA_REJECT },
[IFLA_BRIDGE_MRP_INSTANCE_RING_ID] = { .type = NLA_U32 },
[IFLA_BRIDGE_MRP_INSTANCE_P_IFINDEX] = { .type = NLA_U32 },
[IFLA_BRIDGE_MRP_INSTANCE_S_IFINDEX] = { .type = NLA_U32 },
[IFLA_BRIDGE_MRP_INSTANCE_PRIO] = { .type = NLA_U16 },
};
static int br_mrp_instance_parse(struct net_bridge *br, struct nlattr *attr,
int cmd, struct netlink_ext_ack *extack)
{
struct nlattr *tb[IFLA_BRIDGE_MRP_INSTANCE_MAX + 1];
struct br_mrp_instance inst;
int err;
err = nla_parse_nested(tb, IFLA_BRIDGE_MRP_INSTANCE_MAX, attr,
br_mrp_instance_policy, extack);
if (err)
return err;
if (!tb[IFLA_BRIDGE_MRP_INSTANCE_RING_ID] ||
!tb[IFLA_BRIDGE_MRP_INSTANCE_P_IFINDEX] ||
!tb[IFLA_BRIDGE_MRP_INSTANCE_S_IFINDEX]) {
NL_SET_ERR_MSG_MOD(extack,
"Missing attribute: RING_ID or P_IFINDEX or S_IFINDEX");
return -EINVAL;
}
memset(&inst, 0, sizeof(inst));
inst.ring_id = nla_get_u32(tb[IFLA_BRIDGE_MRP_INSTANCE_RING_ID]);
inst.p_ifindex = nla_get_u32(tb[IFLA_BRIDGE_MRP_INSTANCE_P_IFINDEX]);
inst.s_ifindex = nla_get_u32(tb[IFLA_BRIDGE_MRP_INSTANCE_S_IFINDEX]);
inst.prio = MRP_DEFAULT_PRIO;
if (tb[IFLA_BRIDGE_MRP_INSTANCE_PRIO])
inst.prio = nla_get_u16(tb[IFLA_BRIDGE_MRP_INSTANCE_PRIO]);
if (cmd == RTM_SETLINK)
return br_mrp_add(br, &inst);
else
return br_mrp_del(br, &inst);
return 0;
}
static const struct nla_policy
br_mrp_port_state_policy[IFLA_BRIDGE_MRP_PORT_STATE_MAX + 1] = {
[IFLA_BRIDGE_MRP_PORT_STATE_UNSPEC] = { .type = NLA_REJECT },
[IFLA_BRIDGE_MRP_PORT_STATE_STATE] = { .type = NLA_U32 },
};
static int br_mrp_port_state_parse(struct net_bridge_port *p,
struct nlattr *attr,
struct netlink_ext_ack *extack)
{
struct nlattr *tb[IFLA_BRIDGE_MRP_PORT_STATE_MAX + 1];
enum br_mrp_port_state_type state;
int err;
err = nla_parse_nested(tb, IFLA_BRIDGE_MRP_PORT_STATE_MAX, attr,
br_mrp_port_state_policy, extack);
if (err)
return err;
if (!tb[IFLA_BRIDGE_MRP_PORT_STATE_STATE]) {
NL_SET_ERR_MSG_MOD(extack, "Missing attribute: STATE");
return -EINVAL;
Annotation
- Immediate include surface: `net/genetlink.h`, `uapi/linux/mrp_bridge.h`, `br_private.h`, `br_private_mrp.h`.
- Detected declarations: `function br_mrp_instance_parse`, `function br_mrp_port_state_parse`, `function br_mrp_port_role_parse`, `function br_mrp_ring_state_parse`, `function br_mrp_ring_role_parse`, `function br_mrp_start_test_parse`, `function br_mrp_in_state_parse`, `function br_mrp_in_role_parse`, `function br_mrp_start_in_test_parse`, `function br_mrp_parse`.
- 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.