Re: [PATCH bpf v2 2/2] selftests/bpf: Add test for narrow loads from context at an offset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 7/23/20 2:59 AM, Jakub Sitnicki wrote:
Check that narrow loads at various offsets from a context field backed by a
target field that is smaller in size work as expected. That is target field
value is loaded only when the offset is less than the target field size.
While for offsets beyond the target field, the loaded value is zero.

Signed-off-by: Jakub Sitnicki <jakub@xxxxxxxxxxxxxx>

Ack with minor nit below.
Acked-by: Yonghong Song <yhs@xxxxxx>

---
  .../selftests/bpf/prog_tests/narrow_load.c    | 84 +++++++++++++++++++
  .../selftests/bpf/progs/test_narrow_load.c    | 43 ++++++++++
  2 files changed, 127 insertions(+)
  create mode 100644 tools/testing/selftests/bpf/prog_tests/narrow_load.c
  create mode 100644 tools/testing/selftests/bpf/progs/test_narrow_load.c

diff --git a/tools/testing/selftests/bpf/prog_tests/narrow_load.c b/tools/testing/selftests/bpf/prog_tests/narrow_load.c
new file mode 100644
index 000000000000..6d79d722a66d
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/narrow_load.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+// Copyright (c) 2020 Cloudflare
+
+#include "test_progs.h"
+#include "test_narrow_load.skel.h"
+
+static int duration;
+
+void run_sk_reuseport_prog(struct bpf_program *reuseport_prog)

static function?

+{
+	static const struct timeval timeo = { .tv_sec = 3 };
+	struct sockaddr_in addr = {
+		.sin_family = AF_INET,
+		.sin_port = 0,
+		.sin_addr.s_addr = htonl(INADDR_LOOPBACK),
+	};
+	socklen_t len = sizeof(addr);
+	int err, fd, prog_fd;
+	const int one = 1;
+	char buf = 42;
+	ssize_t n;
+
[...]



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux