From 64d9799efcc33b934ff0980c2215a9a023d78cca Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 2 Oct 2023 16:07:33 -0400 Subject: [PATCH 1/3] integration/xdp: reduce repetition --- test/integration-test/src/tests/xdp.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/integration-test/src/tests/xdp.rs b/test/integration-test/src/tests/xdp.rs index 88423fe9..e66b497f 100644 --- a/test/integration-test/src/tests/xdp.rs +++ b/test/integration-test/src/tests/xdp.rs @@ -82,17 +82,19 @@ fn cpumap_chain() { xdp.load().unwrap(); xdp.attach("lo", XdpFlags::default()).unwrap(); + const PAYLOAD: &str = "hello cpumap"; + let sock = UdpSocket::bind("127.0.0.1:1777").unwrap(); sock.set_read_timeout(Some(Duration::from_millis(1))) .unwrap(); - sock.send_to(b"hello cpumap", "127.0.0.1:1777").unwrap(); + sock.send_to(PAYLOAD.as_bytes(), "127.0.0.1:1777").unwrap(); - // Read back the packet to ensure it wenth through the entire network stack, including our two + // Read back the packet to ensure it went through the entire network stack, including our two // probes. - let mut buf = vec![0u8; 1000]; + let mut buf = [0u8; PAYLOAD.len() + 1]; let n = sock.recv(&mut buf).unwrap(); - assert_eq!(&buf[..n], b"hello cpumap"); + assert_eq!(&buf[..n], PAYLOAD.as_bytes()); assert_eq!(hits.get(&0, 0).unwrap(), 1); assert_eq!(hits.get(&1, 0).unwrap(), 1); } From 062ebfdc68146b4b705c44a2c76cd6624f8c3730 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 2 Oct 2023 16:09:03 -0400 Subject: [PATCH 2/3] integration/xdp: use kernel-allocated port --- test/integration-test/src/tests/xdp.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration-test/src/tests/xdp.rs b/test/integration-test/src/tests/xdp.rs index e66b497f..780fe465 100644 --- a/test/integration-test/src/tests/xdp.rs +++ b/test/integration-test/src/tests/xdp.rs @@ -84,10 +84,11 @@ fn cpumap_chain() { const PAYLOAD: &str = "hello cpumap"; - let sock = UdpSocket::bind("127.0.0.1:1777").unwrap(); + let sock = UdpSocket::bind("127.0.0.1:0").unwrap(); + let addr = sock.local_addr().unwrap(); sock.set_read_timeout(Some(Duration::from_millis(1))) .unwrap(); - sock.send_to(PAYLOAD.as_bytes(), "127.0.0.1:1777").unwrap(); + sock.send_to(PAYLOAD.as_bytes(), addr).unwrap(); // Read back the packet to ensure it went through the entire network stack, including our two // probes. From 81268b7ac1ca325a740076e0d00c2ff5af1a20b7 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 2 Oct 2023 16:09:52 -0400 Subject: [PATCH 3/3] integration/xdp: increase timeout to 60 seconds There's absolutely no reason to have a short timeout here. This has resulted in at least one flake: https://github.com/aya-rs/bpf-linker/actions/runs/6384472390/job/17327196576. --- test/integration-test/src/tests/xdp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration-test/src/tests/xdp.rs b/test/integration-test/src/tests/xdp.rs index 780fe465..092f280e 100644 --- a/test/integration-test/src/tests/xdp.rs +++ b/test/integration-test/src/tests/xdp.rs @@ -86,7 +86,7 @@ fn cpumap_chain() { let sock = UdpSocket::bind("127.0.0.1:0").unwrap(); let addr = sock.local_addr().unwrap(); - sock.set_read_timeout(Some(Duration::from_millis(1))) + sock.set_read_timeout(Some(Duration::from_secs(60))) .unwrap(); sock.send_to(PAYLOAD.as_bytes(), addr).unwrap();