mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
selftests/bpf: Fix total_bytes in msg_loop_rx in test_sockmap
[ Upstream commit 523dffccbadea0cfd65f1ff04944b864c558c4a8 ] total_bytes in msg_loop_rx should also take push into account, otherwise total_bytes will be a smaller value, which makes the msg_loop_rx end early. Besides, total_bytes has already taken pop into account, so we don't need to subtract some bytes from iov_buf in sendmsg_test. The additional subtraction may make total_bytes a negative number, and msg_loop_rx will just end without checking anything. Fixes:18d4e900a4("bpf: Selftests, improve test_sockmap total bytes counter") Fixes:d69672147f("selftests, bpf: Add one test for sockmap with strparser") Signed-off-by: Zijian Zhang <zijianzhang@bytedance.com> Reviewed-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/r/20241106222520.527076-4-zijianzhang@bytedance.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0bff469c83
commit
4a9eebcee4
@@ -605,8 +605,8 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
|
|||||||
}
|
}
|
||||||
clock_gettime(CLOCK_MONOTONIC, &s->end);
|
clock_gettime(CLOCK_MONOTONIC, &s->end);
|
||||||
} else {
|
} else {
|
||||||
|
float total_bytes, txmsg_pop_total, txmsg_push_total;
|
||||||
int slct, recvp = 0, recv, max_fd = fd;
|
int slct, recvp = 0, recv, max_fd = fd;
|
||||||
float total_bytes, txmsg_pop_total;
|
|
||||||
int fd_flags = O_NONBLOCK;
|
int fd_flags = O_NONBLOCK;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
unsigned char k = 0;
|
unsigned char k = 0;
|
||||||
@@ -627,10 +627,14 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
|
|||||||
total_bytes = (float)iov_length * (float)cnt;
|
total_bytes = (float)iov_length * (float)cnt;
|
||||||
if (!opt->sendpage)
|
if (!opt->sendpage)
|
||||||
total_bytes *= (float)iov_count;
|
total_bytes *= (float)iov_count;
|
||||||
if (txmsg_apply)
|
if (txmsg_apply) {
|
||||||
|
txmsg_push_total = txmsg_end_push * (total_bytes / txmsg_apply);
|
||||||
txmsg_pop_total = txmsg_pop * (total_bytes / txmsg_apply);
|
txmsg_pop_total = txmsg_pop * (total_bytes / txmsg_apply);
|
||||||
else
|
} else {
|
||||||
|
txmsg_push_total = txmsg_end_push * cnt;
|
||||||
txmsg_pop_total = txmsg_pop * cnt;
|
txmsg_pop_total = txmsg_pop * cnt;
|
||||||
|
}
|
||||||
|
total_bytes += txmsg_push_total;
|
||||||
total_bytes -= txmsg_pop_total;
|
total_bytes -= txmsg_pop_total;
|
||||||
err = clock_gettime(CLOCK_MONOTONIC, &s->start);
|
err = clock_gettime(CLOCK_MONOTONIC, &s->start);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@@ -799,8 +803,6 @@ static int sendmsg_test(struct sockmap_options *opt)
|
|||||||
|
|
||||||
rxpid = fork();
|
rxpid = fork();
|
||||||
if (rxpid == 0) {
|
if (rxpid == 0) {
|
||||||
if (txmsg_pop || txmsg_start_pop)
|
|
||||||
iov_buf -= (txmsg_pop - txmsg_start_pop + 1);
|
|
||||||
if (opt->drop_expected || txmsg_ktls_skb_drop)
|
if (opt->drop_expected || txmsg_ktls_skb_drop)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user