[PATCH 3/3] test/bpf: add extra test cases for bpf convert

Konstantin Ananyev konstantin.v.ananyev at yandex.ru
Thu Jun 27 13:55:31 CEST 2024


From: Konstantin Ananyev <konstantin.ananyev at huawei.com>

Add few extra cases to catch problems similar to:
https://bugs.dpdk.org/show_bug.cgi?id=1465
Plus made it dump cBPF filter and converted eBPF program
to make things easier to track.

Suggested-by: Isaac Boukris <iboukris at gmail.com>
Signed-off-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
---
 app/test/test_bpf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
index 64c3c90b0a..993e181b76 100644
--- a/app/test/test_bpf.c
+++ b/app/test/test_bpf.c
@@ -3423,6 +3423,9 @@ static const char * const sample_filters[] = {
 	" and ((ip[2:2] - 4 * (ip[0] & 0x0F) - 4 * ((tcp[12] & 0xF0) >> 4) > 69))",
 	/* Other */
 	"len = 128",
+	"host 1::1 or host 1::1 or host 1::1 or host 1::1 or host 1::1 or host 1::1",
+	"host 1::1 or host 1::2 or host 1::3 or host 1::4 or host 1::5 "
+	"or host 192.0.2.1 or host 192.0.2.100 or host 192.0.2.200",
 };
 
 static int
@@ -3445,6 +3448,9 @@ test_bpf_filter(pcap_t *pcap, const char *s)
 		goto error;
 	}
 
+	printf("bpf convert for \"%s\" produced:\n", s);
+	rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
+
 	bpf = rte_bpf_load(prm);
 	if (bpf == NULL) {
 		printf("%s@%d: failed to load bpf code, error=%d(%s);\n",
-- 
2.35.3



More information about the dev mailing list