From 5e47e52ea2d4f6f8f3f38f1aa1e559b9b57b5ba9 Mon Sep 17 00:00:00 2001 From: Huang-Huang Bao Date: Thu, 21 Nov 2024 14:14:44 +0800 Subject: [PATCH] fix: prevent pkg_config from emitting Cargo linking instructions --- Cargo.toml | 8 +++----- build.rs | 5 ++++- src/instance/mod.rs | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dfaf9a8..7d7551f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,13 +20,13 @@ strip = true default = ["aya", "pkg-config"] # Enable IPv6 NAPT ipv6 = [] -# Enable Aya BPF loader, requires Rust>=1.80.0 +# Enable Aya BPF loader aya = [ # the dep:aya is also used for determine kernel version so it's already included ] # Enable libbpf BPF loader libbpf = ["dep:libbpf-rs", "dep:libbpf-sys"] -# Enable libbpf skeleton-wrapped BPF loader, requires unpublish self_cell for now +# Enable libbpf skeleton-wrapped BPF loader libbpf-skel = [ "dep:libbpf-rs", "dep:libbpf-sys", @@ -39,9 +39,7 @@ bindgen = ["libbpf-sys?/bindgen"] static = ["libbpf-sys?/static"] # # libbpf is vendrored and static in any case. -# Note currently there is a bug in libbpf-sys that prevent static linking if -# system libbpf is present, delete system libbpf or /path/to/pkgconfig/libbpf.pc -# to work around it. See https://github.com/libbpf/libbpf-sys/issues/112 +# [dependencies] anyhow = "1.0.93" diff --git a/build.rs b/build.rs index 27ebeb0..f2ad3dd 100644 --- a/build.rs +++ b/build.rs @@ -49,7 +49,10 @@ fn einat_obj_build() { // Specify environment variable LIBBPF_NO_PKG_CONFIG=1 to disable pkg-config lookup. // Or just disable the "pkg-config" feature. #[cfg(feature = "pkg-config")] - match pkg_config::probe_library("libbpf") { + match pkg_config::Config::new() + .cargo_metadata(false) + .probe("libbpf") + { Ok(libbpf) => { let includes = libbpf .include_paths diff --git a/src/instance/mod.rs b/src/instance/mod.rs index 948799c..494fae6 100644 --- a/src/instance/mod.rs +++ b/src/instance/mod.rs @@ -12,6 +12,7 @@ use anyhow::{anyhow, Result}; use cfg_if::cfg_if; #[cfg(any(feature = "aya", feature = "libbpf", feature = "libbpf-skel"))] use enum_dispatch::enum_dispatch; +use ipnet::IpNet; use tracing::{debug, info}; use crate::skel::einat; @@ -202,6 +203,7 @@ fn apply_inet_config>( Ok(()) } +// FIXME: matching network prefix instead of simple `==` comparison fn remove_binding_and_ct_entries(skel: &mut T, external_addr: IpAddr) -> Result<()> { let addr_flag = if external_addr.is_ipv4() { BindingFlags::ADDR_IPV4