@@ -11,14 +11,15 @@ sub my_test {
1111 my $in_port = $$options_ref {' port_base' };
1212 my $out_port = $in_port + 1;
1313
14- my $test_pkt = get_default_black_box_pkt( $in_port , $out_port );
14+ my $test_pkt = get_default_black_box_pkt( $in_port , $out_port , $$options_ref { ' pkt_len ' } );
1515
1616 my $max_idle = 0x0; # second before flow expiration -- never time out
1717 my $wildcards = 0x0; # exact match
1818 # Create a flow mod without expiry
1919 my $flags = 0x0; # don't send flow expiry
2020 my $flow_mod_pkt =
2121 create_flow_mod_from_udp( $ofp , $test_pkt , $in_port , $out_port , $max_idle , $flags , $wildcards );
22+ print " send flow mode without expiry\n " ;
2223 print $sock $flow_mod_pkt ;
2324
2425 # Delete the flow and verify that we don't see an expiry
@@ -33,13 +34,14 @@ sub my_test {
3334 exit 1;
3435 }
3536
36- # Create a flow mod with expiry
37+ # Create a flow mod with expiry
3738 $flags = $enums {' OFPFF_SEND_FLOW_REM' }; # want flow expiry
3839 $flow_mod_pkt =
3940 create_flow_mod_from_udp( $ofp , $test_pkt , $in_port , $out_port , $max_idle , $flags , $wildcards );
41+ print " send flow mode with expiry\n " ;
4042 print $sock $flow_mod_pkt ;
4143
42- # Delete the flow and verify that we don't see an expiry
44+ # Delete the flow and verify that we do see an expiry
4345 $flags = 0x0; # Reset the flags to zero. Should not matter as it
4446 # should only depend on the flags when the flow was installed.
4547 $flow_mod_pkt =
@@ -51,6 +53,51 @@ sub my_test {
5153 my $pkt_total = 0;
5254 wait_for_flow_expired( $ofp , $sock , $options_ref , $pkt_len , $pkt_total );
5355
56+ # Redo the same test with a few packets to make sure stats are correct
57+ # Jean II
58+
59+ # Create a flow mod with expiry
60+ $flags = $enums {' OFPFF_SEND_FLOW_REM' }; # want flow expiry
61+ $flow_mod_pkt =
62+ create_flow_mod_from_udp( $ofp , $test_pkt , $in_port , $out_port , $max_idle , $flags , $wildcards );
63+ print " send flow mode with expiry and with 3 packets\n " ;
64+ print $sock $flow_mod_pkt ;
65+
66+ # Give OF switch time to process the flow mod
67+ usleep($$options_ref {' send_delay' });
68+ usleep($$options_ref {' send_delay' });
69+
70+ # Send 3 packets, because first packet can be "special" - Jean II
71+ # We should be using $options{'pkt_total'}, but that is stuck at 1
72+ nftest_send(" eth" . ($in_port ), $test_pkt -> packed);
73+ nftest_send(" eth" . ($in_port ), $test_pkt -> packed);
74+ nftest_send(" eth" . ($in_port ), $test_pkt -> packed);
75+
76+ # expect 3 packets
77+ print " expect 3 packets\n " ;
78+ nftest_expect(" eth" . ($out_port ), $test_pkt -> packed);
79+ nftest_expect(" eth" . ($out_port ), $test_pkt -> packed);
80+ nftest_expect(" eth" . ($out_port ), $test_pkt -> packed);
81+
82+ # Wait for stats to refresh
83+ sleep ($$options_ref {' max_idle' });
84+ # dpctl_show_flows($options_ref);
85+
86+ # Delete the flow and verify that we do see an expiry
87+ $flags = 0x0; # Reset the flags to zero. Should not matter as it
88+ # should only depend on the flags when the flow was installed.
89+ $flow_mod_pkt =
90+ create_flow_mod_from_udp_action( $ofp , $test_pkt , $in_port , $out_port , $max_idle ,
91+ $flags , $wildcards , " OFPFC_DELETE" );
92+ print $sock $flow_mod_pkt ;
93+
94+ # And now check the stats in the flow removed message...
95+ my $pkt_len = $$options_ref {' pkt_len' };
96+ my $pkt_total = 3;
97+ wait_for_flow_expired( $ofp , $sock , $options_ref , $pkt_len , $pkt_total );
98+
99+
100+
54101}
55102
56103run_black_box_test( \&my_test, \@ARGV );
0 commit comments