stp 不在网络命名空间中工作?

stp 不在网络命名空间中工作?

为什么 netns 内部的 Linux 网桥可以看到 bpdus 但不更新拓扑?

我创建了一对网络:NS300、NS301,每个网络中都有一个网桥:br300、br301、网桥 3031-3130 之间的第一个 veth 链路,以及网桥 3031b-3130b 之间的第二个 veth 链路。

我已将 veth 接口设置为 netnses,对其进行升级,将它们从属到网桥,并且可以通过 veth 链路双向查看网桥之间的 STP BPDU。但网桥似乎对 BPDU 没有反应。不发生根桥选举。每座桥都将自己视为根桥。

通过在网桥之间添加第二条 veth 链路,我有效地形成了一个 cpu 主机利用率为 100% 的循环(一个网桥具有到 PC 的物理链路)。使用bridge的优先级和veth端口成本并没有多大帮助。

两个 veth 链接均被禁用:

mikle@LabHost:~$ sudo ip netns show
NS301 (id: 1)
NS300 (id: 0)

mikle@LabHost:~$ sudo ip -n NS300 -br link show type veth
300b@if10        UP             46:03:77:1a:8c:f8 <BROADCAST,MULTICAST,UP,LOWER_UP>
3031@if22        DOWN           4a:db:50:ac:f2:bc <BROADCAST,MULTICAST>
3031b@if24       DOWN           8a:f7:74:8e:57:6a <BROADCAST,MULTICAST>


mikle@LabHost:~$ sudo ip -n NS301 -br link show type veth
301b@if12        UP             9a:1b:d5:c3:6b:07 <BROADCAST,MULTICAST,UP,LOWER_UP>
3130@if23        LOWERLAYERDOWN 6e:e6:83:e3:51:b8 <NO-CARRIER,BROADCAST,MULTICAST,UP>
3130b@if25       LOWERLAYERDOWN 9a:07:48:db:a8:dd <NO-CARRIER,BROADCAST,MULTICAST,UP>


mikle@LabHost:~$ sudo ip netns exec NS300 ip -d link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
2: br300: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 46:03:77:1a:8c:f8 brd ff:ff:ff:ff:ff:ff promiscuity 0
    bridge forward_delay 3000 hello_time 200 max_age 2000 ageing_time 30000 stp_state 1 priority 4096 vlan_filtering 0 vlan_protocol 802.1Q bridge_id 1000.46:3:77:1a:8c:f8 designated_root 1000.46:3:77:1a:8c:f8 root_port 0 root_path_cost 0 topology_change 0 topology_change_detected 0 hello_timer    0.64 tcn_timer    0.00 topology_change_timer    0.00 gc_timer   86.64 vlan_default_pvid 1 group_fwd_mask 0 group_address 01:80:c2:00:00:00 mcast_snooping 1 mcast_router 1 mcast_query_use_ifaddr 0 mcast_querier 0 mcast_hash_elasticity 4 mcast_hash_max 512 mcast_last_member_count 2 mcast_startup_query_count 2 mcast_last_member_interval 100 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query_response_interval 1000 mcast_startup_query_interval 3125 nf_call_iptables 0 nf_call_ip6tables 0 nf_call_arptables 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
9: 300b@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br300 state UP mode DEFAULT group default qlen 1000
    link/ether 46:03:77:1a:8c:f8 brd ff:ff:ff:ff:ff:ff link-netnsid 0 promiscuity 1
    veth
    bridge_slave state forwarding priority 8 cost 50 hairpin off guard off root_block off fastleave off learning on flood on port_id 0x2001 port_no 0x1 designated_port 8193 designated_cost 0 designated_bridge 1000.46:3:77:1a:8c:f8 designated_root 1000.46:3:77:1a:8c:f8 hold_timer    0.00 message_age_timer    0.00 forward_delay_timer    0.00 topology_change_ack 0 config_pending 0 proxy_arp off proxy_arp_wifi off mcast_router 1 mcast_fast_leave off mcast_flood on addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
16: tun300: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc pfifo_fast master br300 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 52:6b:30:d6:d5:8f brd ff:ff:ff:ff:ff:ff promiscuity 1
    bridge_slave state forwarding priority 32 cost 100 hairpin off guard off root_block off fastleave off learning on flood on port_id 0x8003 port_no 0x3 designated_port 32771 designated_cost 0 designated_bridge 1000.46:3:77:1a:8c:f8 designated_root 1000.46:3:77:1a:8c:f8 hold_timer    0.00 message_age_timer    0.00 forward_delay_timer    0.00 topology_change_ack 0 config_pending 0 proxy_arp off proxy_arp_wifi off mcast_router 1 mcast_fast_leave off mcast_flood on addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
23: 3031@if22: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue master br300 state DOWN mode DEFAULT group default qlen 1000
    link/ether 4a:db:50:ac:f2:bc brd ff:ff:ff:ff:ff:ff link-netnsid 1 promiscuity 1
    veth
    bridge_slave state disabled priority 8 cost 50 hairpin off guard off root_block off fastleave off learning on flood on port_id 0x2002 port_no 0x2 designated_port 8194 designated_cost 0 designated_bridge 1000.46:3:77:1a:8c:f8 designated_root 1000.46:3:77:1a:8c:f8 hold_timer    0.00 message_age_timer    0.00 forward_delay_timer    0.00 topology_change_ack 0 config_pending 0 proxy_arp off proxy_arp_wifi off mcast_router 1 mcast_fast_leave off mcast_flood on addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
25: 3031b@if24: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue master br300 state DOWN mode DEFAULT group default qlen 1000
    link/ether 8a:f7:74:8e:57:6a brd ff:ff:ff:ff:ff:ff link-netnsid 1 promiscuity 1
    veth
    bridge_slave state disabled priority 8 cost 50 hairpin off guard off root_block off fastleave off learning on flood on port_id 0x2004 port_no 0x4 designated_port 8196 designated_cost 0 designated_bridge 1000.46:3:77:1a:8c:f8 designated_root 1000.46:3:77:1a:8c:f8 hold_timer    0.00 message_age_timer    0.00 forward_delay_timer    0.00 topology_change_ack 0 config_pending 0 proxy_arp off proxy_arp_wifi off mcast_router 1 mcast_fast_leave off mcast_flood on addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535


mikle@LabHost:~$ sudo ip netns exec NS301 ip -d link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
2: br301: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 6e:e6:83:e3:51:b8 brd ff:ff:ff:ff:ff:ff promiscuity 0
    bridge forward_delay 3000 hello_time 200 max_age 2000 ageing_time 30000 stp_state 1 priority 32768 vlan_filtering 0 vlan_protocol 802.1Q bridge_id 8000.6e:e6:83:e3:51:b8 designated_root 8000.6e:e6:83:e3:51:b8 root_port 0 root_path_cost 0 topology_change 0 topology_change_detected 0 hello_timer    1.11 tcn_timer    0.00 topology_change_timer    0.00 gc_timer  237.11 vlan_default_pvid 1 group_fwd_mask 0 group_address 01:80:c2:00:00:00 mcast_snooping 1 mcast_router 1 mcast_query_use_ifaddr 0 mcast_querier 0 mcast_hash_elasticity 4 mcast_hash_max 512 mcast_last_member_count 2 mcast_startup_query_count 2 mcast_last_member_interval 100 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query_response_interval 1000 mcast_startup_query_interval 3125 nf_call_iptables 0 nf_call_ip6tables 0 nf_call_arptables 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
11: 301b@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br301 state UP mode DEFAULT group default qlen 1000
    link/ether 9a:1b:d5:c3:6b:07 brd ff:ff:ff:ff:ff:ff link-netnsid 0 promiscuity 1
    veth
    bridge_slave state forwarding priority 32 cost 2 hairpin off guard off root_block off fastleave off learning on flood on port_id 0x8001 port_no 0x1 designated_port 32769 designated_cost 0 designated_bridge 8000.6e:e6:83:e3:51:b8 designated_root 8000.6e:e6:83:e3:51:b8 hold_timer    0.11 message_age_timer    0.00 forward_delay_timer    0.00 topology_change_ack 0 config_pending 0 proxy_arp off proxy_arp_wifi off mcast_router 1 mcast_fast_leave off mcast_flood on addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
17: tun301: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc pfifo_fast master br301 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether ee:c5:9b:f8:1c:e5 brd ff:ff:ff:ff:ff:ff promiscuity 1
    bridge_slave state forwarding priority 32 cost 100 hairpin off guard off root_block off fastleave off learning on flood on port_id 0x8003 port_no 0x3 designated_port 32771 designated_cost 0 designated_bridge 8000.6e:e6:83:e3:51:b8 designated_root 8000.6e:e6:83:e3:51:b8 hold_timer    0.11 message_age_timer    0.00 forward_delay_timer    0.00 topology_change_ack 0 config_pending 0 proxy_arp off proxy_arp_wifi off mcast_router 1 mcast_fast_leave off mcast_flood on addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
22: 3130@if23: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br301 state LOWERLAYERDOWN mode DEFAULT group default qlen 1000
    link/ether 6e:e6:83:e3:51:b8 brd ff:ff:ff:ff:ff:ff link-netnsid 1 promiscuity 1
    veth
    bridge_slave state disabled priority 32 cost 2 hairpin off guard off root_block off fastleave off learning on flood on port_id 0x8002 port_no 0x2 designated_port 32770 designated_cost 0 designated_bridge 8000.6e:e6:83:e3:51:b8 designated_root 8000.6e:e6:83:e3:51:b8 hold_timer    0.00 message_age_timer    0.00 forward_delay_timer    0.00 topology_change_ack 0 config_pending 0 proxy_arp off proxy_arp_wifi off mcast_router 1 mcast_fast_leave off mcast_flood on addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
24: 3130b@if25: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br301 state LOWERLAYERDOWN mode DEFAULT group default qlen 1000
    link/ether 9a:07:48:db:a8:dd brd ff:ff:ff:ff:ff:ff link-netnsid 1 promiscuity 1
    veth
    bridge_slave state disabled priority 32 cost 2 hairpin off guard off root_block off fastleave off learning on flood on port_id 0x8004 port_no 0x4 designated_port 32772 designated_cost 0 designated_bridge 8000.6e:e6:83:e3:51:b8 designated_root 8000.6e:e6:83:e3:51:b8 hold_timer    0.00 message_age_timer    0.00 forward_delay_timer    0.00 topology_change_ack 0 config_pending 0 proxy_arp off proxy_arp_wifi off mcast_router 1 mcast_fast_leave off mcast_flood on addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535



mikle@LabHost:~$ sudo ip netns exec NS300 brctl show
bridge name     bridge id               STP enabled     interfaces
br300           1000.4603771a8cf8       yes             300b
                                                        3031
                                                        3031b
                                                        tun300

mikle@LabHost:~$ sudo ip netns exec NS300 brctl showstp br300
br300
 bridge id              1000.4603771a8cf8
 designated root        1000.4603771a8cf8
 root port                 0                    path cost                  0
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            30.00                 bridge forward delay      30.00
 ageing time             300.00
 hello timer               0.58                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                  38.58
 flags


300b (1)
 port id                2001                    state                forwarding
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2001                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

3031 (2)
 port id                2002                    state                  disabled
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

3031b (4)
 port id                2004                    state                  disabled
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2004                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

tun300 (3)
 port id                8003                    state                forwarding
 designated root        1000.4603771a8cf8       path cost                100
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        8003                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags




mikle@LabHost:~$ sudo ip netns exec NS300 brctl showmacs br300
port no mac addr                is local?       ageing timer
<... partially skipped ...>
  3     18:9c:5d:1c:12:c7       no                 1.09
  3     2c:27:d7:be:01:24       no               248.84
  1     4e:4d:4a:bb:b1:f7       no               115.99
  3     54:7f:ee:1f:bf:bc       no                18.33
  3     9c:b6:54:7c:dd:0d       no                 1.77
  3     b4:b5:2f:61:d8:a1       no                15.69
  3     e4:c7:22:f2:ab:60       no                61.47



mikle@LabHost:~$ sudo ip netns exec NS301 brctl show
bridge name     bridge id               STP enabled     interfaces
br301           8000.6ee683e351b8       yes             301b
                                                        3130
                                                        3130b
                                                        tun301
mikle@LabHost:~$ sudo ip netns exec NS301 brctl showstp br301
br301
 bridge id              8000.6ee683e351b8
 designated root        8000.6ee683e351b8
 root port                 0                    path cost                  0
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            30.00                 bridge forward delay      30.00
 ageing time             300.00
 hello timer               0.00                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                 155.99
 flags


301b (1)
 port id                8001                    state                forwarding
 designated root        8000.6ee683e351b8       path cost                  2
 designated bridge      8000.6ee683e351b8       message age timer          0.00
 designated port        8001                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

3130 (2)
 port id                8002                    state                  disabled
 designated root        8000.6ee683e351b8       path cost                  2
 designated bridge      8000.6ee683e351b8       message age timer          0.00
 designated port        8002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

3130b (4)
 port id                8004                    state                  disabled
 designated root        8000.6ee683e351b8       path cost                  2
 designated bridge      8000.6ee683e351b8       message age timer          0.00
 designated port        8004                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

tun301 (3)
 port id                8003                    state                forwarding
 designated root        8000.6ee683e351b8       path cost                100
 designated bridge      8000.6ee683e351b8       message age timer          0.00
 designated port        8003                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags



mikle@LabHost:~$ sudo ip netns exec NS301 brctl showmacs br301 | grep no
port no mac addr                is local?       ageing timer
  1     36:d4:1d:c9:a8:73       no                38.66

3031 veth 链路已启用,bpdus 已通过,rootbridge 未收敛:

mikle@LabHost:~$ sudo ip netns exec NS300 ip link set 3031 up
mikle@LabHost:~$ sudo ip netns exec NS300 brctl showstp br300
br300
 bridge id              1000.4603771a8cf8
 designated root        1000.4603771a8cf8
 root port                 0                    path cost                  0
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            30.00                 bridge forward delay      30.00
 ageing time             300.00
 hello timer               1.50                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                  89.50
 flags


300b (1)
 port id                2001                    state                forwarding
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2001                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.50
 flags

3031 (2)
 port id                2002                    state                 listening
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2002                    forward delay timer       15.20
 designated cost           0                    hold timer                 0.50
 flags

3031b (4)
 port id                2004                    state                  disabled
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2004                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

======
3031 (2)
 port id                2002                    state                  learning
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2002                    forward delay timer       23.54
 designated cost           0                    hold timer                 0.50
 flags

sudo ip netns exec NS300 brctl showstp br300
br300
 bridge id              1000.4603771a8cf8
 designated root        1000.4603771a8cf8
 root port                 0                    path cost                  0
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            30.00                 bridge forward delay      30.00
 ageing time             300.00
 hello timer               1.60                 tcn timer                  0.00
 topology change timer    49.85                 gc timer                  43.60
 flags                  TOPOLOGY_CHANGE TOPOLOGY_CHANGE_DETECTED


300b (1)
 port id                2001                    state                forwarding
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2001                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.60
 flags

3031 (2)
 port id                2002                    state                forwarding
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.60
 flags

3031b (4)
 port id                2004                    state                  disabled
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2004                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

tun300 (3)
 port id                8003                    state                forwarding
 designated root        1000.4603771a8cf8       path cost                100
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        8003                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.60
 flags



sudo ip netns exec NS300 brctl showmacs br300 | grep no
port no mac addr                is local?       ageing timer
<... skippped>
  2     6e:e6:83:e3:51:b8       no                 0.77
  3     9c:b6:54:7c:dd:0d       no                22.82
  3     b4:b5:2f:61:d8:a1       no                22.93



sudo ip netns exec NS300 tcpdump -i 3031 -e  -lv -Q out stp
tcpdump: listening on 3031, link-type EN10MB (Ethernet), capture size 262144 bytes
03:09:26.757635 4a:db:50:ac:f2:bc (oui Unknown) > 01:80:c2:00:00:00 (oui Unknown), 802.3, length 38: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 1000.46:03:77:1a:8c:f8.2002, length 35
        message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 30.00s
        root-id 1000.46:03:77:1a:8c:f8, root-pathcost 0
03:09:28.741625 4a:db:50:ac:f2:bc (oui Unknown) > 01:80:c2:00:00:00 (oui Unknown), 802.3, length 38: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 1000.46:03:77:1a:8c:f8.2002, length 35
        message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 30.00s
        root-id 1000.46:03:77:1a:8c:f8, root-pathcost 0



sudo ip netns exec NS300 tcpdump -i 3031 -e  -lv -Q in stp
tcpdump: listening on 3031, link-type EN10MB (Ethernet), capture size 262144 bytes
03:09:42.757625 6e:e6:83:e3:51:b8 (oui Unknown) > 01:80:c2:00:00:00 (oui Unknown), 802.3, length 38: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.6e:e6:83:e3:51:b8.8002, length 35
        message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 30.00s
        root-id 8000.6e:e6:83:e3:51:b8, root-pathcost 0
03:09:44.741627 6e:e6:83:e3:51:b8 (oui Unknown) > 01:80:c2:00:00:00 (oui Unknown), 802.3, length 38: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.6e:e6:83:e3:51:b8.8002, length 35
        message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 30.00s
        root-id 8000.6e:e6:83:e3:51:b8, root-pathcost 0

mikle@LabHost:~$ sudo ip netns exec NS301 brctl showstp br301
br301
 bridge id              8000.6ee683e351b8
 designated root        8000.6ee683e351b8
 root port                 0                    path cost                  0
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            30.00                 bridge forward delay      30.00
 ageing time             300.00
 hello timer               0.79                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                  17.79
 flags
3130 (2)
 port id                8002                    state                forwarding
 designated root        8000.6ee683e351b8       path cost                  2
 designated bridge      8000.6ee683e351b8       message age timer          0.00
 designated port        8002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

3130b (4)
 port id                8004                    state                  disabled
 designated root        8000.6ee683e351b8       path cost                  2
 designated bridge      8000.6ee683e351b8       message age timer          0.00
 designated port        8004                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

300301 veth 链路已启用,100% cpu 负载,arp 已循环。

sudo ip -n NS300 link set 3031b up


sudo ip netns exec NS300 brctl showstp br300
br300
 bridge id              1000.4603771a8cf8
 designated root        1000.4603771a8cf8
 root port                 0                    path cost                  0
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            30.00                 bridge forward delay      30.00
 ageing time             300.00
 hello timer               1.34                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                  53.34
 flags

3031 (2)
 port id                2002                    state                forwarding
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.34
 flags

3031b (4)
 port id                2004                    state                 listening
 designated root        1000.4603771a8cf8       path cost                 50
 designated bridge      1000.4603771a8cf8       message age timer          0.00
 designated port        2004                    forward delay timer        4.10
 designated cost           0                    hold timer                 0.34
 flags

mikle@LabHost:~$ sudo ip netns exec NS301 brctl showstp br301
br301
 bridge id              8000.6ee683e351b8
 designated root        8000.6ee683e351b8
 root port                 0                    path cost                  0
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            30.00                 bridge forward delay      30.00
 ageing time             300.00
 hello timer               0.32                 tcn timer                  0.00
 topology change timer    37.72                 gc timer                   6.32
 flags                  TOPOLOGY_CHANGE TOPOLOGY_CHANGE_DETECTED


3130 (2)
 port id                8002                    state                forwarding
 designated root        8000.6ee683e351b8       path cost                  2
 designated bridge      8000.6ee683e351b8       message age timer          0.00
 designated port        8002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

3130b (4)
 port id                8004                    state                forwarding
 designated root        8000.6ee683e351b8       path cost                  2
 designated bridge      8000.6ee683e351b8       message age timer          0.00
 designated port        8004                    forward delay timer        0.00

答案1

我也遇到了这个问题,我深入研究了细节。

根本原因是,stp 消息从bridge_slaves 正确发送,但 rcv 例程仅限于第init_ns166net/llc/llc_input.c行(linux-source-5.15.0这是我的 ubunt jammy dist,但对于每个 dist 也是相同的)。

int llc_rcv(struct sk_buff *skb, struct net_device *dev,
        struct packet_type *pt, struct net_device *orig_dev)
{
    struct llc_sap *sap;
    struct llc_pdu_sn *pdu;
    int dest;
    int (*rcv)(struct sk_buff *, struct net_device *,
               struct packet_type *, struct net_device *);
    void (*sta_handler)(struct sk_buff *skb);
    void (*sap_handler)(struct llc_sap *sap, struct sk_buff *skb);

    if (!net_eq(dev_net(dev), &init_net))
            goto drop;
    ...
}

因此该丢弃拒绝处理 BPDU 消息,例如 config 和 tcn。

相关内容