From 27e6742eaa74b8e4096031bca8b809a42d1efe2e Mon Sep 17 00:00:00 2001 From: Glen Gibb Date: Wed, 10 Mar 2010 17:01:39 -0800 Subject: [PATCH] regress: flow expiry with multiple packets An optimization done by some switches is to push an exact-match entry into the flow tables when a wildcard flow has a match. Enhance the test_delete_send_flow_exp test to test a flow with multiple packets to verify that the statistics for a wildcard flow include any special hidden exact-match flows. Change submitted by: Jean Tourrilhes --- .../regress/test_delete_send_flow_exp/run.pl | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/regress/projects/black_box/regress/test_delete_send_flow_exp/run.pl b/regress/projects/black_box/regress/test_delete_send_flow_exp/run.pl index 047a32b..6e093fc 100755 --- a/regress/projects/black_box/regress/test_delete_send_flow_exp/run.pl +++ b/regress/projects/black_box/regress/test_delete_send_flow_exp/run.pl @@ -11,7 +11,7 @@ sub my_test { my $in_port = $$options_ref{'port_base'}; my $out_port = $in_port + 1; - my $test_pkt = get_default_black_box_pkt( $in_port, $out_port); + my $test_pkt = get_default_black_box_pkt( $in_port, $out_port, $$options_ref{'pkt_len'} ); my $max_idle = 0x0; # second before flow expiration -- never time out my $wildcards = 0x0; # exact match @@ -19,6 +19,7 @@ sub my_test { my $flags = 0x0; # don't send flow expiry my $flow_mod_pkt = create_flow_mod_from_udp( $ofp, $test_pkt, $in_port, $out_port, $max_idle, $flags, $wildcards ); + print "send flow mode without expiry\n"; print $sock $flow_mod_pkt; # Delete the flow and verify that we don't see an expiry @@ -33,13 +34,14 @@ sub my_test { exit 1; } - # Create a flow mod with expiry + # Create a flow mod with expiry $flags = $enums{'OFPFF_SEND_FLOW_REM'}; # want flow expiry $flow_mod_pkt = create_flow_mod_from_udp( $ofp, $test_pkt, $in_port, $out_port, $max_idle, $flags, $wildcards ); + print "send flow mode with expiry\n"; print $sock $flow_mod_pkt; - # Delete the flow and verify that we don't see an expiry + # Delete the flow and verify that we do see an expiry $flags = 0x0; # Reset the flags to zero. Should not matter as it # should only depend on the flags when the flow was installed. $flow_mod_pkt = @@ -51,6 +53,51 @@ sub my_test { my $pkt_total = 0; wait_for_flow_expired( $ofp, $sock, $options_ref, $pkt_len, $pkt_total ); + # Redo the same test with a few packets to make sure stats are correct + # Jean II + + # Create a flow mod with expiry + $flags = $enums{'OFPFF_SEND_FLOW_REM'}; # want flow expiry + $flow_mod_pkt = + create_flow_mod_from_udp( $ofp, $test_pkt, $in_port, $out_port, $max_idle, $flags, $wildcards ); + print "send flow mode with expiry and with 3 packets\n"; + print $sock $flow_mod_pkt; + + # Give OF switch time to process the flow mod + usleep($$options_ref{'send_delay'}); + usleep($$options_ref{'send_delay'}); + + # Send 3 packets, because first packet can be "special" - Jean II + # We should be using $options{'pkt_total'}, but that is stuck at 1 + nftest_send("eth" . ($in_port), $test_pkt->packed); + nftest_send("eth" . ($in_port), $test_pkt->packed); + nftest_send("eth" . ($in_port), $test_pkt->packed); + + # expect 3 packets + print "expect 3 packets\n"; + nftest_expect("eth" . ($out_port), $test_pkt->packed); + nftest_expect("eth" . ($out_port), $test_pkt->packed); + nftest_expect("eth" . ($out_port), $test_pkt->packed); + + # Wait for stats to refresh + sleep($$options_ref{'max_idle'}); + #dpctl_show_flows($options_ref); + + # Delete the flow and verify that we do see an expiry + $flags = 0x0; # Reset the flags to zero. Should not matter as it + # should only depend on the flags when the flow was installed. + $flow_mod_pkt = + create_flow_mod_from_udp_action( $ofp, $test_pkt, $in_port, $out_port, $max_idle, + $flags, $wildcards, "OFPFC_DELETE" ); + print $sock $flow_mod_pkt; + + # And now check the stats in the flow removed message... + my $pkt_len = $$options_ref{'pkt_len'}; + my $pkt_total = 3; + wait_for_flow_expired( $ofp, $sock, $options_ref, $pkt_len, $pkt_total ); + + + } run_black_box_test( \&my_test, \@ARGV );