net/bridge/br_ioctl.c
Source file repositories/reference/linux-study-clean/net/bridge/br_ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
net/bridge/br_ioctl.c- Extension
.c- Size
- 10171 bytes
- Lines
- 471
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/capability.hlinux/compat.hlinux/kernel.hlinux/if_bridge.hlinux/netdevice.hlinux/slab.hlinux/times.hnet/net_namespace.hlinux/uaccess.hbr_private.h
Detected Declarations
function get_bridge_ifindicesfunction get_port_ifindicesfunction list_for_each_entryfunction get_fdb_entriesfunction add_del_iffunction br_dev_read_uargsfunction br_dev_siocdevprivatefunction old_devicelessfunction br_ioctl_stub
Annotated Snippet
if ((pt = br_get_port(br, args[2])) == NULL) {
rcu_read_unlock();
return -EINVAL;
}
memset(&p, 0, sizeof(struct __port_info));
memcpy(&p.designated_root, &pt->designated_root, 8);
memcpy(&p.designated_bridge, &pt->designated_bridge, 8);
p.port_id = READ_ONCE(pt->port_id);
p.designated_port = READ_ONCE(pt->designated_port);
p.path_cost = READ_ONCE(pt->path_cost);
p.designated_cost = READ_ONCE(pt->designated_cost);
p.state = pt->state;
p.top_change_ack = pt->topology_change_ack;
p.config_pending = READ_ONCE(pt->config_pending);
p.message_age_timer_value = br_timer_value(&pt->message_age_timer);
p.forward_delay_timer_value = br_timer_value(&pt->forward_delay_timer);
p.hold_timer_value = br_timer_value(&pt->hold_timer);
rcu_read_unlock();
if (copy_to_user(argp, &p, sizeof(p)))
return -EFAULT;
return 0;
}
case BRCTL_SET_BRIDGE_STP_STATE:
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
return -EPERM;
ret = br_stp_set_enabled(br, args[1], NULL);
break;
case BRCTL_SET_BRIDGE_PRIORITY:
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
return -EPERM;
br_stp_set_bridge_priority(br, args[1]);
ret = 0;
break;
case BRCTL_SET_PORT_PRIORITY:
{
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
return -EPERM;
spin_lock_bh(&br->lock);
if ((p = br_get_port(br, args[1])) == NULL)
ret = -EINVAL;
else
ret = br_stp_set_port_priority(p, args[2]);
spin_unlock_bh(&br->lock);
break;
}
case BRCTL_SET_PATH_COST:
{
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
return -EPERM;
spin_lock_bh(&br->lock);
if ((p = br_get_port(br, args[1])) == NULL)
ret = -EINVAL;
else
ret = br_stp_set_path_cost(p, args[2]);
spin_unlock_bh(&br->lock);
break;
}
case BRCTL_GET_FDB_ENTRIES:
return get_fdb_entries(br, argp, args[2], args[3]);
default:
ret = -EOPNOTSUPP;
}
if (!ret) {
if (p)
br_ifinfo_notify(RTM_NEWLINK, NULL, p);
else
netdev_state_change(br->dev);
}
return ret;
}
static int old_deviceless(struct net *net, void __user *data)
{
unsigned long args[3];
Annotation
- Immediate include surface: `linux/capability.h`, `linux/compat.h`, `linux/kernel.h`, `linux/if_bridge.h`, `linux/netdevice.h`, `linux/slab.h`, `linux/times.h`, `net/net_namespace.h`.
- Detected declarations: `function get_bridge_ifindices`, `function get_port_ifindices`, `function list_for_each_entry`, `function get_fdb_entries`, `function add_del_if`, `function br_dev_read_uargs`, `function br_dev_siocdevprivate`, `function old_deviceless`, `function br_ioctl_stub`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.