Skip to content

Commit

Permalink
fix: prevent pkg_config from emitting Cargo linking instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
EHfive committed Nov 21, 2024
1 parent 5a6a99e commit 5e47e52
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/instance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -202,6 +203,7 @@ fn apply_inet_config<P: InetPrefix, T: EinatEbpf + EinatEbpfInet<P>>(
Ok(())
}

// FIXME: matching network prefix instead of simple `==` comparison
fn remove_binding_and_ct_entries<T: EinatEbpf>(skel: &mut T, external_addr: IpAddr) -> Result<()> {
let addr_flag = if external_addr.is_ipv4() {
BindingFlags::ADDR_IPV4
Expand Down

0 comments on commit 5e47e52

Please sign in to comment.