mirror of
https://github.com/netdata/libbpf.git
synced 2026-11-07 02:10:16 +08:00
net: bridge: add stp_mode attribute for STP mode selection
The bridge-stp usermode helper is currently restricted to the initial
network namespace, preventing userspace STP daemons (e.g. mstpd) from
operating on bridges in other network namespaces. Since commit
ff62198553e4 ("bridge: Only call /sbin/bridge-stp for the initial
network namespace"), bridges in non-init namespaces silently fall
back to kernel STP with no way to use userspace STP.
Add a new bridge attribute IFLA_BR_STP_MODE that allows explicit
per-bridge control over STP mode selection:
BR_STP_MODE_AUTO (default) - Existing behavior: invoke the
/sbin/bridge-stp helper in init_net only; fall back to kernel STP
if it fails or in non-init namespaces.
BR_STP_MODE_USER - Directly enable userspace STP (BR_USER_STP)
without invoking the helper. Works in any network namespace.
Userspace is responsible for ensuring an STP daemon manages the
bridge.
BR_STP_MODE_KERNEL - Directly enable kernel STP (BR_KERNEL_STP)
without invoking the helper.
The mode can only be changed while STP is disabled, or set to the
same value (-EBUSY otherwise). IFLA_BR_STP_MODE is processed before
IFLA_BR_STP_STATE in br_changelink(), so both can be set atomically
in a single netlink message. The mode can also be changed in the
same message that disables STP.
The stp_mode struct field is u8 since all possible values fit, while
NLA_U32 is used for the netlink attribute since it occupies the same
space in the netlink message as NLA_U8.
A new stp_helper_active boolean tracks whether the /sbin/bridge-stp
helper was invoked during br_stp_start(), so that br_stp_stop() only
calls the helper for stop when it was called for start. This avoids
calling the helper asymmetrically when stp_mode changes between
start and stop.
Suggested-by: Ido Schimmel <idosch@nvidia.com>
Assisted-by: Claude:claude-opus-4-6
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: Andy Roulin <aroulin@nvidia.com>
Link: https://patch.msgid.link/20260405205224.3163000-2-aroulin@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
1 parent
8159a62fa8
commit
86525c190b
1 file changed
+39
@@ -744,6 +744,11 @@ enum in6_addr_gen_mode {
|
||||
* @IFLA_BR_FDB_MAX_LEARNED
|
||||
* Set the number of max dynamically learned FDB entries for the current
|
||||
* bridge.
|
||||
*
|
||||
* @IFLA_BR_STP_MODE
|
||||
* Set the STP mode for the bridge, which controls how the bridge
|
||||
* selects between userspace and kernel STP. The valid values are
|
||||
* documented below in the ``BR_STP_MODE_*`` constants.
|
||||
*/
|
||||
enum {
|
||||
IFLA_BR_UNSPEC,
|
||||
@@ -796,11 +801,45 @@ enum {
|
||||
IFLA_BR_MCAST_QUERIER_STATE,
|
||||
IFLA_BR_FDB_N_LEARNED,
|
||||
IFLA_BR_FDB_MAX_LEARNED,
|
||||
IFLA_BR_STP_MODE,
|
||||
__IFLA_BR_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BR_MAX (__IFLA_BR_MAX - 1)
|
||||
|
||||
/**
|
||||
* DOC: Bridge STP mode values
|
||||
*
|
||||
* @BR_STP_MODE_AUTO
|
||||
* Default. The kernel invokes the ``/sbin/bridge-stp`` helper to hand
|
||||
* the bridge to a userspace STP daemon (e.g. mstpd). Only attempted in
|
||||
* the initial network namespace; in other namespaces this falls back to
|
||||
* kernel STP.
|
||||
*
|
||||
* @BR_STP_MODE_USER
|
||||
* Directly enable userspace STP (``BR_USER_STP``) without invoking the
|
||||
* ``/sbin/bridge-stp`` helper. Works in any network namespace.
|
||||
* Userspace is responsible for ensuring an STP daemon manages the
|
||||
* bridge.
|
||||
*
|
||||
* @BR_STP_MODE_KERNEL
|
||||
* Directly enable kernel STP (``BR_KERNEL_STP``) without invoking the
|
||||
* helper.
|
||||
*
|
||||
* The mode controls how the bridge selects between userspace and kernel
|
||||
* STP when STP is enabled via ``IFLA_BR_STP_STATE``. It can only be
|
||||
* changed while STP is disabled (``IFLA_BR_STP_STATE`` == 0), returns
|
||||
* ``-EBUSY`` otherwise. The default value is ``BR_STP_MODE_AUTO``.
|
||||
*/
|
||||
enum br_stp_mode {
|
||||
BR_STP_MODE_AUTO,
|
||||
BR_STP_MODE_USER,
|
||||
BR_STP_MODE_KERNEL,
|
||||
__BR_STP_MODE_MAX
|
||||
};
|
||||
|
||||
#define BR_STP_MODE_MAX (__BR_STP_MODE_MAX - 1)
|
||||
|
||||
struct ifla_bridge_id {
|
||||
__u8 prio[2];
|
||||
__u8 addr[6]; /* ETH_ALEN */
|
||||
|
||||
Reference in new issue
Block a user