From: Semir Sionek Date: Tue, 24 Jun 2025 12:19:04 +0000 (+0000) Subject: hsa: fix echo-bytes echo client runs over UDP X-Git-Tag: v26.02-rc0~212 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F43285%2F3;p=vpp.git hsa: fix echo-bytes echo client runs over UDP Previously counting received bytes didn't take into account the datagram header size, leading to a bigger than expected size and an overflow of es->bytes_to_receive. Type: fix Change-Id: If31d4ed5f989645388dbf9c1b9829c6f2e4e8c62 Signed-off-by: Semir Sionek --- diff --git a/extras/hs-test/echo_test.go b/extras/hs-test/echo_test.go index b753121f401..53f83542bc3 100644 --- a/extras/hs-test/echo_test.go +++ b/extras/hs-test/echo_test.go @@ -8,7 +8,7 @@ import ( ) func init() { - RegisterVethTests(EchoBuiltinTest, EchoBuiltinBandwidthTest) + RegisterVethTests(EchoBuiltinTest, EchoBuiltinBandwidthTest, EchoBuiltinEchobytesTest) RegisterSoloVethTests(TcpWithLossTest) RegisterVeth6Tests(TcpWithLoss6Test) } @@ -57,6 +57,20 @@ func EchoBuiltinBandwidthTest(s *VethsSuite) { } } +func EchoBuiltinEchobytesTest(s *VethsSuite) { + serverVpp := s.Containers.ServerVpp.VppInstance + + serverVpp.Vppctl("test echo server " + + " uri udp://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1) + + clientVpp := s.Containers.ClientVpp.VppInstance + + o := clientVpp.Vppctl("test echo client echo-bytes verbose uri" + + " udp://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1) + s.Log(o) + s.AssertNotContains(o, "test echo clients: failed: timeout with 1 sessions") +} + func TcpWithLossTest(s *VethsSuite) { serverVpp := s.Containers.ServerVpp.VppInstance diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c index 54e806a9ba4..843ce40a4d3 100644 --- a/src/plugins/hs_apps/echo_client.c +++ b/src/plugins/hs_apps/echo_client.c @@ -190,6 +190,7 @@ receive_data_chunk (ec_worker_t *wrk, ec_session_t *es) { ec_main_t *ecm = &ec_main; svm_fifo_t *rx_fifo = es->rx_fifo; + session_dgram_pre_hdr_t ph; int n_read, i; if (ecm->cfg.test_bytes) @@ -199,8 +200,23 @@ receive_data_chunk (ec_worker_t *wrk, ec_session_t *es) } else { - n_read = svm_fifo_max_dequeue_cons (rx_fifo); - svm_fifo_dequeue_drop (rx_fifo, n_read); + if (!es->is_dgram) + { + n_read = svm_fifo_max_dequeue_cons (rx_fifo); + svm_fifo_dequeue_drop (rx_fifo, n_read); + } + else + { + n_read = svm_fifo_max_dequeue_cons (rx_fifo); + if (n_read <= sizeof (session_dgram_hdr_t)) + return; + svm_fifo_peek (rx_fifo, 0, sizeof (ph), (u8 *) &ph); + if (n_read < (ph.data_length + SESSION_CONN_HDR_LEN)) + return; + svm_fifo_dequeue_drop (rx_fifo, + ph.data_length + SESSION_CONN_HDR_LEN); + n_read = ph.data_length; + } } if (n_read > 0) @@ -233,7 +249,14 @@ receive_data_chunk (ec_worker_t *wrk, ec_session_t *es) } } } - ASSERT (n_read <= es->bytes_to_receive); + if (n_read > es->bytes_to_receive) + { + ec_err ("expected %llu, received %llu bytes!", + es->bytes_received + es->bytes_to_receive, + es->bytes_received + n_read); + ecm->test_failed = 1; + es->bytes_to_receive = n_read; + } es->bytes_to_receive -= n_read; es->bytes_received += n_read; }