From ab214a69377d66a1aaffdd411f06613a3e92d884 Mon Sep 17 00:00:00 2001 From: Ritik Mishra Date: Tue, 18 Jul 2023 16:59:20 -0700 Subject: [PATCH] Open the raw socket with `O_NONBLOCK` --- src/phy/sys/bpf.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/phy/sys/bpf.rs b/src/phy/sys/bpf.rs index 1935ac3fc..7e65b982a 100644 --- a/src/phy/sys/bpf.rs +++ b/src/phy/sys/bpf.rs @@ -57,7 +57,10 @@ fn open_device() -> io::Result { unsafe { for i in 0..256 { let dev = format!("/dev/bpf{}\0", i); - match libc::open(dev.as_ptr() as *const libc::c_char, libc::O_RDWR) { + match libc::open( + dev.as_ptr() as *const libc::c_char, + libc::O_RDWR | libc::O_NONBLOCK, + ) { -1 => continue, fd => return Ok(fd), };