net/bridge/br_sysfs_br.c
Source file repositories/reference/linux-study-clean/net/bridge/br_sysfs_br.c
File Facts
- System
- Linux kernel
- Corpus path
net/bridge/br_sysfs_br.c- Extension
.c- Size
- 30431 bytes
- Lines
- 1088
- 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/capability.hlinux/kernel.hlinux/netdevice.hlinux/etherdevice.hlinux/hex.hlinux/if_bridge.hlinux/rtnetlink.hlinux/spinlock.hlinux/times.hlinux/sched/signal.hbr_private.h
Detected Declarations
function store_bridge_parmfunction forward_delay_showfunction set_forward_delayfunction forward_delay_storefunction hello_time_showfunction set_hello_timefunction hello_time_storefunction max_age_showfunction set_max_agefunction max_age_storefunction ageing_time_showfunction set_ageing_timefunction ageing_time_storefunction stp_state_showfunction set_stp_statefunction stp_state_storefunction group_fwd_mask_showfunction set_group_fwd_maskfunction group_fwd_mask_storefunction priority_showfunction set_priorityfunction priority_storefunction root_id_showfunction bridge_id_showfunction root_port_showfunction root_path_cost_showfunction topology_change_showfunction topology_change_detected_showfunction hello_timer_showfunction tcn_timer_showfunction topology_change_timer_showfunction gc_timer_showfunction group_addr_showfunction group_addr_storefunction set_flushfunction flush_storefunction no_linklocal_learn_showfunction set_no_linklocal_learnfunction no_linklocal_learn_storefunction multicast_router_showfunction set_multicast_routerfunction multicast_router_storefunction multicast_snooping_showfunction multicast_snooping_storefunction multicast_query_use_ifaddr_showfunction set_query_use_ifaddrfunction multicast_query_use_ifaddr_storefunction multicast_querier_show
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Sysfs attributes of bridge
* Linux ethernet bridge
*
* Authors:
* Stephen Hemminger <shemminger@osdl.org>
*/
#include <linux/capability.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/hex.h>
#include <linux/if_bridge.h>
#include <linux/rtnetlink.h>
#include <linux/spinlock.h>
#include <linux/times.h>
#include <linux/sched/signal.h>
#include "br_private.h"
/* IMPORTANT: new bridge options must be added with netlink support only
* please do not add new sysfs entries
*/
#define to_bridge(cd) ((struct net_bridge *)netdev_priv(to_net_dev(cd)))
/*
* Common code for storing bridge parameters.
*/
static ssize_t store_bridge_parm(struct device *d,
const char *buf, size_t len,
int (*set)(struct net_bridge *br, unsigned long val,
struct netlink_ext_ack *extack))
{
struct net_bridge *br = to_bridge(d);
struct netlink_ext_ack extack = {0};
unsigned long val;
int err;
if (!ns_capable(dev_net(br->dev)->user_ns, CAP_NET_ADMIN))
return -EPERM;
err = kstrtoul(buf, 0, &val);
if (err != 0)
return err;
if (!rtnl_trylock())
return restart_syscall();
err = (*set)(br, val, &extack);
if (!err)
netdev_state_change(br->dev);
if (extack._msg) {
if (err)
br_err(br, "%s\n", extack._msg);
else
br_warn(br, "%s\n", extack._msg);
}
rtnl_unlock();
return err ? err : len;
}
static ssize_t forward_delay_show(struct device *d,
struct device_attribute *attr, char *buf)
{
struct net_bridge *br = to_bridge(d);
return sysfs_emit(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay));
}
static int set_forward_delay(struct net_bridge *br, unsigned long val,
struct netlink_ext_ack *extack)
{
return br_set_forward_delay(br, val);
}
static ssize_t forward_delay_store(struct device *d,
struct device_attribute *attr,
const char *buf, size_t len)
{
return store_bridge_parm(d, buf, len, set_forward_delay);
}
static DEVICE_ATTR_RW(forward_delay);
static ssize_t hello_time_show(struct device *d, struct device_attribute *attr,
char *buf)
{
Annotation
- Immediate include surface: `linux/capability.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/hex.h`, `linux/if_bridge.h`, `linux/rtnetlink.h`, `linux/spinlock.h`.
- Detected declarations: `function store_bridge_parm`, `function forward_delay_show`, `function set_forward_delay`, `function forward_delay_store`, `function hello_time_show`, `function set_hello_time`, `function hello_time_store`, `function max_age_show`, `function set_max_age`, `function max_age_store`.
- 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.