Projects STRLCPY ebpfguard Commits 3464ba44
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    docs/gh/prerequisites.md
    skipped 118 lines
    119 119  ```bash
    120 120  $ apt-get update && apt-get install -y --no-install-recommends \
    121 121   build-essential \
     122 + clang \
    122 123   libclang-dev \
    123 124   linux-tools-$(uname -r)
    124 125  ```
    skipped 3 lines
    128 129  You need the Rust stable and nightly toolchains installed on your system, bpf-linker and bpftool binary.
    129 130   
    130 131  Install rust from https://rustup.rs. Further commands assume availability of rustup command.
     132 + 
     133 +Install musl toolchain for crosscompatibility.
     134 + 
     135 +```bash
     136 +$ rustup target add x86_64-unknown-linux-musl
     137 +```
    131 138   
    132 139  Install bindgen-cli:
    133 140   
    skipped 23 lines
  • ■ ■ ■ ■
    ebpfguard-ebpf/build.rs
    skipped 28 lines
    29 29   &[],
    30 30   )
    31 31   .unwrap();
    32  - println!("cargo:rerun-if-changed=src/src/vmlinux.h");
     32 + println!("cargo:rerun-if-changed=src/vmlinux.h");
    33 33   
    34 34   let mut out = File::create(dest_path).unwrap();
    35 35   write!(out, "{}", bindings).unwrap();
    skipped 21 lines
  • ■ ■ ■ ■ ■ ■
    xtask/src/build_ebpf.rs
    skipped 2 lines
    3 3  use clap::Parser;
    4 4   
    5 5  #[derive(Debug, Copy, Clone)]
    6  -pub enum Architecture {
     6 +pub enum EbpfArchitecture {
    7 7   BpfEl,
    8 8   BpfEb,
    9 9  }
    10 10   
    11  -impl std::str::FromStr for Architecture {
     11 +impl std::str::FromStr for EbpfArchitecture {
    12 12   type Err = String;
    13 13   
    14 14   fn from_str(s: &str) -> Result<Self, Self::Err> {
    15 15   Ok(match s {
    16  - "bpfel-unknown-none" => Architecture::BpfEl,
    17  - "bpfeb-unknown-none" => Architecture::BpfEb,
     16 + "bpfel-unknown-none" => EbpfArchitecture::BpfEl,
     17 + "bpfeb-unknown-none" => EbpfArchitecture::BpfEb,
    18 18   _ => return Err("invalid target".to_owned()),
    19 19   })
    20 20   }
    21 21  }
    22 22   
    23  -impl std::fmt::Display for Architecture {
     23 +impl std::fmt::Display for EbpfArchitecture {
    24 24   fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    25 25   f.write_str(match self {
    26  - Architecture::BpfEl => "bpfel-unknown-none",
    27  - Architecture::BpfEb => "bpfeb-unknown-none",
     26 + EbpfArchitecture::BpfEl => "bpfel-unknown-none",
     27 + EbpfArchitecture::BpfEb => "bpfeb-unknown-none",
    28 28   })
    29 29   }
    30 30  }
    skipped 26 lines
    57 57  pub struct Options {
    58 58   /// Set the endianness of the BPF target
    59 59   #[clap(default_value = "bpfel-unknown-none", long)]
    60  - pub target: Architecture,
     60 + pub target: EbpfArchitecture,
    61 61   /// Build the release target
    62 62   #[clap(long)]
    63 63   pub release: bool,
    skipped 39 lines
  • ■ ■ ■ ■ ■ ■
    xtask/src/run.rs
    skipped 2 lines
    3 3  use anyhow::Context as _;
    4 4  use clap::Parser;
    5 5   
    6  -use crate::build_ebpf::{build_ebpf, Architecture, Options as BuildOptions};
     6 +use crate::build_ebpf::{build_ebpf, EbpfArchitecture, Options as BuildOptions};
    7 7   
    8 8  #[derive(Debug, Parser)]
    9 9  pub struct Options {
    10 10   /// Set the endianness of the BPF target
    11 11   #[clap(default_value = "bpfel-unknown-none", long)]
    12  - pub bpf_target: Architecture,
     12 + pub bpf_target: EbpfArchitecture,
     13 + /// Set userspace compilation target
     14 + #[clap(default_value = "x86_64-unknown-linux-musl", long)]
     15 + pub userspace_target: String,
    13 16   /// Build and run the release target
    14 17   #[clap(long)]
    15 18   pub release: bool,
    skipped 34 lines
    50 53   // profile we are building (release or debug)
    51 54   let profile = if opts.release { "release" } else { "debug" };
    52 55   let example = opts.example;
    53  - let bin_path = format!("target/{profile}/examples/{example}");
     56 + let userspace_target = opts.userspace_target;
     57 + let bin_path = format!("target/{userspace_target}/{profile}/examples/{example}");
    54 58   
    55 59   // arguments to pass to the application
    56 60   let mut run_args: Vec<_> = opts.run_args.iter().map(String::as_str).collect();
    skipped 18 lines
Please wait...
Page is in error, reload to recover