Message ID | 20231117093145.1563511-6-liuhangbin@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Doc: update bridge doc | expand |
On Fri, Nov 17, 2023 at 05:31:40PM +0800, Hangbin Liu wrote: > +STP > +=== I think it would be very good to say a few words about the user space STP helper at /sbin/bridge-stp, and that the kernel only has full support for the legacy STP, whereas newer protocols are all handled in user space. But I don't know a lot of technical details about it, so I would hope somebody else chimes in with a paragraph inserted here somewhere :)
On Mon, Nov 20, 2023 at 01:39:47PM +0200, Vladimir Oltean wrote: > On Fri, Nov 17, 2023 at 05:31:40PM +0800, Hangbin Liu wrote: > > +STP > > +=== > > I think it would be very good to say a few words about the user space > STP helper at /sbin/bridge-stp, and that the kernel only has full support > for the legacy STP, whereas newer protocols are all handled in user > space. But I don't know a lot of technical details about it, so I would > hope somebody else chimes in with a paragraph inserted here somewhere :) Hmm, I google searched but can't find this tool. Nikolay, is this tool still widely used? Do you know where I can find the source code/doc of it? Thanks Hangbin
On 11/21/23 05:02, Hangbin Liu wrote: > On Mon, Nov 20, 2023 at 01:39:47PM +0200, Vladimir Oltean wrote: >> On Fri, Nov 17, 2023 at 05:31:40PM +0800, Hangbin Liu wrote: >>> +STP >>> +=== >> >> I think it would be very good to say a few words about the user space >> STP helper at /sbin/bridge-stp, and that the kernel only has full support >> for the legacy STP, whereas newer protocols are all handled in user >> space. But I don't know a lot of technical details about it, so I would >> hope somebody else chimes in with a paragraph inserted here somewhere :) > > Hmm, I google searched but can't find this tool. Nikolay, is this tool still > widely used? Do you know where I can find the source code/doc of it? > > Thanks > Hangbin Man.. you're documenting the bridge, please check its source code and you'll have your answer. "bridge-stp" is not a single tool, rather than a device for the bridge to start/stop user-space stp when requested. As an example here's the first google result: https://github.com/mstpd/mstpd/blob/master/bridge-stp.in
Hi Nikolay, On Fri, Nov 24, 2023 at 03:18:19PM +0200, Nikolay Aleksandrov wrote: > On 11/21/23 05:02, Hangbin Liu wrote: > > On Mon, Nov 20, 2023 at 01:39:47PM +0200, Vladimir Oltean wrote: > > > On Fri, Nov 17, 2023 at 05:31:40PM +0800, Hangbin Liu wrote: > > > > +STP > > > > +=== > > > > > > I think it would be very good to say a few words about the user space > > > STP helper at /sbin/bridge-stp, and that the kernel only has full support > > > for the legacy STP, whereas newer protocols are all handled in user > > > space. But I don't know a lot of technical details about it, so I would > > > hope somebody else chimes in with a paragraph inserted here somewhere :) > > > > Hmm, I google searched but can't find this tool. Nikolay, is this tool still > > widely used? Do you know where I can find the source code/doc of it? > > > > Thanks > > Hangbin > > Man.. you're documenting the bridge, please check its source code and > you'll have your answer. "bridge-stp" is not a single tool, rather than Thanks for your reply. I'm not very familiar with the bridge STP part. The #define BR_STP_PROG "/sbin/bridge-stp" mislead me to think that the bridge-stp is a userspace tool.. > a device for the bridge to start/stop user-space stp when requested. > As an example here's the first google result: > https://github.com/mstpd/mstpd/blob/master/bridge-stp.in Last time I just searched bridge-stp and didn't find any useful result. This time with "sbin/bridge-stp" I saw the doc you pointed. Thanks for your reference. So for the STP part, How about add a paragraph like: The user space STP helper *bridge-stp* is a program to control whether to use user mode spanning tree. The `/sbin/bridge-stp <bridge> <start|stop>` is called by the kernel when STP is enabled/disabled on a bridge (via `brctl stp <bridge> <on|off>` or `ip link set <bridge> type bridge stp_state <0|1>`). The kernel enables user_stp mode if that command returns 0, or enables kernel_stp mode if that command returns any other value. Thanks Hangbin
On Tue, 21 Nov 2023 11:02:55 +0800 Hangbin Liu <liuhangbin@gmail.com> wrote: > On Mon, Nov 20, 2023 at 01:39:47PM +0200, Vladimir Oltean wrote: > > On Fri, Nov 17, 2023 at 05:31:40PM +0800, Hangbin Liu wrote: > > > +STP > > > +=== > > > > I think it would be very good to say a few words about the user space > > STP helper at /sbin/bridge-stp, and that the kernel only has full support > > for the legacy STP, whereas newer protocols are all handled in user > > space. But I don't know a lot of technical details about it, so I would > > hope somebody else chimes in with a paragraph inserted here somewhere :) > > Hmm, I google searched but can't find this tool. Nikolay, is this tool still > widely used? Do you know where I can find the source code/doc of it? > > Thanks > Hangbin Older one is here (no longer maintained): https://github.com/shemminger/RSTP Other version is here: https://github.com/mstpd/mstpd
diff --git a/Documentation/networking/bridge.rst b/Documentation/networking/bridge.rst index 84aae94f6598..1fd339e48129 100644 --- a/Documentation/networking/bridge.rst +++ b/Documentation/networking/bridge.rst @@ -51,6 +51,91 @@ options are added. .. kernel-doc:: net/bridge/br_sysfs_br.c :doc: Bridge sysfs attributes +STP +=== + +The STP (Spanning Tree Protocol) implementation in the Linux bridge driver +is a critical feature that helps prevent loops and broadcast storms in +Ethernet networks by identifying and disabling redundant links. In a Linux +bridge context, STP is crucial for network stability and availability. + +STP is a Layer 2 protocol that operates at the Data Link Layer of the OSI +model. It was originally developed as IEEE 802.1D and has since evolved into +multiple versions, including Rapid Spanning Tree Protocol (RSTP) and +`Multiple Spanning Tree Protocol (MSTP) +<https://lore.kernel.org/netdev/20220316150857.2442916-1-tobias@waldekranz.com/>`_. + +Bridge Ports and STP States +--------------------------- + +In the context of STP, bridge ports can be in one of the following states: + * Blocking: The port is disabled for data traffic and only listens for + BPDUs (Bridge Protocol Data Units) from other devices to determine the + network topology. + * Listening: The port begins to participate in the STP process and listens + for BPDUs. + * Learning: The port continues to listen for BPDUs and begins to learn MAC + addresses from incoming frames but does not forward data frames. + * Forwarding: The port is fully operational and forwards both BPDUs and + data frames. + * Disabled: The port is administratively disabled and does not participate + in the STP process. The data frames forwarding are also disabled. + +Root Bridge and Convergence +--------------------------- + +In the context of networking and Ethernet bridging in Linux, the root bridge +is a designated switch in a bridged network that serves as a reference point +for the spanning tree algorithm to create a loop-free topology. + +Here's how the STP works and root bridge is chosen: + 1. Bridge Priority: Each bridge running a spanning tree protocol, has a + configurable Bridge Priority value. The lower the value, the higher the + priority. By default, the Bridge Priority is set to a standard value + (e.g., 32768). + 2. Bridge ID: The Bridge ID is composed of two components: Bridge Priority + and the MAC address of the bridge. It uniquely identifies each bridge + in the network. The Bridge ID is used to compare the priorities of + different bridges. + 3. Bridge Election: When the network starts, all bridges initially assume + that they are the root bridge. They start advertising Bridge Protocol + Data Units (BPDU) to their neighbors, containing their Bridge ID and + other information. + 4. BPDU Comparison: Bridges exchange BPDUs to determine the root bridge. + Each bridge examines the received BPDUs, including the Bridge Priority + and Bridge ID, to determine if it should adjust its own priorities. + The bridge with the lowest Bridge ID will become the root bridge. + 5. Root Bridge Announcement: Once the root bridge is determined, it sends + BPDUs with information about the root bridge to all other bridges in the + network. This information is used by other bridges to calculate the + shortest path to the root bridge and, in doing so, create a loop-free + topology. + 6. Forwarding Ports: After the root bridge is selected and the spanning tree + topology is established, each bridge determines which of its ports should + be in the forwarding state (used for data traffic) and which should be in + the blocking state (used to prevent loops). The root bridge's ports are + all in the forwarding state. while other bridges have some ports in the + blocking state to avoid loops. + 7. Root Ports: After the root bridge is selected and the spanning tree + topology is established, each non-root bridge processes incoming + BPDUs and determines which of its ports provides the shortest path to the + root bridge based on the information in the received BPDUs. This port is + designated as the root port. And it is in the Forwarding state, allowing + it to actively forward network traffic. + 8. Designated ports: A designated port is the port through which the non-root + bridge will forward traffic towards the designated segment. Designated ports + are placed in the Forwarding state. All other ports on the non-root + bridge that are not designated for specific segments are placed in the + Blocking state to prevent network loops. + +STP ensures network convergence by calculating the shortest path and disabling +redundant links. When network topology changes occur (e.g., a link failure), +STP recalculates the network topology to restore connectivity while avoiding loops. + +Proper configuration of STP parameters, such as the bridge priority, can +influence which bridge becomes the Root Bridge. Careful configuration can +optimize network performance and path selection. + FAQ ===
Add STP part for bridge document. Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> --- Documentation/networking/bridge.rst | 85 +++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)