This patch makes the stp tests more stable and adds the test for fdb/mdb flushing when topology is changed.
Signed-off-by: nickcooper-zhangtonghao <n...@opencloud.tech> --- tests/stp.at | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 154 insertions(+), 9 deletions(-) diff --git a/tests/stp.at b/tests/stp.at index 8b64218..20f7940 100644 --- a/tests/stp.at +++ b/tests/stp.at @@ -374,7 +374,12 @@ m4_define([STRIP_USED], [[sed ' ']]) m4_define([FILTER_STP_TOPOLOGY], [[ grep 'STP state change' | sed ' - s/.*ofproto_dpif|.*|// + s/.*ofproto_dpif|.*|port .*:/port <>:/ +']]) + +m4_define([FILTER_STP_TOPOLOGY_FORWARDING], [[ +grep 'learning to forwarding' | sed ' + s/.*ofproto_dpif|.*|port .*:/port <>:/ ']]) AT_SETUP([STP - dummy interface]) @@ -423,8 +428,8 @@ ovs-appctl time/warp 3000 ovs-appctl time/warp 3000 AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl -port p1: STP state changed from disabled to listening -port p2: STP state changed from disabled to listening +port <>: STP state changed from disabled to listening +port <>: STP state changed from disabled to listening ]) AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(7),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' | grep STP], [0], [dnl @@ -445,14 +450,15 @@ ovs-appctl time/warp 3000 ovs-appctl time/warp 3000 ovs-appctl time/warp 3000 ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl -port p1: STP state changed from disabled to listening -port p2: STP state changed from disabled to listening -port p1: STP state changed from listening to learning -port p2: STP state changed from listening to learning -port p1: STP state changed from learning to forwarding -port p2: STP state changed from learning to forwarding +port <>: STP state changed from disabled to listening +port <>: STP state changed from disabled to listening +port <>: STP state changed from listening to learning +port <>: STP state changed from listening to learning +port <>: STP state changed from learning to forwarding +port <>: STP state changed from learning to forwarding ]) AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(7),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' | grep Datapath], [0], [dnl @@ -462,5 +468,144 @@ AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(8),eth(src=50:54:00:00:00: Datapath actions: 2 ]) +AT_CLEANUP + +AT_SETUP([STP - flush the fdb and mdb when topology changed]) +OVS_VSWITCHD_START([]) + +# setting as below, the br0 will be root bridge and p5 will be blocked. +AT_CHECK([ + ovs-vsctl -- \ + set port br0 other_config:stp-enable=false -- \ + set bridge br0 datapath-type=dummy -- \ + set bridge br0 stp_enable=true mcast_snooping_enable=true \ + other-config:hwaddr=aa:66:aa:66:00:00 -- \ + add-br br1 -- \ + set port br1 other_config:stp-enable=false -- \ + set bridge br1 datapath-type=dummy -- \ + set bridge br1 stp_enable=true mcast_snooping_enable=true \ + other-config:hwaddr=aa:66:aa:66:00:01 -- \ + add-br br2 -- \ + set port br2 other_config:stp-enable=false -- \ + set bridge br2 datapath-type=dummy -- \ + set bridge br2 stp_enable=true mcast_snooping_enable=true \ + other-config:hwaddr=aa:66:aa:66:00:02 +], [0]) + +AT_CHECK([ovs-appctl vlog/set ofproto_dpif:dbg]) + +AT_CHECK([ovs-ofctl add-flow br0 action=normal]) +AT_CHECK([ovs-ofctl add-flow br1 action=normal]) +AT_CHECK([ovs-ofctl add-flow br2 action=normal]) + +AT_CHECK([ + ovs-vsctl add-port br0 p1 -- \ + set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p1.sock ofport_request=1 + ovs-vsctl add-port br0 p2 -- \ + set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p6.sock ofport_request=2 + ovs-vsctl add-port br1 p3 -- \ + set interface p3 type=dummy options:stream=unix:$OVS_RUNDIR/p1.sock ofport_request=3 + ovs-vsctl add-port br1 p4 -- \ + set interface p4 type=dummy options:pstream=punix:$OVS_RUNDIR/p4.sock ofport_request=4 + ovs-vsctl add-port br2 p5 -- \ + set interface p5 type=dummy options:stream=unix:$OVS_RUNDIR/p4.sock ofport_request=5 + ovs-vsctl add-port br2 p6 -- \ + set interface p6 type=dummy options:pstream=punix:$OVS_RUNDIR/p6.sock ofport_request=6 +], [0]) + + +ovs-appctl time/stop + +# give time for STP to move initially +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 + +AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl +port <>: STP state changed from disabled to listening +port <>: STP state changed from disabled to listening +port <>: STP state changed from disabled to listening +port <>: STP state changed from disabled to listening +port <>: STP state changed from disabled to listening +port <>: STP state changed from disabled to listening +]) + +# give time for STP to synchronize +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 + +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 + +AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY_FORWARDING], [0], [dnl +port <>: STP state changed from learning to forwarding +port <>: STP state changed from learning to forwarding +port <>: STP state changed from learning to forwarding +port <>: STP state changed from learning to forwarding +port <>: STP state changed from learning to forwarding +]) + +# root bridge sends query packet +# we don't want to lose that message, so send it twice +AT_CHECK([ovs-appctl netdev-dummy/receive br0 \ + '01005E010101000C29A027D18100000108004500001C000100004002CBCBAC102201E00101011114EEEB00000000']) + +ovs-appctl time/warp 1000 +AT_CHECK([ovs-appctl netdev-dummy/receive br0 \ + '01005E010101000C29A027D18100000108004500001C000100004002CBCBAC102201E00101011114EEEB00000000']) + +OVS_WAIT_UNTIL([ovs-appctl fdb/show br0 | grep '00:0c:29:a0:27:d1']) +OVS_WAIT_UNTIL([ovs-appctl fdb/show br1 | grep '00:0c:29:a0:27:d1']) +OVS_WAIT_UNTIL([ovs-appctl fdb/show br2 | grep '00:0c:29:a0:27:d1']) + +OVS_WAIT_UNTIL([ovs-appctl mdb/show br0 | grep 'querier']) +OVS_WAIT_UNTIL([ovs-appctl mdb/show br1 | grep 'querier']) +OVS_WAIT_UNTIL([ovs-appctl mdb/show br2 | grep 'querier']) + +# del p2 on the br0, the topology will be changed +AT_CHECK([ovs-vsctl del-port br0 p2]) + +# give time for STP to synchronize +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 + +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 + +ovs-appctl time/warp 3000 +ovs-appctl time/warp 3000 + +# check fdb and mdb +AT_CHECK([ovs-appctl fdb/show br0], [0], [dnl + port VLAN MAC Age +]) +AT_CHECK([ovs-appctl fdb/show br1], [0], [dnl + port VLAN MAC Age +]) +AT_CHECK([ovs-appctl fdb/show br2], [0], [dnl + port VLAN MAC Age +]) + +AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl + port VLAN GROUP Age +]) +AT_CHECK([ovs-appctl mdb/show br1], [0], [dnl + port VLAN GROUP Age +]) +AT_CHECK([ovs-appctl mdb/show br2], [0], [dnl + port VLAN GROUP Age +]) + OVS_VSWITCHD_STOP AT_CLEANUP -- 1.8.3.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev