From f3375f0b13803489e7e44a0dc8aa787a9aa44f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Mon, 20 Nov 2023 14:27:39 -0800 Subject: [PATCH] Update nix dependency to 0.27 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the nix dependency that we depend on to 0.27, to prevent copies of multiple versions being pulled in during the build. Signed-off-by: Daniel Müller --- Cargo.lock | 20 +++++++++++++++----- examples/bpf_query/Cargo.toml | 2 +- examples/tc_port_whitelist/Cargo.toml | 2 +- examples/tproxy/Cargo.toml | 2 +- examples/tproxy/src/bin/proxy.rs | 12 ++++++------ libbpf-rs/Cargo.toml | 2 +- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5352ab93a..c42d73864 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,7 +48,7 @@ dependencies = [ "clap", "iced-x86", "libbpf-rs", - "nix 0.26.4", + "nix 0.27.1", ] [[package]] @@ -277,7 +277,7 @@ dependencies = [ "libc", "log", "memmem", - "nix 0.26.4", + "nix 0.27.1", "num_enum", "pkg-config", "plain", @@ -360,6 +360,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "nix" version = "0.26.4" @@ -369,7 +378,7 @@ dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", - "memoffset", + "memoffset 0.7.1", "pin-utils", ] @@ -382,6 +391,7 @@ dependencies = [ "bitflags 2.4.1", "cfg-if", "libc", + "memoffset 0.9.0", ] [[package]] @@ -794,7 +804,7 @@ dependencies = [ "libbpf-cargo", "libbpf-rs", "libc", - "nix 0.26.4", + "nix 0.27.1", "plain", ] @@ -879,7 +889,7 @@ dependencies = [ "ctrlc", "libbpf-cargo", "libbpf-rs", - "nix 0.26.4", + "nix 0.27.1", ] [[package]] diff --git a/examples/bpf_query/Cargo.toml b/examples/bpf_query/Cargo.toml index 5a8aae50d..783bb1271 100644 --- a/examples/bpf_query/Cargo.toml +++ b/examples/bpf_query/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] libbpf-rs = { path = "../../libbpf-rs" } -nix = { version = "0.26", default-features = false, features = ["net", "user"] } +nix = { version = "0.27", default-features = false, features = ["net", "user"] } clap = { version = "4.0.32", default-features = false, features = ["std", "derive", "help", "usage"] } [target.'cfg(target_arch = "x86_64")'.dependencies] diff --git a/examples/tc_port_whitelist/Cargo.toml b/examples/tc_port_whitelist/Cargo.toml index ccde25580..1e05ed318 100644 --- a/examples/tc_port_whitelist/Cargo.toml +++ b/examples/tc_port_whitelist/Cargo.toml @@ -10,7 +10,7 @@ anyhow = "1.0" libbpf-rs = { path = "../../libbpf-rs" } libc = "0.2" plain = "0.2" -nix = { version = "0.26", default-features = false, features = ["net", "user"] } +nix = { version = "0.27", default-features = false, features = ["net", "user"] } clap = { version = "4.0.32", default-features = false, features = ["std", "derive", "help", "usage"] } [build-dependencies] diff --git a/examples/tproxy/Cargo.toml b/examples/tproxy/Cargo.toml index db0a9a165..6ee504370 100644 --- a/examples/tproxy/Cargo.toml +++ b/examples/tproxy/Cargo.toml @@ -13,7 +13,7 @@ anyhow = "1.0" clap = { version = "4.0.32", default-features = false, features = ["std", "derive", "help", "usage"] } ctrlc = "3.2" libbpf-rs = { path = "../../libbpf-rs" } -nix = { version = "0.26", default-features = false, features = ["net", "user"] } +nix = { version = "0.27", default-features = false, features = ["net", "user"] } [build-dependencies] libbpf-cargo = { path = "../../libbpf-cargo" } diff --git a/examples/tproxy/src/bin/proxy.rs b/examples/tproxy/src/bin/proxy.rs index f818fc76c..a371ae849 100644 --- a/examples/tproxy/src/bin/proxy.rs +++ b/examples/tproxy/src/bin/proxy.rs @@ -1,6 +1,6 @@ use std::net::TcpListener; use std::net::TcpStream; -use std::os::unix::io::FromRawFd; +use std::os::fd::AsRawFd as _; use std::str::FromStr; use anyhow::Context; @@ -56,17 +56,17 @@ fn main() -> Result<()> { .context("Failed to create listener socket")?; // Set some sockopts - setsockopt(fd, ReuseAddr, &true).context("Failed to set SO_REUSEADDR")?; - setsockopt(fd, IpTransparent, &true).context("Failed to set IP_TRANSPARENT")?; + setsockopt(&fd, ReuseAddr, &true).context("Failed to set SO_REUSEADDR")?; + setsockopt(&fd, IpTransparent, &true).context("Failed to set IP_TRANSPARENT")?; // Bind to addr let addr = format!("{}:{}", opts.addr, opts.port); let addr = SockaddrIn::from_str(&addr).context("Failed to parse socketaddr")?; - bind(fd, &addr).context("Failed to bind listener")?; + bind(fd.as_raw_fd(), &addr).context("Failed to bind listener")?; // Start listening - listen(fd, 128).context("Failed to listen")?; - let listener = unsafe { TcpListener::from_raw_fd(fd) }; + listen(&fd, 128).context("Failed to listen")?; + let listener = TcpListener::from(fd); for client in listener.incoming() { let client = client.context("Failed to connect to client")?; diff --git a/libbpf-rs/Cargo.toml b/libbpf-rs/Cargo.toml index 5adac728a..4180eefe1 100644 --- a/libbpf-rs/Cargo.toml +++ b/libbpf-rs/Cargo.toml @@ -25,7 +25,7 @@ bitflags = "2.0" lazy_static = "1.4" libbpf-sys = { version = "1.0.3" } libc = "0.2" -nix = { version = "0.26", default-features = false, features = ["net", "user"] } +nix = { version = "0.27", default-features = false, features = ["net", "user"] } num_enum = "0.5" strum_macros = "0.24" thiserror = "1.0.10"