aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/unittest/tcp_test.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-10-19 17:49:00 -0700
committerFlorin Coras <florin.coras@gmail.com>2018-10-21 19:26:22 +0000
commit9f9e969f149e40044fee9d2e47b7dd96f3ae4dfa (patch)
tree076e54c10681d87216b73b101e4ec569f8c41ada /src/plugins/unittest/tcp_test.c
parenta9ded38b1f2d852ff231a305805e5f5c801b9c76 (diff)
tcp: count first lost hole (VPP-1465)
Change-Id: I3ac136e2a10796d8fa86ddb6f0d6cabe5fa749f8 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/plugins/unittest/tcp_test.c')
-rw-r--r--src/plugins/unittest/tcp_test.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/plugins/unittest/tcp_test.c b/src/plugins/unittest/tcp_test.c
index 608f1efc53d..d06578771c0 100644
--- a/src/plugins/unittest/tcp_test.c
+++ b/src/plugins/unittest/tcp_test.c
@@ -129,7 +129,7 @@ tcp_test_sack_rx (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST ((sb->last_sacked_bytes == 400),
"last sacked bytes %d", sb->last_sacked_bytes);
TCP_TEST ((sb->high_sacked == 900), "high sacked %u", sb->high_sacked);
- TCP_TEST ((sb->lost_bytes == 200), "lost bytes %u", sb->lost_bytes);
+ TCP_TEST ((sb->lost_bytes == 300), "lost bytes %u", sb->lost_bytes);
/*
* Inject odd blocks
@@ -276,7 +276,7 @@ tcp_test_sack_rx (vlib_main_t * vm, unformat_input_t * input)
"\n%U", format_tcp_scoreboard, sb, tc);
TCP_TEST ((pool_elts (sb->holes) == 5),
"scoreboard has %d elements", pool_elts (sb->holes));
- TCP_TEST ((sb->lost_bytes == 200), "lost bytes %u", sb->lost_bytes);
+ TCP_TEST ((sb->lost_bytes == 300), "lost bytes %u", sb->lost_bytes);
tcp_rcv_sacks (tc, 950);
@@ -368,7 +368,7 @@ tcp_test_sack_rx (vlib_main_t * vm, unformat_input_t * input)
sb->last_sacked_bytes);
TCP_TEST ((sb->last_bytes_delivered == 0), "last bytes delivered %d",
sb->last_bytes_delivered);
- TCP_TEST ((sb->lost_bytes == 200), "lost bytes %u", sb->lost_bytes);
+ TCP_TEST ((sb->lost_bytes == 300), "lost bytes %u", sb->lost_bytes);
tc->snd_una = 100;
tcp_rcv_sacks (tc, 200);
@@ -410,6 +410,32 @@ tcp_test_sack_rx (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST ((sb->last_bytes_delivered == 0), "last bytes delivered %d",
sb->last_bytes_delivered);
TCP_TEST ((sb->snd_una_adv == 0), "snd_una_adv %u", sb->snd_una_adv);
+
+ /*
+ * Add [1200, 1500] and test that [1000, 1200] is lost (bytes condition)
+ * snd_una = 1000 and snd_una_max = 1600
+ */
+ tc->snd_una = 1000;
+ tc->snd_una_max = 1600;
+ vec_reset_length (tc->rcv_opts.sacks);
+ block.start = 1200;
+ block.end = 1500;
+ vec_add1 (tc->rcv_opts.sacks, block);
+ tc->rcv_opts.n_sack_blocks = vec_len (tc->rcv_opts.sacks);
+ tcp_rcv_sacks (tc, 1000);
+ if (verbose)
+ vlib_cli_output (vm, "\nacked [1200, 1500] test first hole is lost:\n%U",
+ format_tcp_scoreboard, sb, tc);
+ TCP_TEST ((pool_elts (sb->holes) == 2), "scoreboard has %d elements",
+ pool_elts (sb->holes));
+ TCP_TEST ((sb->sacked_bytes == 300), "sacked bytes %d", sb->sacked_bytes);
+ TCP_TEST ((sb->last_sacked_bytes == 300), "last sacked bytes %d",
+ sb->last_sacked_bytes);
+ TCP_TEST ((sb->last_bytes_delivered == 0), "last bytes delivered %d",
+ sb->last_bytes_delivered);
+ TCP_TEST ((sb->lost_bytes == 200), "lost bytes %u", sb->lost_bytes);
+ TCP_TEST ((sb->snd_una_adv == 0), "snd_una_adv %u", sb->snd_una_adv);
+
return 0;
}