[ovs-dev] [PATCH v6 02/18] lib/stp, rstp: Add unit more unit tests.

Daniele Venturino venturino.daniele at gmail.com
Tue Sep 9 10:28:59 UTC 2014


Acked-by: Daniele Venturino <daniele.venturino at m3s.it>

2014-08-21 1:57 GMT+02:00 Jarno Rajahalme <jrajahalme at nicira.com>:

> Existing STP and RSTP test cases only test the protocols with test
> utilities.  These tests test them as part of OVS using the
> netdev-dummy device.
>
> Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
> ---
>  ofproto/ofproto-dpif.c |   16 ++++----
>  tests/rstp.at          |   86 +++++++++++++++++++++++++++++++++++++++++
>  tests/stp.at           |  100
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 194 insertions(+), 8 deletions(-)
>
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index ace96b1..4da16f4 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -2026,10 +2026,10 @@ update_rstp_port_state(struct ofport_dpif *ofport)
>          enum ofputil_port_state of_state;
>          bool fwd_change;
>
> -        VLOG_DBG_RL(&rl, "port %s: RSTP state changed from %s to %s",
> -                netdev_get_name(ofport->up.netdev),
> -                rstp_state_name(ofport->rstp_state),
> -                rstp_state_name(state));
> +        VLOG_DBG("port %s: RSTP state changed from %s to %s",
> +                 netdev_get_name(ofport->up.netdev),
> +                 rstp_state_name(ofport->rstp_state),
> +                 rstp_state_name(state));
>          if (rstp_learn_in_state(ofport->rstp_state)
>                  != rstp_learn_in_state(state)) {
>              /* xxx Learning action flows should also be flushed. */
> @@ -2158,10 +2158,10 @@ update_stp_port_state(struct ofport_dpif *ofport)
>          enum ofputil_port_state of_state;
>          bool fwd_change;
>
> -        VLOG_DBG_RL(&rl, "port %s: STP state changed from %s to %s",
> -                    netdev_get_name(ofport->up.netdev),
> -                    stp_state_name(ofport->stp_state),
> -                    stp_state_name(state));
> +        VLOG_DBG("port %s: STP state changed from %s to %s",
> +                 netdev_get_name(ofport->up.netdev),
> +                 stp_state_name(ofport->stp_state),
> +                 stp_state_name(state));
>          if (stp_learn_in_state(ofport->stp_state)
>                  != stp_learn_in_state(state)) {
>              /* xxx Learning action flows should also be flushed. */
> diff --git a/tests/rstp.at b/tests/rstp.at
> index 0818332..be3490d 100644
> --- a/tests/rstp.at
> +++ b/tests/rstp.at
> @@ -147,3 +147,89 @@ check 2 = F:400000 Di F F F F F F
>  ])
>  AT_CHECK([ovstest test-rstp test-rstp-ieee802.1d-2004-fig17.7], [0], [])
>  AT_CLEANUP
> +
> +# Strips out uninteresting parts of flow output, as well as parts
> +# that vary from one run to another (e.g., timing and bond actions).
> +m4_define([STRIP_USED], [[sed '
> +    s/used:[0-9]*\.[0-9]*/used:0.0/
> +    s/duration=[0-9.]*s*/duration=Xs/
> +    s/idle_age=[0-9]*,/idle_age=X,/
> +']])
> +m4_define([FILTER_STP_TOPOLOGY], [[
> +grep 'STP state changed' | sed '
> +    s/.*ofproto_dpif|.*|//
> +']])
> +
> +AT_SETUP([RSTP - dummy interface])
> +# Create br0 with interfaces p1 and p7
> +#    and br1 with interfaces p2 and p8
> +# with p1 and p2 connected via unix domain socket
> +OVS_VSWITCHD_START(
> +  [set port br0 other_config:rstp-enable=false -- \
> +   set bridge br0 rstp_enable=true -- \
> +   add-br br1 -- \
> +   set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
> +   set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
> +                  fail-mode=secure -- \
> +   set port br1 other_config:rstp-enable=false -- \
> +   set bridge br1 rstp_enable=true --])
> +
> +AT_CHECK([ovs-vsctl add-port br0 p1 -- \
> +   set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock
> ofport_request=1 -- \
> +   set port p1 other_config:rstp-enable=true -- \
> +])
> +AT_CHECK([ovs-vsctl add-port br0 p7 -- \
> +   set interface p7 ofport_request=7 type=dummy -- \
> +   set port p7 other_config:rstp-enable=false -- \
> +])
> +AT_CHECK([ovs-vsctl add-port br1 p2 -- \
> +   set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock
> ofport_request=2 -- \
> +   set port p2 other_config:rstp-enable=true -- \
> +])
> +AT_CHECK([ovs-vsctl add-port br1 p8 -- \
> +   set interface p8 ofport_request=8 type=dummy -- \
> +   set port p8 other_config:rstp-enable=false -- \
> +])
> +
> +ovs-appctl time/stop
> +
> +AT_CHECK([ovs-ofctl add-flow br0 "in_port=7 icmp actions=1"])
> +AT_CHECK([ovs-ofctl add-flow br0 "in_port=1 icmp actions=7"])
> +AT_CHECK([ovs-ofctl add-flow br1 "in_port=8 icmp actions=2"])
> +AT_CHECK([ovs-ofctl add-flow br1 "in_port=2 icmp actions=8"])
> +
> +AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl
> +port p1: RSTP state changed from Disabled to Discarding
> +port p2: RSTP state changed from Disabled to Discarding
> +])
> +
> +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
> +RSTP not in forwarding state, skipping output
> +])
> +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy
> 'in_port(8),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'
> | grep STP], [0], [dnl
> +RSTP not in forwarding state, skipping output
> +])
> +
> +#
> +# RSTP needs link to be in admin-state up, netdev-dummy is by default down
> +#
> +AT_CHECK([ovs-appctl netdev-dummy/set-admin-state up], [], [dnl
> +OK
> +])
> +
> +AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl
> +port p1: RSTP state changed from Disabled to Discarding
> +port p2: RSTP state changed from Disabled to Discarding
> +port p2: RSTP state changed from Discarding to Forwarding
> +port p1: RSTP state changed from Discarding 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
> +Datapath actions: 1
> +])
> +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy
> 'in_port(8),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'
> | grep Datapath], [0], [dnl
> +Datapath actions: 2
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> diff --git a/tests/stp.at b/tests/stp.at
> index 20c231f..c01ad81 100644
> --- a/tests/stp.at
> +++ b/tests/stp.at
> @@ -364,3 +364,103 @@ stp|INFO|stp111: detected topology change.
>  stp|INFO|stp333: detected topology change.
>  ])
>  AT_CLEANUP
> +
> +# Strips out uninteresting parts of flow output, as well as parts
> +# that vary from one run to another (e.g., timing and bond actions).
> +m4_define([STRIP_USED], [[sed '
> +    s/used:[0-9]*\.[0-9]*/used:0.0/
> +    s/duration=[0-9.]*s*/duration=Xs/
> +    s/idle_age=[0-9]*,/idle_age=X,/
> +']])
> +m4_define([FILTER_STP_TOPOLOGY], [[
> +grep 'STP state change' | sed '
> +    s/.*ofproto_dpif|.*|//
> +']])
> +
> +AT_SETUP([STP - dummy interface])
> +# Create br0 with interfaces p1 and p7
> +#    and br1 with interfaces p2 and p8
> +# with p1 and p2 connected via unix domain socket
> +OVS_VSWITCHD_START(
> +  [set port br0 other_config:stp-enable=false -- \
> +   set bridge br0 stp_enable=true -- \
> +   add-br br1 -- \
> +   set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
> +   set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
> +                  fail-mode=secure -- \
> +   set port br1 other_config:stp-enable=false -- \
> +   set bridge br1 stp_enable=true --])
> +
> +AT_CHECK([ovs-appctl vlog/set ofproto_dpif:dbg])
> +
> +AT_CHECK([ovs-vsctl add-port br0 p1 -- \
> +   set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock
> ofport_request=1 -- \
> +   set port p1 other_config:stp-enable=true -- \
> +])
> +AT_CHECK([ovs-vsctl add-port br0 p7 -- \
> +   set interface p7 ofport_request=7 type=dummy -- \
> +   set port p7 other_config:stp-enable=false -- \
> +])
> +AT_CHECK([ovs-vsctl add-port br1 p2 -- \
> +   set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock
> ofport_request=2 -- \
> +   set port p2 other_config:stp-enable=true -- \
> +])
> +AT_CHECK([ovs-vsctl add-port br1 p8 -- \
> +   set interface p8 ofport_request=8 type=dummy -- \
> +   set port p8 other_config:stp-enable=false -- \
> +])
> +
> +ovs-appctl time/stop
> +
> +AT_CHECK([ovs-ofctl add-flow br0 "in_port=7 icmp actions=1"])
> +AT_CHECK([ovs-ofctl add-flow br0 "in_port=1 icmp actions=7"])
> +AT_CHECK([ovs-ofctl add-flow br1 "in_port=8 icmp actions=2"])
> +AT_CHECK([ovs-ofctl add-flow br1 "in_port=2 icmp actions=8"])
> +
> +# 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 p1: STP state changed from disabled to listening
> +port p2: 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
> +STP not in forwarding state, skipping output
> +])
> +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy
> 'in_port(8),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'
> | grep STP], [0], [dnl
> +STP not in forwarding state, skipping output
> +])
> +
> +# 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
> +
> +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
> +])
> +
> +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
> +Datapath actions: 1
> +])
> +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy
> 'in_port(8),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'
> | grep Datapath], [0], [dnl
> +Datapath actions: 2
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list