大网数据广告活动
服务器运维问答

Linux bridge_slave changes automatically to forwarding state

· 52CE 我爱测

I'm trying to change the state of bridge slaves on Linux brigde system and It has very weird behaviour, changing all the time the port state to forwarding. I.E: Create a bridge with dummy interface as a slave (It occurs with othe…

问题原文

原帖链接 · Adrián Moreno · CC BY-SA 4.0

I'm trying to change the state of bridge slaves on Linux brigde system and It has very weird behaviour, changing all the time the port state to forwarding.

I.E:

Create a bridge with dummy interface as a slave (It occurs with other type of interace)

$ ip link add dev midummy type dummy
$ ip link add dev br type bridge
$ ip link set dev midummy master br
$ ip link set dev br up
$ ip link set dev midummy up

Check the status of the bridge slave:

$ brctl showstp br

...
midummy (1)
 port id        8001            state            forwarding
...

Try to change to blocking state

$ ip link set dev midummy type bridge_slave state 4
...
midummy (1)
 port id        8001            state            forwarding
...

$dmesg
[ 2414.108892] br: port 1(midummy) entered blocking state
[ 2414.108898] br: port 1(midummy) entered forwarding state

Why kernel is changing bridge slave state to forwarding? Is there any bridge flag to configure this behaviour?

Thanks in advance

已采纳解答

原帖链接 · Anton Danilov · CC BY-SA 4.0

In short, this behaviour is due by stp and periodic bridge port status checking by timer even the stp is disabled completely. You can investigate the source code to find why this happens. I have found the workaround to execute your wish. Linux kernel supports an userspace stp daemon and you can write it or just link it to /dev/true to manage the stp states by hands.

Short demonstration:

# create the fake stp daemon and disable in-kernel stp handling.
# should return success exit code
ln -s /bin/true /sbin/bridge-stp

# start the fake stp daemon
brctl stp br on

# bring up the interface to the blocking state
ip link set dev midummy type bridge_slave state 4

# check the interface state again and again. state aren't changing
# except the transactions between disabled and blocking state, 
# that depends on bridge port status (UP or DOWN)
# use 'bridge monitor' to realtime monitoring of state changes

# !!! stop the fake stp before removing the symlink /bin/bridge-stp !!!
brctl stp br off

# and then remove the symbolic link to prevent future effects
rm /sbin/bridge-stp

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-04-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。