[CRIU] [PATCH 2/4] test/zdtm: Fix pagesize issue in PACKET_RX/TX_RING
Laurent Dufour
ldufour at linux.vnet.ibm.com
Wed Jul 1 08:32:38 PDT 2015
Calls to setsockopt(PACKET_RX_RING/PACKET_TX_RING) are dependent of the
system's page size.
Using sysconf() page size makes these tests working on ppc64 where page
size is 64K.
Signed-off-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
---
test/zdtm/live/static/packet_sock.c | 8 ++++----
test/zdtm/live/static/packet_sock_mmap.c | 10 +++++-----
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/test/zdtm/live/static/packet_sock.c b/test/zdtm/live/static/packet_sock.c
index a12e624e100a..5931a55f2e00 100644
--- a/test/zdtm/live/static/packet_sock.c
+++ b/test/zdtm/live/static/packet_sock.c
@@ -138,10 +138,10 @@ int main(int argc, char **argv)
}
memset(&ring, 0, sizeof(ring));
- ring.tp_block_size = 4096;
+ ring.tp_block_size = PAGE_SIZE;
ring.tp_block_nr = 1;
ring.tp_frame_size = 1024;
- ring.tp_frame_nr = 4;
+ ring.tp_frame_nr = (ring.tp_block_size / ring.tp_frame_size) * ring.tp_block_nr;
if (setsockopt(sk1, SOL_PACKET, PACKET_RX_RING, &ring, sizeof(ring)) < 0) {
err("Can't set rx ring %m");
return 1;
@@ -183,10 +183,10 @@ int main(int argc, char **argv)
}
memset(&ring, 0, sizeof(ring));
- ring.tp_block_size = 4096;
+ ring.tp_block_size = PAGE_SIZE;
ring.tp_block_nr = 1;
ring.tp_frame_size = 1024;
- ring.tp_frame_nr = 4;
+ ring.tp_frame_nr = (ring.tp_block_size / ring.tp_frame_size) * ring.tp_block_nr;
if (setsockopt(sk2, SOL_PACKET, PACKET_TX_RING, &ring, sizeof(ring)) < 0) {
err("Can't set tx ring %m");
return 1;
diff --git a/test/zdtm/live/static/packet_sock_mmap.c b/test/zdtm/live/static/packet_sock_mmap.c
index 28912adca5ba..942868fe68b7 100644
--- a/test/zdtm/live/static/packet_sock_mmap.c
+++ b/test/zdtm/live/static/packet_sock_mmap.c
@@ -69,26 +69,26 @@ int main(int argc, char **argv)
}
memset(&ring, 0, sizeof(ring));
- ring.tp_block_size = 4096;
+ ring.tp_block_size = PAGE_SIZE;
ring.tp_block_nr = 1;
ring.tp_frame_size = 1024;
- ring.tp_frame_nr = 4;
+ ring.tp_frame_nr = (ring.tp_block_size / ring.tp_frame_size) * ring.tp_block_nr;
if (setsockopt(sk, SOL_PACKET, PACKET_RX_RING, &ring, sizeof(ring)) < 0) {
err("Can't set rx ring %m");
return 1;
}
memset(&ring, 0, sizeof(ring));
- ring.tp_block_size = 4096;
+ ring.tp_block_size = PAGE_SIZE;
ring.tp_block_nr = 1;
ring.tp_frame_size = 1024;
- ring.tp_frame_nr = 4;
+ ring.tp_frame_nr = (ring.tp_block_size / ring.tp_frame_size) * ring.tp_block_nr;
if (setsockopt(sk, SOL_PACKET, PACKET_TX_RING, &ring, sizeof(ring)) < 0) {
err("Can't set tx ring %m");
return 1;
}
- mem = mmap(NULL, 2 * 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE, sk, 0);
+ mem = mmap(NULL, 2 * PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE, sk, 0);
if (mem == MAP_FAILED) {
err("Can't mmap socket %m");
return 1;
--
1.9.1
More information about the CRIU
mailing list