diff options
author | Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> | 2018-05-31 00:42:39 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-06-02 00:13:56 -0400 |
commit | d825e12f084650649b61209d0cd514c0e57bb0de (patch) | |
tree | 6244d255ba0540e1c60e9f0aa4ce1e725a08648f /tools | |
parent | a009f1f396d04a700971586ce8a142ea606cbb61 (diff) |
selftests/bpf: test_sockmap, fix data verification
When data verification is enabled, some tests fail because verification is done
incorrectly. Following changes fix it.
- Identify the size of data block to be verified
- Reset verification counter when data block size is reached
- Fixed the value printed in case of verfication failure
Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/test_sockmap.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index 5cd0550af595..2bc70e1ab2eb 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c | |||
@@ -337,8 +337,15 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, | |||
337 | int fd_flags = O_NONBLOCK; | 337 | int fd_flags = O_NONBLOCK; |
338 | struct timeval timeout; | 338 | struct timeval timeout; |
339 | float total_bytes; | 339 | float total_bytes; |
340 | int bytes_cnt = 0; | ||
341 | int chunk_sz; | ||
340 | fd_set w; | 342 | fd_set w; |
341 | 343 | ||
344 | if (opt->sendpage) | ||
345 | chunk_sz = iov_length * cnt; | ||
346 | else | ||
347 | chunk_sz = iov_length * iov_count; | ||
348 | |||
342 | fcntl(fd, fd_flags); | 349 | fcntl(fd, fd_flags); |
343 | total_bytes = (float)iov_count * (float)iov_length * (float)cnt; | 350 | total_bytes = (float)iov_count * (float)iov_length * (float)cnt; |
344 | err = clock_gettime(CLOCK_MONOTONIC, &s->start); | 351 | err = clock_gettime(CLOCK_MONOTONIC, &s->start); |
@@ -393,9 +400,14 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, | |||
393 | errno = -EIO; | 400 | errno = -EIO; |
394 | fprintf(stderr, | 401 | fprintf(stderr, |
395 | "detected data corruption @iov[%i]:%i %02x != %02x, %02x ?= %02x\n", | 402 | "detected data corruption @iov[%i]:%i %02x != %02x, %02x ?= %02x\n", |
396 | i, j, d[j], k - 1, d[j+1], k + 1); | 403 | i, j, d[j], k - 1, d[j+1], k); |
397 | goto out_errno; | 404 | goto out_errno; |
398 | } | 405 | } |
406 | bytes_cnt++; | ||
407 | if (bytes_cnt == chunk_sz) { | ||
408 | k = 0; | ||
409 | bytes_cnt = 0; | ||
410 | } | ||
399 | recv--; | 411 | recv--; |
400 | } | 412 | } |
401 | } | 413 | } |