Skip to content

Commit e9016a2

Browse files
authoredJul 17, 2024··
Merge pull request bpfman#1141 from astoycos/spec-license
Update image spec to support multiple images, add build tooling for bytecode images
2 parents f5af4aa + b72009c commit e9016a2

File tree

35 files changed

+1713
-617
lines changed

35 files changed

+1713
-617
lines changed
 

‎.github/workflows/image-build.yaml

+102-120
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@ on: # yamllint disable-line rule:truthy
1010
workflow_dispatch:
1111

1212
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout bpfman
17+
uses: actions/checkout@v4
18+
19+
- name: Build bpfman binary
20+
run: cargo build -p bpfman --verbose
21+
22+
- name: archive bpfman binary
23+
run: |
24+
cd target/debug
25+
tar -czvf bpfman.tar.gz bpfman
26+
27+
- name: Archive bpfman Binaries
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: bpfman
31+
path: |
32+
./target/debug/bpfman.tar.gz
33+
1334
build-and-push-images:
1435
permissions:
1536
contents: read
@@ -206,6 +227,7 @@ jobs:
206227
done
207228
208229
build-and-push-bytecode-images:
230+
needs: [build]
209231
permissions:
210232
contents: read
211233
packages: write
@@ -221,13 +243,9 @@ jobs:
221243
bpf_build_wrapper: go
222244
repository: bpfman-bytecode
223245
image: go-xdp-counter
224-
context: ./examples/go-xdp-counter
225-
dockerfile: ./Containerfile.bytecode
226-
build_args: |
227-
PROGRAM_NAME=go-xdp-counter
228-
BPF_FUNCTION_NAME=xdp_stats
229-
PROGRAM_TYPE=xdp
230-
BYTECODE_FILENAME=bpf_bpfel.o
246+
context: .
247+
dockerfile: ./Containerfile.bytecode.multi.arch
248+
bytecode_dir: ./examples/go-xdp-counter
231249
tags: |
232250
type=ref,event=branch
233251
type=ref,event=tag
@@ -241,13 +259,9 @@ jobs:
241259
bpf_build_wrapper: go
242260
repository: bpfman-bytecode
243261
image: go-tc-counter
244-
context: ./examples/go-tc-counter
245-
dockerfile: ./Containerfile.bytecode
246-
build_args: |
247-
PROGRAM_NAME=go-tc-counter
248-
BPF_FUNCTION_NAME=stats
249-
PROGRAM_TYPE=tc
250-
BYTECODE_FILENAME=bpf_bpfel.o
262+
context: .
263+
dockerfile: ./Containerfile.bytecode.multi.arch
264+
bytecode_dir: ./examples/go-tc-counter
251265
tags: |
252266
type=ref,event=branch
253267
type=ref,event=tag
@@ -261,13 +275,9 @@ jobs:
261275
bpf_build_wrapper: go
262276
repository: bpfman-bytecode
263277
image: go-tracepoint-counter
264-
context: ./examples/go-tracepoint-counter
265-
dockerfile: ./Containerfile.bytecode
266-
build_args: |
267-
PROGRAM_NAME=go-tracepoint-counter
268-
BPF_FUNCTION_NAME=tracepoint_kill_recorder
269-
PROGRAM_TYPE=tracepoint
270-
BYTECODE_FILENAME=bpf_bpfel.o
278+
context: .
279+
dockerfile: ./Containerfile.bytecode.multi.arch
280+
bytecode_dir: ./examples/go-tracepoint-counter
271281
tags: |
272282
type=ref,event=branch
273283
type=ref,event=tag
@@ -281,13 +291,9 @@ jobs:
281291
bpf_build_wrapper: go
282292
repository: bpfman-bytecode
283293
image: go-kprobe-counter
284-
context: ./examples/go-kprobe-counter
285-
dockerfile: ./Containerfile.bytecode
286-
build_args: |
287-
PROGRAM_NAME=kprobe_counter
288-
BPF_FUNCTION_NAME=kprobe_counter
289-
PROGRAM_TYPE=kprobe
290-
BYTECODE_FILENAME=bpf_bpfel.o
294+
context: .
295+
dockerfile: ./Containerfile.bytecode.multi.arch
296+
bytecode_dir: ./examples/go-kprobe-counter
291297
tags: |
292298
type=ref,event=branch
293299
type=ref,event=tag
@@ -301,13 +307,9 @@ jobs:
301307
bpf_build_wrapper: go
302308
repository: bpfman-bytecode
303309
image: go-uprobe-counter
304-
context: ./examples/go-uprobe-counter
305-
dockerfile: ./Containerfile.bytecode
306-
build_args: |
307-
PROGRAM_NAME=uprobe_counter
308-
BPF_FUNCTION_NAME=uprobe_counter
309-
PROGRAM_TYPE=uprobe
310-
BYTECODE_FILENAME=bpf_bpfel.o
310+
context: .
311+
dockerfile: ./Containerfile.bytecode.multi.arch
312+
bytecode_dir: ./examples/go-uprobe-counter
311313
tags: |
312314
type=ref,event=branch
313315
type=ref,event=tag
@@ -321,13 +323,9 @@ jobs:
321323
bpf_build_wrapper: go
322324
repository: bpfman-bytecode
323325
image: go-uretprobe-counter
324-
context: ./examples/go-uretprobe-counter
325-
dockerfile: ./Containerfile.bytecode
326-
build_args: |
327-
PROGRAM_NAME=uretprobe_counter
328-
BPF_FUNCTION_NAME=uretprobe_counter
329-
PROGRAM_TYPE=uretprobe
330-
BYTECODE_FILENAME=bpf_x86_bpfel.o
326+
context: .
327+
dockerfile: ./Containerfile.bytecode.multi.arch
328+
bytecode_dir: ./examples/go-uretprobe-counter
331329
tags: |
332330
type=ref,event=branch
333331
type=ref,event=tag
@@ -341,10 +339,9 @@ jobs:
341339
bpf_build_wrapper: go
342340
repository: bpfman-bytecode
343341
image: go-app-counter
344-
context: ./examples/go-app-counter
345-
dockerfile: ./Containerfile.bytecode
346-
build_args: |
347-
BYTECODE_FILENAME=bpf_bpfel.o
342+
context: .
343+
dockerfile: ./Containerfile.bytecode.multi.arch
344+
bytecode_dir: ./examples/go-app-counter
348345
tags: |
349346
type=ref,event=branch
350347
type=ref,event=tag
@@ -358,13 +355,9 @@ jobs:
358355
bpf_build_wrapper: rust
359356
repository: bpfman-bytecode
360357
image: xdp_pass
361-
context: ./tests/integration-test/bpf/.output
362-
dockerfile: ./Containerfile.bytecode
363-
build_args: |
364-
PROGRAM_NAME=xdp_pass
365-
BPF_FUNCTION_NAME=pass
366-
PROGRAM_TYPE=xdp
367-
BYTECODE_FILENAME=xdp_pass.bpf.o
358+
context: .
359+
dockerfile: ./Containerfile.bytecode.multi.arch
360+
bytecode_dir: ./tests/integration-test/bpf/.output/xdp_pass.bpf
368361
tags: |
369362
type=ref,event=branch
370363
type=ref,event=tag
@@ -378,13 +371,9 @@ jobs:
378371
bpf_build_wrapper: rust
379372
repository: bpfman-bytecode
380373
image: xdp_pass_private
381-
context: ./tests/integration-test/bpf/.output
382-
dockerfile: ./Containerfile.bytecode
383-
build_args: |
384-
PROGRAM_NAME=xdp_pass_private
385-
BPF_FUNCTION_NAME=pass
386-
PROGRAM_TYPE=xdp
387-
BYTECODE_FILENAME=xdp_pass.bpf.o
374+
context: .
375+
dockerfile: ./Containerfile.bytecode.multi.arch
376+
bytecode_dir: ./tests/integration-test/bpf/.output/xdp_pass.bpf
388377
tags: |
389378
type=ref,event=branch
390379
type=ref,event=tag
@@ -398,13 +387,9 @@ jobs:
398387
bpf_build_wrapper: rust
399388
repository: bpfman-bytecode
400389
image: tc_pass
401-
context: ./tests/integration-test/bpf/.output
402-
dockerfile: ./Containerfile.bytecode
403-
build_args: |
404-
PROGRAM_NAME=tc_pass
405-
BPF_FUNCTION_NAME=pass
406-
PROGRAM_TYPE=tc
407-
BYTECODE_FILENAME=tc_pass.bpf.o
390+
context: .
391+
dockerfile: ./Containerfile.bytecode.multi.arch
392+
bytecode_dir: ./tests/integration-test/bpf/.output/tc_pass.bpf
408393
tags: |
409394
type=ref,event=branch
410395
type=ref,event=tag
@@ -418,13 +403,9 @@ jobs:
418403
bpf_build_wrapper: rust
419404
repository: bpfman-bytecode
420405
image: tracepoint
421-
context: ./tests/integration-test/bpf/.output
422-
dockerfile: ./Containerfile.bytecode
423-
build_args: |
424-
PROGRAM_NAME=tracepoint
425-
BPF_FUNCTION_NAME=enter_openat
426-
PROGRAM_TYPE=tracepoint
427-
BYTECODE_FILENAME=tp_openat.bpf.o
406+
context: .
407+
dockerfile: ./Containerfile.bytecode.multi.arch
408+
bytecode_dir: ./tests/integration-test/bpf/.output/tp_openat.bpf
428409
tags: |
429410
type=ref,event=branch
430411
type=ref,event=tag
@@ -438,13 +419,9 @@ jobs:
438419
bpf_build_wrapper: rust
439420
repository: bpfman-bytecode
440421
image: uprobe
441-
context: ./tests/integration-test/bpf/.output
442-
dockerfile: ./Containerfile.bytecode
443-
build_args: |
444-
PROGRAM_NAME=uprobe
445-
BPF_FUNCTION_NAME=my_uprobe
446-
PROGRAM_TYPE=uprobe
447-
BYTECODE_FILENAME=uprobe.bpf.o
422+
context: .
423+
dockerfile: ./Containerfile.bytecode.multi.arch
424+
bytecode_dir: ./tests/integration-test/bpf/.output/uprobe.bpf
448425
tags: |
449426
type=ref,event=branch
450427
type=ref,event=tag
@@ -458,13 +435,9 @@ jobs:
458435
bpf_build_wrapper: rust
459436
repository: bpfman-bytecode
460437
image: uretprobe
461-
context: ./tests/integration-test/bpf/.output
462-
dockerfile: ./Containerfile.bytecode
463-
build_args: |
464-
PROGRAM_NAME=uretprobe
465-
BPF_FUNCTION_NAME=my_uretprobe
466-
PROGRAM_TYPE=uretprobe
467-
BYTECODE_FILENAME=uprobe.bpf.o
438+
context: .
439+
dockerfile: ./Containerfile.bytecode.multi.arch
440+
bytecode_dir: ./tests/integration-test/bpf/.output/uprobe.bpf
468441
tags: |
469442
type=ref,event=branch
470443
type=ref,event=tag
@@ -478,13 +451,9 @@ jobs:
478451
bpf_build_wrapper: rust
479452
repository: bpfman-bytecode
480453
image: kprobe
481-
context: ./tests/integration-test/bpf/.output
482-
dockerfile: ./Containerfile.bytecode
483-
build_args: |
484-
PROGRAM_NAME=kprobe
485-
BPF_FUNCTION_NAME=my_kprobe
486-
PROGRAM_TYPE=kprobe
487-
BYTECODE_FILENAME=kprobe.bpf.o
454+
context: .
455+
dockerfile: ./Containerfile.bytecode.multi.arch
456+
bytecode_dir: ./tests/integration-test/bpf/.output/kprobe.bpf
488457
tags: |
489458
type=ref,event=branch
490459
type=ref,event=tag
@@ -498,13 +467,9 @@ jobs:
498467
bpf_build_wrapper: rust
499468
repository: bpfman-bytecode
500469
image: kretprobe
501-
context: ./tests/integration-test/bpf/.output
502-
dockerfile: ./Containerfile.bytecode
503-
build_args: |
504-
PROGRAM_NAME=kretprobe
505-
BPF_FUNCTION_NAME=my_kretprobe
506-
PROGRAM_TYPE=kretprobe
507-
BYTECODE_FILENAME=kprobe.bpf.o
470+
context: .
471+
dockerfile: ./Containerfile.bytecode.multi.arch
472+
bytecode_dir: ./tests/integration-test/bpf/.output/kprobe.bpf
508473
tags: |
509474
type=ref,event=branch
510475
type=ref,event=tag
@@ -518,13 +483,9 @@ jobs:
518483
bpf_build_wrapper: rust
519484
repository: bpfman-bytecode
520485
image: fentry
521-
context: ./tests/integration-test/bpf/.output
522-
dockerfile: ./Containerfile.bytecode
523-
build_args: |
524-
PROGRAM_NAME=do_unlinkat
525-
BPF_FUNCTION_NAME=test_fentry
526-
PROGRAM_TYPE=fentry
527-
BYTECODE_FILENAME=fentry.bpf.o
486+
context: .
487+
dockerfile: ./Containerfile.bytecode.multi.arch
488+
bytecode_dir: ./tests/integration-test/bpf/.output/fentry.bpf
528489
tags: |
529490
type=ref,event=branch
530491
type=ref,event=tag
@@ -538,13 +499,9 @@ jobs:
538499
bpf_build_wrapper: rust
539500
repository: bpfman-bytecode
540501
image: fexit
541-
context: ./tests/integration-test/bpf/.output
542-
dockerfile: ./Containerfile.bytecode
543-
build_args: |
544-
PROGRAM_NAME=do_unlinkat
545-
BPF_FUNCTION_NAME=test_fexit
546-
PROGRAM_TYPE=fexit
547-
BYTECODE_FILENAME=fentry.bpf.o
502+
context: .
503+
dockerfile: ./Containerfile.bytecode.multi.arch
504+
bytecode_dir: ./tests/integration-test/bpf/.output/fentry.bpf
548505
tags: |
549506
type=ref,event=branch
550507
type=ref,event=tag
@@ -559,7 +516,8 @@ jobs:
559516
repository: bpfman
560517
image: xdp-dispatcher
561518
context: .
562-
dockerfile: ./Containerfile.xdp_dispatcher_v1
519+
dockerfile: ./Containerfile.bytecode.multi.arch
520+
bytecode_dir: ./.output/xdp_dispatcher_v1.bpf
563521
tags: |
564522
type=ref,event=branch
565523
type=ref,event=tag
@@ -573,7 +531,8 @@ jobs:
573531
repository: bpfman
574532
image: xdp-dispatcher
575533
context: .
576-
dockerfile: ./Containerfile.xdp_dispatcher_v2
534+
dockerfile: ./Containerfile.bytecode.multi.arch
535+
bytecode_dir: ./.output/xdp_dispatcher_v2.bpf
577536
tags: |
578537
type=ref,event=branch
579538
type=ref,event=tag
@@ -587,7 +546,8 @@ jobs:
587546
repository: bpfman
588547
image: tc-dispatcher
589548
context: .
590-
dockerfile: ./Containerfile.tc_dispatcher
549+
dockerfile: ./Containerfile.bytecode.multi.arch
550+
bytecode_dir: ./.output/tc_dispatcher.bpf
591551
tags: |
592552
type=ref,event=branch
593553
type=ref,event=tag
@@ -656,6 +616,15 @@ jobs:
656616
username: ${{ secrets.BPFMAN_BYTECODE_USERNAME }}
657617
password: ${{ secrets.BPFMAN_BYTECODE_ROBOT_TOKEN }}
658618

619+
- name: Download bpfman binary
620+
uses: actions/download-artifact@v4
621+
with:
622+
name: bpfman
623+
624+
- name: Unpack bpfman binary
625+
run: |
626+
tar -C /usr/local/bin -xzvf bpfman.tar.gz
627+
659628
- name: Extract metadata (tags, labels) for image
660629
id: meta
661630
uses: docker/metadata-action@v5.5.1
@@ -669,15 +638,28 @@ jobs:
669638
- name: Set up Docker Buildx
670639
uses: docker/setup-buildx-action@v3
671640

641+
- name: Manually generate build args
642+
id: build-tags
643+
run: |
644+
bytecode_data=$(bpfman image generate-build-args --cilium-ebpf-project ${{ matrix.image.bytecode_dir }})
645+
build_args="${bytecode_data}\n"
646+
printf BUILD_ARGS="$build_args" >> $GITHUB_ENV
647+
{
648+
echo 'BUILD_ARGS<<EOF'
649+
printf "$build_args"
650+
echo EOF
651+
} >> "$GITHUB_ENV"
652+
672653
- name: Build and push
673654
id: build-push-image
674655
uses: docker/build-push-action@v6
675656
with:
657+
platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x
676658
push: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
677659
tags: ${{ steps.meta.outputs.tags }}
678660
labels: ${{ steps.meta.outputs.labels }}
679661
file: ${{ matrix.image.dockerfile }}
680-
build-args: ${{ matrix.image.build_args }}
662+
build-args: ${{ env.BUILD_ARGS }}
681663
context: ${{ matrix.image.context }}
682664

683665
- name: Sign the images with GitHub OIDC Token

‎Cargo.lock

+23-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ assert_cmd = { version = "2", default-features = false }
2626
assert_matches = { version = "1", default-features = false }
2727
async-trait = { version = "0.1", default-features = false }
2828
aya = { version = "0.12", default-features = false }
29+
aya-obj = { version = "0.1.0", default-features = false }
2930
base16ct = { version = "0.2.0", default-features = false }
3031
base64 = { version = "0.22.0", default-features = false }
3132
bpfman = { version = "0.5.0", path = "./bpfman" }
@@ -54,6 +55,7 @@ netlink-packet-core = { version = "^0.7", default-features = false }
5455
netlink-packet-route = { version = "^0.19", default-features = false }
5556
netlink-sys = { version = "^0.8", default-features = false }
5657
nix = { version = "0.28", default-features = false }
58+
object = { version = "0.32.2", default-features = false }
5759
oci-distribution = { version = "0.10", default-features = false }
5860
opentelemetry = { version = "0.22.0", default-features = false }
5961
opentelemetry-otlp = { version = "0.15.0", default-features = false }
@@ -89,7 +91,6 @@ tower = { version = "0.4.13", default-features = false }
8991
url = { version = "2.5.1", default-features = false }
9092
users = { version = "0.11.0", default-features = false }
9193

92-
9394
[workspace.metadata.vendor-filter]
9495
platforms = [
9596
"aarch64-unknown-linux-gnu",

‎Containerfile.bytecode

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
FROM scratch
22

3-
ARG PROGRAM_NAME
4-
ARG BPF_FUNCTION_NAME
5-
ARG PROGRAM_TYPE
6-
ARG BYTECODE_FILENAME
7-
ARG KERNEL_COMPILE_VER
3+
ARG BYTECODE_FILE
4+
ARG PROGRAMS
5+
ARG MAPS
86

9-
COPY $BYTECODE_FILENAME /
10-
LABEL io.ebpf.program_type $PROGRAM_TYPE
11-
LABEL io.ebpf.filename $BYTECODE_FILENAME
12-
LABEL io.ebpf.program_name $PROGRAM_NAME
13-
LABEL io.ebpf.bpf_function_name $BPF_FUNCTION_NAME
7+
LABEL "io.ebpf.programs"=$PROGRAMS
8+
LABEL "io.ebpf.maps"=$MAPS
9+
10+
COPY $BYTECODE_FILE /

‎Containerfile.bytecode.multi.arch

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
## see https://go.dev/doc/install/source#environment for valid
2+
## GOARCHes when GOOS=linux.
3+
FROM scratch
4+
ARG TARGETARCH
5+
ARG TARGETOS
6+
7+
FROM scratch AS linux386
8+
ARG BC_386_EL
9+
COPY $BC_386_EL /
10+
11+
FROM scratch AS linuxamd64
12+
ARG BC_AMD64_EL
13+
COPY $BC_AMD64_EL /
14+
15+
FROM scratch AS linuxarm
16+
ARG BC_ARM_EL
17+
COPY $BC_ARM_EL /
18+
19+
FROM scratch AS linuxarm64
20+
ARG BC_ARM64_EL
21+
COPY $BC_ARM64_EL /
22+
23+
FROM scratch AS linuxloong64
24+
ARG BC_LOONG64_EL
25+
COPY $BC_LOONG64_EL /
26+
27+
FROM scratch AS linuxmips
28+
ARG BC_MIPS_EB
29+
COPY $BC_MIPS_EB /
30+
31+
FROM scratch AS linuxmipsle
32+
ARG BC_MIPSLE_EL
33+
COPY $BC_MIPSLE_EL /
34+
35+
FROM scratch AS linuxmips64
36+
ARG BC_MIPS64_EB
37+
COPY $BC_MIPS64_EB /
38+
39+
FROM scratch AS linuxmips64le
40+
ARG BC_MIPS64LE_EL
41+
COPY $BC_MIPS64LE_EL /
42+
43+
FROM scratch AS linuxppc64
44+
ARG BC_PPC64_EB
45+
COPY $BC_PPC64_EL /
46+
47+
FROM scratch AS linuxppc64le
48+
ARG BC_PPC64LE_EL
49+
COPY $BC_PPC64LE_EL /
50+
51+
FROM scratch AS linuxriscv64
52+
ARG BC_RISCV64_EL
53+
COPY $BC_RISCV64_EL /
54+
55+
FROM scratch AS linuxs390x
56+
ARG BC_S390X_EB
57+
COPY $BC_S390X_EB /
58+
59+
ARG TARGETARCH
60+
ARG TARGETOS
61+
62+
# Use the build argument to select the correct base image
63+
FROM ${TARGETOS}${TARGETARCH}
64+
ARG PROGRAMS
65+
ARG MAPS
66+
LABEL "io.ebpf.programs"=$PROGRAMS
67+
LABEL "io.ebpf.maps"=$MAPS

‎Containerfile.xdp_dispatcher_v1

-7
This file was deleted.

‎Containerfile.xdp_dispatcher_v2

-7
This file was deleted.

‎bpfman/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ path = "src/bin/cli/main.rs"
2020
anyhow = { workspace = true, features = ["std"] }
2121
async-trait = { workspace = true }
2222
aya = { workspace = true }
23+
aya-obj = { workspace = true }
2324
base16ct = { workspace = true, features = ["alloc"] }
2425
base64 = { workspace = true }
2526
bpfman-csi = { workspace = true }
@@ -49,6 +50,7 @@ nix = { workspace = true, features = [
4950
"socket",
5051
"user",
5152
] }
53+
object = { workspace = true, features = ["elf", "read_core"] }
5254
oci-distribution = { workspace = true, default-features = false, features = [
5355
"native-tls",
5456
"trust-dns",

‎bpfman/src/bin/cli/args.rs

+269-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright Authors of bpfman
33

4+
use std::{
5+
io::ErrorKind,
6+
path::{Path, PathBuf},
7+
str::FromStr,
8+
};
9+
410
use bpfman::types::ProgramType;
5-
use clap::{Args, Parser, Subcommand};
11+
use clap::{ArgGroup, Args, Parser, Subcommand};
612
use hex::FromHex;
713

814
#[derive(Parser, Debug)]
@@ -87,9 +93,8 @@ pub(crate) struct LoadImageArgs {
8793
#[command(flatten)]
8894
pub(crate) pull_args: PullBytecodeArgs,
8995

90-
/// Optional: The name of the function that is the entry point for the BPF program.
91-
/// If not provided, the program name defined as part of the bytecode image will be used.
92-
#[clap(short, long, verbatim_doc_comment, default_value = "")]
96+
/// Required: The name of the function that is the entry point for the eBPF program.
97+
#[clap(short, long, verbatim_doc_comment)]
9398
pub(crate) name: String,
9499

95100
/// Optional: Global variables to be set when program is loaded.
@@ -307,9 +312,269 @@ pub(crate) struct GetArgs {
307312

308313
#[derive(Subcommand, Debug)]
309314
#[command(disable_version_flag = true)]
315+
#[allow(clippy::large_enum_variant)]
310316
pub(crate) enum ImageSubCommand {
311317
/// Pull an eBPF bytecode image from a remote registry.
312318
Pull(PullBytecodeArgs),
319+
/// Build an eBPF bytecode image from local bytecode objects and push to a registry.
320+
///
321+
/// To use, the --container-file and --tag must be included, as well as a pointer to
322+
/// at least one bytecode file that can be passed in several ways. Use either:
323+
/// * --bytecode: for a single bytecode built for the host architecture.
324+
/// * --cilium-ebpf-project: for a cilium/ebpf project directory which contains
325+
/// multiple object files for different architectures.
326+
/// * --bc-386-el .. --bc-s390x-eb: to add one or more architecture specific bytecode files.
327+
///
328+
/// Examples:
329+
/// bpfman image build -f Containerfile.bytecode -t quay.io/<USER>/go-xdp-counter:test \
330+
/// -b ./examples/go-xdp-counter/bpf_x86_bpfel.o
331+
Build(BuildBytecodeArgs),
332+
/// Generate the OCI image labels for a given bytecode file.
333+
///
334+
/// To use, the --container-file and --tag must be included, as well as a pointer to
335+
/// at least one bytecode file that can be passed in several ways. Use either:
336+
/// * --bytecode: for a single bytecode built for the host architecture.
337+
/// * --cilium-ebpf-project: for a cilium/ebpf project directory which contains
338+
/// multiple object files for different architectures.
339+
/// * --bc-386-el .. --bc-s390x-eb: to add one or more architecture specific bytecode files.
340+
///
341+
/// Examples:
342+
/// bpfman image generate-build-args --bc-amd64-el ./examples/go-xdp-counter/bpf_x86_bpfel.o
343+
GenerateBuildArgs(GenerateArgs),
344+
}
345+
346+
/// GoArch represents the architectures understood by golang when the GOOS=linux.
347+
/// They are used here since the OCI spec and most container tools also use them.
348+
/// This structure is also the centralized entry point for specifying ALL multi-arch
349+
/// eBPF bytecode building.
350+
#[derive(Debug, Clone)]
351+
pub(crate) enum GoArch {
352+
X386,
353+
Amd64,
354+
Arm,
355+
Arm64,
356+
Loong64,
357+
Mips,
358+
Mipsle,
359+
Mips64,
360+
Mips64le,
361+
Ppc64,
362+
Ppc64le,
363+
Riscv64,
364+
S390x,
365+
}
366+
367+
impl FromStr for GoArch {
368+
type Err = std::io::Error;
369+
370+
fn from_str(s: &str) -> Result<Self, Self::Err> {
371+
match s {
372+
"386" => Ok(GoArch::X386),
373+
"amd64" => Ok(GoArch::Amd64),
374+
"arm" => Ok(GoArch::Arm),
375+
"arm64" => Ok(GoArch::Arm64),
376+
"loong64" => Ok(GoArch::Loong64),
377+
"mips" => Ok(GoArch::Mips),
378+
"mipsle" => Ok(GoArch::Mipsle),
379+
"mips64" => Ok(GoArch::Mips64),
380+
"mips64le" => Ok(GoArch::Mips64le),
381+
"ppc64" => Ok(GoArch::Ppc64),
382+
"ppc64le" => Ok(GoArch::Ppc64le),
383+
"riscv64" => Ok(GoArch::Riscv64),
384+
"s390x" => Ok(GoArch::S390x),
385+
_ => Err(std::io::Error::new(ErrorKind::InvalidInput, "not a valid bytecode arch, please refer to https://go.dev/doc/install/source#environment for valid GOARCHes when GOOS=linux.")),
386+
}
387+
}
388+
}
389+
390+
impl GoArch {
391+
/// Converts GoArch to a platform string ($GOOS/$GOARCH) that the container
392+
/// runtimes understand.
393+
pub(crate) fn get_platform(&self) -> String {
394+
match self {
395+
GoArch::X386 => "linux/386".to_string(),
396+
GoArch::Amd64 => "linux/amd64".to_string(),
397+
GoArch::Arm => "linux/arm".to_string(),
398+
GoArch::Arm64 => "linux/arm64".to_string(),
399+
GoArch::Loong64 => "linux/loong64".to_string(),
400+
GoArch::Mips => "linux/mips".to_string(),
401+
GoArch::Mipsle => "linux/mipsle".to_string(),
402+
GoArch::Mips64 => "linux/mips64".to_string(),
403+
GoArch::Mips64le => "linux/mips64le".to_string(),
404+
GoArch::Ppc64 => "linux/ppc64".to_string(),
405+
GoArch::Ppc64le => "linux/ppc64le".to_string(),
406+
GoArch::Riscv64 => "linux/riscv64".to_string(),
407+
GoArch::S390x => "linux/s390x".to_string(),
408+
}
409+
}
410+
411+
/// This must be in sync with the build args described in the
412+
/// Containerfile.bytecode.multi.arch file.
413+
pub(crate) fn get_build_arg(&self, bc: &Path) -> String {
414+
match self {
415+
GoArch::X386 => format!("BC_386_EL={}", bc.display()),
416+
GoArch::Amd64 => format!("BC_AMD64_EL={}", bc.display()),
417+
GoArch::Arm => format!("BC_ARM_EL={}", bc.display()),
418+
GoArch::Arm64 => format!("BC_ARM64_EL={}", bc.display()),
419+
GoArch::Loong64 => format!("BC_LOONG64_EL={}", bc.display()),
420+
GoArch::Mips => format!("BC_MIPS_EB={}", bc.display()),
421+
GoArch::Mipsle => format!("BC_MIPSLE_EL={}", bc.display()),
422+
GoArch::Mips64 => format!("BC_MIPS64_EB={}", bc.display()),
423+
GoArch::Mips64le => format!("BC_MIPS64LE_EL={}", bc.display()),
424+
GoArch::Ppc64 => format!("BC_PPC64_EB={}", bc.display()),
425+
GoArch::Ppc64le => format!("BC_PPC64LE_EL={}", bc.display()),
426+
GoArch::Riscv64 => format!("BC_RISCV64_EL={}", bc.display()),
427+
GoArch::S390x => format!("BC_S390X_EB={}", bc.display()),
428+
}
429+
}
430+
431+
/// Discovers the GoArch based on the cilium/ebpf project file-naming conventions.
432+
pub(crate) fn from_cilium_ebpf_file_str(s: &str) -> Result<Self, std::io::Error> {
433+
if s.contains("bpf_x86_bpfel.o") {
434+
Ok(GoArch::Amd64)
435+
} else if s.contains("bpf_arm_bpfel.o") {
436+
Ok(GoArch::Arm)
437+
} else if s.contains("bpf_arm64_bpfel.o") {
438+
Ok(GoArch::Arm64)
439+
} else if s.contains("bpf_loongarch_bpfel.o") {
440+
Ok(GoArch::Loong64)
441+
} else if s.contains("bpf_mips_bpfeb.o") {
442+
Ok(GoArch::Mips)
443+
} else if s.contains("bpf_powerpc_bpfeb.o") {
444+
Ok(GoArch::Ppc64)
445+
} else if s.contains("bpf_powerpc_bpfel.o") {
446+
Ok(GoArch::Ppc64le)
447+
} else if s.contains("bpf_riscv_bpfel.o") {
448+
Ok(GoArch::Riscv64)
449+
} else if s.contains("bpf_s390_bpfeb.o") {
450+
Ok(GoArch::S390x)
451+
} else {
452+
Err(std::io::Error::new(ErrorKind::InvalidInput, "not a valid cilium/ebpf bytecode filename, please refer to https://github.com/cilium/ebpf/blob/main/cmd/bpf2go/gen/target.go#L14"))
453+
}
454+
}
455+
}
456+
457+
#[derive(Args, Debug)]
458+
#[command(disable_version_flag = true)]
459+
pub(crate) struct BuildBytecodeArgs {
460+
/// Optional: bytecode file to use for building the image assuming host architecture.
461+
/// Example: -b ./bpf_x86_bpfel.o
462+
#[clap(flatten)]
463+
pub(crate) bytecode_file: BytecodeFile,
464+
465+
/// Required: Name and optionally a tag in the name:tag format.
466+
/// Example: --tag quay.io/bpfman-bytecode/xdp_pass:latest
467+
#[clap(short, long, verbatim_doc_comment)]
468+
pub(crate) tag: String,
469+
470+
/// Required: Dockerfile to use for building the image.
471+
/// Example: --container_file Containerfile.bytecode
472+
#[clap(short = 'f', long, verbatim_doc_comment)]
473+
pub(crate) container_file: PathBuf,
474+
475+
/// Optional: Container runtime to use, works with docker or podman, defaults to docker
476+
/// Example: --runtime podman
477+
#[clap(short, long, verbatim_doc_comment)]
478+
pub(crate) runtime: Option<String>,
479+
}
480+
481+
#[derive(Args, Debug)]
482+
#[clap(group(
483+
ArgGroup::new("bytecodefile")
484+
.multiple(false)
485+
.conflicts_with("multi-arch")
486+
.args(&["bytecode", "cilium_ebpf_project"]),
487+
))]
488+
#[clap(group(
489+
ArgGroup::new("multi-arch")
490+
.multiple(true)
491+
.args(&["bc_386_el", "bc_amd64_el", "bc_arm_el", "bc_arm64_el", "bc_loong64_el", "bc_mips_eb", "bc_mipsle_el", "bc_mips64_eb", "bc_mips64le_el", "bc_ppc64_eb", "bc_ppc64le_el", "bc_riscv64_el", "bc_s390x_eb"]),
492+
))]
493+
#[command(disable_version_flag = true)]
494+
#[group(required = true)]
495+
pub(crate) struct BytecodeFile {
496+
/// Optional: bytecode file to use for building the image assuming host architecture.
497+
/// Example: -b ./examples/go-xdp-counter/bpf_x86_bpfel.o
498+
#[clap(short, long, verbatim_doc_comment)]
499+
pub(crate) bytecode: Option<PathBuf>,
500+
501+
/// Optional: bytecode file to use for building the image assuming amd64 architecture.
502+
/// Example: --bc-386-el ./examples/go-xdp-counter/bpf_386_bpfel.o
503+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
504+
pub(crate) bc_386_el: Option<PathBuf>,
505+
506+
/// Optional: bytecode file to use for building the image assuming amd64 architecture.
507+
/// Example: --bc-amd64-el ./examples/go-xdp-counter/bpf_x86_bpfel.o
508+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
509+
pub(crate) bc_amd64_el: Option<PathBuf>,
510+
511+
/// Optional: bytecode file to use for building the image assuming arm architecture.
512+
/// Example: --bc-arm-el ./examples/go-xdp-counter/bpf_arm_bpfel.o
513+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
514+
pub(crate) bc_arm_el: Option<PathBuf>,
515+
516+
/// Optional: bytecode file to use for building the image assuming arm64 architecture.
517+
/// Example: --bc-arm64-el ./examples/go-xdp-counter/bpf_arm64_bpfel.o
518+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
519+
pub(crate) bc_arm64_el: Option<PathBuf>,
520+
521+
/// Optional: bytecode file to use for building the image assuming loong64 architecture.
522+
/// Example: --bc-loong64-el ./examples/go-xdp-counter/bpf_loong64_bpfel.o
523+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
524+
pub(crate) bc_loong64_el: Option<PathBuf>,
525+
526+
/// Optional: bytecode file to use for building the image assuming mips architecture.
527+
/// Example: --bc-mips-eb ./examples/go-xdp-counter/bpf_mips_bpfeb.o
528+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
529+
pub(crate) bc_mips_eb: Option<PathBuf>,
530+
531+
/// Optional: bytecode file to use for building the image assuming mipsle architecture.
532+
/// Example: --bc-mipsle-el ./examples/go-xdp-counter/bpf_mipsle_bpfel.o
533+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
534+
pub(crate) bc_mipsle_el: Option<PathBuf>,
535+
536+
/// Optional: bytecode file to use for building the image assuming mips64 architecture.
537+
/// Example: --bc-mips64-eb ./examples/go-xdp-counter/bpf_mips64_bpfeb.o
538+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
539+
pub(crate) bc_mips64_eb: Option<PathBuf>,
540+
541+
/// Optional: bytecode file to use for building the image assuming mips64le architecture.
542+
/// Example: --bc-mips64le-el ./examples/go-xdp-counter/bpf_mips64le_bpfel.o
543+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
544+
pub(crate) bc_mips64le_el: Option<PathBuf>,
545+
546+
/// Optional: bytecode file to use for building the image assuming ppc64 architecture.
547+
/// Example: --bc-ppc64-eb ./examples/go-xdp-counter/bpf_ppc64_bpfeb.o
548+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
549+
pub(crate) bc_ppc64_eb: Option<PathBuf>,
550+
551+
/// Optional: bytecode file to use for building the image assuming ppc64le architecture.
552+
/// Example: --bc-ppc64le-el ./examples/go-xdp-counter/bpf_ppc64le_bpfel.o
553+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
554+
pub(crate) bc_ppc64le_el: Option<PathBuf>,
555+
556+
/// Optional: bytecode file to use for building the image assuming riscv64 architecture.
557+
/// Example: --bc-riscv64-el ./examples/go-xdp-counter/bpf_riscv64_bpfel.o
558+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
559+
pub(crate) bc_riscv64_el: Option<PathBuf>,
560+
561+
/// Optional: bytecode file to use for building the image assuming s390x architecture.
562+
/// Example: --bc-s390x-eb ./examples/go-xdp-counter/bpf_s390x_bpfeb.o
563+
#[clap(long, verbatim_doc_comment, group = "multi-arch")]
564+
pub(crate) bc_s390x_eb: Option<PathBuf>,
565+
566+
/// Optional: If specified pull multi-arch bytecode files from a cilium/ebpf formatted project
567+
/// where the bytecode files all contain a standard bpf_<GOARCH>_<(el/eb)>.o tag.
568+
/// Example: --cilium-ebpf-project ./examples/go-xdp-counter
569+
#[clap(short, long, verbatim_doc_comment)]
570+
pub(crate) cilium_ebpf_project: Option<PathBuf>,
571+
}
572+
573+
#[derive(Args, Debug)]
574+
#[command(disable_version_flag = true)]
575+
pub(crate) struct GenerateArgs {
576+
#[clap(flatten)]
577+
pub(crate) bytecode: BytecodeFile,
313578
}
314579

315580
#[derive(Args, Debug)]

‎bpfman/src/bin/cli/image.rs

+460-2
Large diffs are not rendered by default.

‎bpfman/src/errors.rs

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ pub enum BpfmanError {
4040
image_prog_name: String,
4141
provided_prog_name: String,
4242
},
43+
#[error("Program {expected_prog_name} not found in bytecode image {bytecode_image} with program names {program_names:?}")]
44+
ProgramNotFoundInBytecode {
45+
bytecode_image: String,
46+
expected_prog_name: String,
47+
program_names: Vec<String>,
48+
},
4349
#[error("Unable to delete program {0}")]
4450
BpfmanProgramDeleteError(#[source] anyhow::Error),
4551
#[error(transparent)]
@@ -69,6 +75,8 @@ pub enum BpfmanError {
6975
pub enum ParseError {
7076
#[error("{program} is not a valid program type")]
7177
InvalidProgramType { program: String },
78+
#[error("{map} is not a valid map type")]
79+
InvalidMapType { map: String },
7280
#[error("{proceedon} is not a valid proceed-on value")]
7381
InvalidProceedOn { proceedon: String },
7482
#[error("not a valid direction: {direction}")]

‎bpfman/src/multiprog/tc.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::{
3636

3737
const DEFAULT_PRIORITY: u32 = 50; // Default priority for user programs in the dispatcher
3838
const TC_DISPATCHER_PRIORITY: u16 = 50; // Default TC priority for TC Dispatcher
39+
const TC_DISPATCHER_PROGRAM_NAME: &str = "tc_dispatcher";
3940

4041
/// These constants define the key of SLED DB
4142
const REVISION: &str = "revision";
@@ -127,7 +128,7 @@ impl TcDispatcher {
127128
None,
128129
);
129130

130-
let (path, bpf_function_name) = image_manager
131+
let (path, bpf_program_names) = image_manager
131132
.get_image(
132133
root_db,
133134
&image.image_url,
@@ -137,14 +138,24 @@ impl TcDispatcher {
137138
)
138139
.await?;
139140

141+
if !bpf_program_names.contains(&TC_DISPATCHER_PROGRAM_NAME.to_string()) {
142+
return Err(BpfmanError::ProgramNotFoundInBytecode {
143+
bytecode_image: image.image_url,
144+
expected_prog_name: TC_DISPATCHER_PROGRAM_NAME.to_string(),
145+
program_names: bpf_program_names,
146+
});
147+
}
148+
140149
let program_bytes = image_manager.get_bytecode_from_image_store(root_db, path)?;
141150

142151
let mut loader = BpfLoader::new()
143152
.set_global("CONFIG", &config, true)
144153
.load(&program_bytes)?;
145154

146-
let dispatcher: &mut SchedClassifier =
147-
loader.program_mut(&bpf_function_name).unwrap().try_into()?;
155+
let dispatcher: &mut SchedClassifier = loader
156+
.program_mut(TC_DISPATCHER_PROGRAM_NAME)
157+
.unwrap()
158+
.try_into()?;
148159

149160
dispatcher.load()?;
150161

@@ -157,7 +168,7 @@ impl TcDispatcher {
157168

158169
self.loader = Some(loader);
159170
self.set_num_extensions(extensions.len())?;
160-
self.set_program_name(&bpf_function_name)?;
171+
self.set_program_name(TC_DISPATCHER_PROGRAM_NAME)?;
161172

162173
self.attach_extensions(&mut extensions)?;
163174
self.attach(root_db, old_dispatcher).await?;

‎bpfman/src/multiprog/xdp.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::{
2929
};
3030

3131
pub(crate) const DEFAULT_PRIORITY: u32 = 50;
32+
const XDP_DISPATCHER_PROGRAM_NAME: &str = "xdp_dispatcher";
3233

3334
/// These constants define the key of SLED DB
3435
const REVISION: &str = "revision";
@@ -123,7 +124,7 @@ impl XdpDispatcher {
123124
None,
124125
);
125126

126-
let (path, bpf_function_name) = image_manager
127+
let (path, bpf_program_names) = image_manager
127128
.get_image(
128129
root_db,
129130
&image.image_url.clone(),
@@ -133,13 +134,24 @@ impl XdpDispatcher {
133134
)
134135
.await?;
135136

137+
if !bpf_program_names.contains(&XDP_DISPATCHER_PROGRAM_NAME.to_string()) {
138+
return Err(BpfmanError::ProgramNotFoundInBytecode {
139+
bytecode_image: image.image_url,
140+
expected_prog_name: XDP_DISPATCHER_PROGRAM_NAME.to_string(),
141+
program_names: bpf_program_names,
142+
});
143+
}
144+
136145
let program_bytes = image_manager.get_bytecode_from_image_store(root_db, path)?;
137146

138147
let mut loader = BpfLoader::new()
139148
.set_global("conf", &config, true)
140149
.load(&program_bytes)?;
141150

142-
let dispatcher: &mut Xdp = loader.program_mut(&bpf_function_name).unwrap().try_into()?;
151+
let dispatcher: &mut Xdp = loader
152+
.program_mut(XDP_DISPATCHER_PROGRAM_NAME)
153+
.unwrap()
154+
.try_into()?;
143155

144156
dispatcher.load()?;
145157

@@ -148,7 +160,7 @@ impl XdpDispatcher {
148160

149161
self.loader = Some(loader);
150162
self.set_num_extensions(extensions.len())?;
151-
self.set_program_name(&bpf_function_name)?;
163+
self.set_program_name(XDP_DISPATCHER_PROGRAM_NAME)?;
152164

153165
self.attach_extensions(&mut extensions)?;
154166
self.attach()?;

‎bpfman/src/oci_utils/image_manager.rs

+180-91
Large diffs are not rendered by default.

‎bpfman/src/oci_utils/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub enum ImageError {
1414
ImageManifestPullFailure(#[source] oci_distribution::errors::OciDistributionError),
1515
#[error("Failed to pull bytecode Image: {0}")]
1616
BytecodeImagePullFailure(#[source] oci_distribution::errors::OciDistributionError),
17-
#[error("Failed to extract bytecode from Image")]
18-
BytecodeImageExtractFailure,
17+
#[error("Failed to extract bytecode from Image: {0}")]
18+
BytecodeImageExtractFailure(String),
1919
#[error(transparent)]
2020
ByteCodeImageProcessFailure(#[from] anyhow::Error),
2121
#[error("BytecodeImage not found: {0}")]

‎bpfman/src/types.rs

+179-17
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{
1212
use aya::programs::ProgramInfo as AyaProgInfo;
1313
use chrono::{prelude::DateTime, Local};
1414
use clap::ValueEnum;
15-
use log::{debug, info, warn};
15+
use log::{info, warn};
1616
use rand::Rng;
1717
use serde::{Deserialize, Serialize};
1818
use sled::Db;
@@ -224,11 +224,11 @@ impl Location {
224224
&self,
225225
root_db: &Db,
226226
image_manager: &mut ImageManager,
227-
) -> Result<(Vec<u8>, String), BpfmanError> {
227+
) -> Result<(Vec<u8>, Vec<String>), BpfmanError> {
228228
match self {
229-
Location::File(l) => Ok((crate::utils::read(l)?, "".to_owned())),
229+
Location::File(l) => Ok((crate::utils::read(l)?, Vec::new())),
230230
Location::Image(l) => {
231-
let (path, bpf_function_name) = image_manager
231+
let (path, bpf_function_names) = image_manager
232232
.get_image(
233233
root_db,
234234
&l.image_url,
@@ -239,7 +239,7 @@ impl Location {
239239
.await?;
240240
let bytecode = image_manager.get_bytecode_from_image_store(root_db, path)?;
241241

242-
Ok((bytecode, bpf_function_name))
242+
Ok((bytecode, bpf_function_names))
243243
}
244244
}
245245
}
@@ -620,19 +620,17 @@ impl ProgramData {
620620
"Loading program bytecode from container image: {}",
621621
l.get_url()
622622
);
623-
// If program name isn't provided and we're loading from a container
624-
// image use the program name provided in the image metadata, otherwise
625-
// always use the provided program name.
626-
let provided_name = self.get_name()?.clone();
627623

628-
if provided_name.is_empty() {
629-
self.set_name(&s)?;
630-
} else if s != provided_name {
631-
debug!(
632-
"Bytecode image bpf function name: {} isn't equal to the provided bpf function name: {}",
633-
s,
634-
provided_name
635-
);
624+
// Error out if the bytecode image doesn't contain the expected program.
625+
let provided_name = self.get_name()?.clone();
626+
if s.contains(&provided_name) {
627+
self.set_name(&provided_name)?;
628+
} else {
629+
return Err(BpfmanError::ProgramNotFoundInBytecode {
630+
bytecode_image: l.image_url,
631+
expected_prog_name: provided_name,
632+
program_names: s,
633+
});
636634
}
637635
}
638636
Location::File(l) => {
@@ -1530,6 +1528,134 @@ impl Program {
15301528
}
15311529
}
15321530

1531+
/// MapType must match the the bpf_map_type enum defined in the linux kernel.
1532+
/// <https://elixir.bootlin.com/linux/v6.9.5/source/include/uapi/linux/bpf.h#L964>
1533+
#[derive(Debug)]
1534+
pub enum MapType {
1535+
Unspec,
1536+
Hash,
1537+
Array,
1538+
ProgArray,
1539+
PerfEventArray,
1540+
PerCpuHash,
1541+
PerCpuArray,
1542+
StackTrace,
1543+
CgroupArray,
1544+
LruHash,
1545+
LruPerCpuHash,
1546+
LpmTrie,
1547+
ArrayOfMaps,
1548+
HashOfMaps,
1549+
Devmap,
1550+
Sockmap,
1551+
Cpumap,
1552+
Xskmap,
1553+
Sockhash,
1554+
CgroupStorage,
1555+
ReuseportSockarray,
1556+
PerCpuCgroupStorage,
1557+
Queue,
1558+
Stack,
1559+
SkStorage,
1560+
DevmapHash,
1561+
StructOps,
1562+
Ringbuf,
1563+
InodeStorage,
1564+
TaskStorage,
1565+
BloomFilter,
1566+
UserRingbuf,
1567+
CgrpStorage,
1568+
Arena,
1569+
}
1570+
1571+
/// This function is only used in the oci-utils for taking an object
1572+
/// file parsed by aya-obj, pulling out the maps included in it, and
1573+
/// presenting it in a user frendly manner, it will panic if it's called
1574+
/// with a non-checked integer, only use where pre-processing has occured.
1575+
impl From<u32> for MapType {
1576+
fn from(value: u32) -> Self {
1577+
match value {
1578+
0 => MapType::Unspec,
1579+
1 => MapType::Hash,
1580+
2 => MapType::Array,
1581+
3 => MapType::ProgArray,
1582+
4 => MapType::PerfEventArray,
1583+
5 => MapType::PerCpuHash,
1584+
6 => MapType::PerCpuArray,
1585+
7 => MapType::StackTrace,
1586+
8 => MapType::CgroupArray,
1587+
9 => MapType::LruHash,
1588+
10 => MapType::LruPerCpuHash,
1589+
11 => MapType::LpmTrie,
1590+
12 => MapType::ArrayOfMaps,
1591+
13 => MapType::HashOfMaps,
1592+
14 => MapType::Devmap,
1593+
15 => MapType::Sockmap,
1594+
16 => MapType::Cpumap,
1595+
17 => MapType::Xskmap,
1596+
18 => MapType::Sockhash,
1597+
20 => MapType::ReuseportSockarray,
1598+
22 => MapType::Queue,
1599+
23 => MapType::Stack,
1600+
24 => MapType::SkStorage,
1601+
25 => MapType::DevmapHash,
1602+
26 => MapType::StructOps,
1603+
27 => MapType::Ringbuf,
1604+
28 => MapType::InodeStorage,
1605+
29 => MapType::TaskStorage,
1606+
30 => MapType::BloomFilter,
1607+
31 => MapType::UserRingbuf,
1608+
32 => MapType::CgrpStorage,
1609+
33 => MapType::Arena,
1610+
v => panic!("Unknown map type {v}"),
1611+
}
1612+
}
1613+
}
1614+
1615+
impl std::fmt::Display for MapType {
1616+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1617+
let v = match self {
1618+
MapType::Unspec => "unspec",
1619+
MapType::Hash => "hash",
1620+
MapType::Array => "array",
1621+
MapType::ProgArray => "prog_array",
1622+
MapType::PerfEventArray => "perf_event_array",
1623+
MapType::PerCpuHash => "per_cpu_hash",
1624+
MapType::PerCpuArray => "per_cpu_array",
1625+
MapType::StackTrace => "stack_trace",
1626+
MapType::CgroupArray => "cgroup_array",
1627+
MapType::LruHash => "lru_hash",
1628+
MapType::LruPerCpuHash => "lru_per_cpu_hash",
1629+
MapType::LpmTrie => "lpm_trie",
1630+
MapType::ArrayOfMaps => "array_of_maps",
1631+
MapType::HashOfMaps => "hash_of_maps",
1632+
MapType::Devmap => "devmap",
1633+
MapType::Sockmap => "sockmap",
1634+
MapType::Cpumap => "cpumap",
1635+
MapType::Xskmap => "xskmap",
1636+
MapType::Sockhash => "sockhash",
1637+
MapType::CgroupStorage => "cgroup_storage",
1638+
MapType::ReuseportSockarray => "reuseport_sockarray",
1639+
MapType::PerCpuCgroupStorage => "per_cpu_cgroup_storage",
1640+
MapType::Queue => "queue",
1641+
MapType::Stack => "stack",
1642+
MapType::SkStorage => "sk_storage",
1643+
MapType::DevmapHash => "devmap_hash",
1644+
MapType::StructOps => "struct_ops",
1645+
MapType::Ringbuf => "ringbuf",
1646+
MapType::InodeStorage => "inode_storage",
1647+
MapType::TaskStorage => "task_storage",
1648+
MapType::BloomFilter => "bloom_filter",
1649+
MapType::UserRingbuf => "user_ringbuf",
1650+
MapType::CgrpStorage => "cgrp_storage",
1651+
MapType::Arena => "arena",
1652+
};
1653+
write!(f, "{}", v)
1654+
}
1655+
}
1656+
1657+
/// ProgramType must match the the bpf_prog_type enum defined in the linux kernel.
1658+
/// <https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/bpf.h#L1024>
15331659
#[derive(ValueEnum, Copy, Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
15341660
pub enum ProgramType {
15351661
Unspec,
@@ -1566,6 +1692,42 @@ pub enum ProgramType {
15661692
Syscall,
15671693
}
15681694

1695+
impl From<aya_obj::ProgramSection> for ProgramType {
1696+
fn from(value: aya_obj::ProgramSection) -> Self {
1697+
match value {
1698+
aya_obj::ProgramSection::KRetProbe => ProgramType::Probe,
1699+
aya_obj::ProgramSection::KProbe => ProgramType::Probe,
1700+
aya_obj::ProgramSection::UProbe { .. } => ProgramType::Probe,
1701+
aya_obj::ProgramSection::URetProbe { .. } => ProgramType::Probe,
1702+
aya_obj::ProgramSection::TracePoint => ProgramType::Tracepoint,
1703+
aya_obj::ProgramSection::SocketFilter => ProgramType::SocketFilter,
1704+
aya_obj::ProgramSection::Xdp { .. } => ProgramType::Xdp,
1705+
aya_obj::ProgramSection::SkMsg => ProgramType::SkMsg,
1706+
aya_obj::ProgramSection::SkSkbStreamParser => ProgramType::SkSkb,
1707+
aya_obj::ProgramSection::SkSkbStreamVerdict => ProgramType::SkSkb,
1708+
aya_obj::ProgramSection::SockOps => ProgramType::SockOps,
1709+
aya_obj::ProgramSection::SchedClassifier => ProgramType::Tc,
1710+
aya_obj::ProgramSection::CgroupSkb => ProgramType::CgroupSkb,
1711+
aya_obj::ProgramSection::CgroupSkbIngress => ProgramType::CgroupSkb,
1712+
aya_obj::ProgramSection::CgroupSkbEgress => ProgramType::CgroupSkb,
1713+
aya_obj::ProgramSection::CgroupSockAddr { .. } => ProgramType::CgroupSockAddr,
1714+
aya_obj::ProgramSection::CgroupSysctl => ProgramType::CgroupSysctl,
1715+
aya_obj::ProgramSection::CgroupSockopt { .. } => ProgramType::CgroupSockopt,
1716+
aya_obj::ProgramSection::LircMode2 => ProgramType::LircMode2,
1717+
aya_obj::ProgramSection::PerfEvent => ProgramType::PerfEvent,
1718+
aya_obj::ProgramSection::RawTracePoint => ProgramType::RawTracepoint,
1719+
aya_obj::ProgramSection::Lsm { .. } => ProgramType::Lsm,
1720+
aya_obj::ProgramSection::BtfTracePoint => ProgramType::Tracepoint,
1721+
aya_obj::ProgramSection::FEntry { .. } => ProgramType::Tracing,
1722+
aya_obj::ProgramSection::FExit { .. } => ProgramType::Tracing,
1723+
aya_obj::ProgramSection::Extension => ProgramType::Ext,
1724+
aya_obj::ProgramSection::SkLookup => ProgramType::SkLookup,
1725+
aya_obj::ProgramSection::CgroupSock { .. } => ProgramType::CgroupSock,
1726+
aya_obj::ProgramSection::CgroupDevice { .. } => ProgramType::CgroupDevice,
1727+
}
1728+
}
1729+
}
1730+
15691731
impl TryFrom<String> for ProgramType {
15701732
type Error = ParseError;
15711733

‎docs/developer-guide/shipping-bytecode.md

+88-37
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ bytecode to all nodes which need it.
1010

1111
## Specifications
1212

13-
We provide two distinct spec variants here to ensure interoperatiblity with existing registries
14-
and packages which do no support the new custom media types defined here.
13+
We provide two distinct spec variants here to ensure interoperability with existing registries
14+
and packages which do not support the new custom media types defined here.
1515

1616
- [custom-data-type-spec](#custom-oci-compatible-spec)
1717
- [backwards-compatable-spec](#backwards-compatible-oci-compliant-spec)
@@ -36,35 +36,34 @@ a `.o` extension) placed at the root of the layer `./`.
3636
To provide relevant metadata regarding the bytecode to any consumers, some relevant labels
3737
**MUST** be defined on the image.
3838

39-
These labels are defined as follows:
39+
These labels are dynamic and defined as follows:
4040

41-
- `io.ebpf.program_type`: The eBPF program type (i.e `xdp`,`tc`, `sockops`, ...).
41+
- `io.ebpf.programs`: A label which defines the eBPF programs stored in the bytecode image.
42+
The value of the label is a list which must contain a valid JSON object with
43+
Key's specifying the program name, and values specifying the program type i.e:
44+
"{ "pass" : "xdp" , "counter" : "tc", ...}".
4245

43-
- `io.ebpf.filename`: The Filename of the bytecode stored in the image.
44-
45-
- `io.ebpf.program_name`: The name of the eBPF Program represented in the bytecode.
46-
47-
- `io.ebpf.bpf_function_name`: The name of the function that is the entry point for the BPF program.
46+
- `io.ebpf.maps`: A label which defines the eBPF maps stored in the bytecode image.
47+
The value of the label is a list which must contain a valid JSON object with
48+
Key's specifying the map name, and values specifying the map type i.e:
49+
"{ "xdp_stats_map" : "per_cpu_array", ...}".
4850

4951
### Building a Backwards compatible OCI compliant image
5052

51-
An Example Containerfile can be found at `/packaging/container/deployment/Containerfile.bytecode`
53+
Bpfman does not provide wrappers around compilers like clang since many eBPF
54+
libraries (i.e aya, libbpf, cilium-ebpf) already do so, meaning users are expected
55+
to pass in the correct ebpf program bytecode for the appropriate platform. However,
56+
bpfman does provide a few image builder commands to make this whole process easier.
5257

53-
To use the provided templated Containerfile simply run a `docker build` command
54-
like the following:
58+
Example Containerfiles for single-arch and multi-arch can be found at `Containerfile.bytecode` and `Containerfile.bytecode.multi.arch`.
5559

56-
```bash
57-
docker build \
58-
--build-arg PROGRAM_NAME=xdp_pass \
59-
--build-arg BPF_FUNCTION_NAME=pass \
60-
--build-arg PROGRAM_TYPE=xdp \
61-
--build-arg BYTECODE_FILENAME=pass.bpf.o \
62-
--build-arg KERNEL_COMPILE_VER=$(uname -r) \
63-
-f Containerfile.bytecode \
64-
/home/<USER>/bytecode -t quay.io/<USER>/xdp_pass:latest
60+
#### Host Platform Architecture Image Build
61+
62+
```console
63+
bpfman image build -b ./examples/go-xdp-counter/bpf_bpfel.o -f Containerfile.bytecode --tag quay.io/<USER>/go-xdp-counter
6564
```
6665

67-
Where `/home/<USER>/bytecode` is the directory the bytecode object file is located.
66+
Where `./examples/go-xdp-counter/bpf_x86_bpfel.o` is the path to the bytecode object file.
6867

6968
Users can also use `skopeo` to ensure the image follows the
7069
backwards compatible version of the spec:
@@ -73,38 +72,90 @@ backwards compatible version of the spec:
7372
configuration layer (`application/vnd.oci.image.config.v1+json`) of the image.
7473

7574
```bash
76-
skopeo inspect docker://quay.io/astoycos/xdp_pass:latest
75+
skopeo inspect docker://quay.io/bpfman-bytecode/go-xdp-counter
7776
{
78-
"Name": "quay.io/<USER>/xdp_pass",
79-
"Digest": "sha256:db1f7dd03f9fba0913e07493238fcfaf0bf08de37b8e992cc5902775dfb9086a",
77+
"Name": "quay.io/bpfman-bytecode/go-xdp-counter",
78+
"Digest": "sha256:e8377e94c56272937689af88a1a6231d4d594f83218b5cda839eaeeea70a30d3",
8079
"RepoTags": [
8180
"latest"
8281
],
83-
"Created": "2022-08-14T14:27:20.147468277Z",
82+
"Created": "2024-05-30T09:17:15.327378016-04:00",
8483
"DockerVersion": "",
8584
"Labels": {
86-
"io.buildah.version": "1.26.1",
87-
"io.ebpf.filename": "pass.bpf.o",
88-
"io.ebpf.program_name": "xdp_counter",
89-
"io.ebpf.program_type": "xdp",
90-
"io.ebpf.bpf_function_name": "pass"
85+
"io.ebpf.maps": "{\"xdp_stats_map\":\"per_cpu_array\"}",
86+
"io.ebpf.programs": "{\"xdp_stats\":\"xdp\"}"
9187
},
9288
"Architecture": "amd64",
9389
"Os": "linux",
9490
"Layers": [
95-
"sha256:5f6dae6f567601fdad15a936d844baac1f30c31bd3df8df0c5b5429f3e048000"
91+
"sha256:c0d921d3f0d077da7cdfba8c0240fb513789e7698cdf326f80f30f388c084cff"
92+
],
93+
"LayersData": [
94+
{
95+
"MIMEType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
96+
"Digest": "sha256:c0d921d3f0d077da7cdfba8c0240fb513789e7698cdf326f80f30f388c084cff",
97+
"Size": 2656,
98+
"Annotations": null
99+
}
96100
],
97101
"Env": [
98102
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
99103
]
100104
}
101105
```
102106

103-
- `skopeo inspect --raw` will show the correct layer type is used in the image.
107+
#### Multi-Architecture Image build
104108

105-
```bash
106-
skopeo inspect --raw docker://quay.io/astoycos/xdp_pass:latest
107-
{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:ff4108b8405a877b2df3e06f9287c509b9d62d6c241c9a5213d81a9abee80361","size":2385},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar+gzip","digest":"sha256:5f6dae6f567601fdad15a936d844baac1f30c31bd3df8df0c5b5429f3e048000","size":1539}],"annotations":{"org.opencontainers.image.base.digest":"sha256:86b59a6cf7046c624c47e40a5618b383d763be712df2c0e7aaf9391c2c9ef559","org.opencontainers.image.base.name":""}}
109+
```console
110+
bpfman image build -t quay.io/bpfman-bytecode/go-xdp-counter-multi --container-file ./Containerfile.bytecode.multi.arch --bc-amd64-el ./examples/go-xdp-counter/bpf_arm64_bpfel.o --bc-s390x-eb ./examples/go-xdp-counter/bpf_s390_bpfeb.o
111+
```
112+
113+
To better understand the available architectures users can use `podman manifest-inspect`
114+
115+
```console
116+
podman manifest inspect quay.io/bpfman-bytecode/go-xdp-counter:test-manual-build
117+
{
118+
"schemaVersion": 2,
119+
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
120+
"manifests": [
121+
{
122+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
123+
"size": 478,
124+
"digest": "sha256:aed62d2e5867663fac66822422512a722003b40453325fd873bbb5840d78cba9",
125+
"platform": {
126+
"architecture": "amd64",
127+
"os": "linux"
128+
}
129+
},
130+
{
131+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
132+
"size": 478,
133+
"digest": "sha256:a348fe2f26dc0851518d8d82e1049d2c39cc2e4f37419fe9231c1967abc4828c",
134+
"platform": {
135+
"architecture": "arm64",
136+
"os": "linux"
137+
}
138+
},
139+
{
140+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
141+
"size": 478,
142+
"digest": "sha256:d5c5d41d2d21e0cb5fb79fe9f343e540942c9a1657cf0de96b8f63e43d369743",
143+
"platform": {
144+
"architecture": "ppc64le",
145+
"os": "linux"
146+
}
147+
},
148+
{
149+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
150+
"size": 478,
151+
"digest": "sha256:7915c83838d73268690381b313fb84b5509912aa351c98c78204584cced50efd",
152+
"platform": {
153+
"architecture": "s390x",
154+
"os": "linux"
155+
}
156+
},
157+
]
158+
}
108159
```
109160

110161
## Custom OCI compatible spec
@@ -113,4 +164,4 @@ This variant of the eBPF bytecode image spec uses custom OCI medium types
113164
to represent eBPF bytecode as container images. Many toolchains and registries
114165
may not support this yet.
115166

116-
TODO(astoycos)
167+
TODO https://github.com/bpfman/bpfman/issues/1162

‎examples/build-bytecode-images.sh

-54
This file was deleted.

‎examples/go-app-counter/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import (
1717
)
1818

1919
const (
20-
DefaultByteCodeFile = "bpf_bpfel.o"
20+
DefaultByteCodeFile = "bpf_x86_bpfel.o"
2121
ApplicationMapsMountPoint = "/run/app/maps"
2222
)
2323

2424
var appMutex = &sync.Mutex{}
2525
var c gobpfman.BpfmanClient
2626
var ctx context.Context
2727

28-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" bpf ./bpf/app_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
28+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" -target amd64,arm64,ppc64le,s390x bpf ./bpf/app_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
2929

3030
func main() {
3131
var conn *grpc.ClientConn

‎examples/go-kprobe-counter/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
const (
2222
KprobeProgramName = "go-kprobe-counter-example"
2323
BpfProgramMapIndex = "kprobe_stats_map"
24-
DefaultByteCodeFile = "bpf_bpfel.o"
24+
DefaultByteCodeFile = "bpf_x86_bpfel.o"
2525

2626
// MapsMountPoint is the "go-kprobe-counter-maps" volumeMount "mountPath" from "deployment.yaml"
2727
MapsMountPoint = "/run/kprobe/maps"
@@ -31,7 +31,7 @@ type Stats struct {
3131
Counter uint64
3232
}
3333

34-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" bpf ./bpf/kprobe_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
34+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" -target amd64,arm64,ppc64le,s390x bpf ./bpf/kprobe_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
3535
func main() {
3636
stop := make(chan os.Signal, 1)
3737
signal.Notify(stop, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)

‎examples/go-tc-counter/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Stats struct {
2424
}
2525

2626
const (
27-
DefaultByteCodeFile = "bpf_bpfel.o"
27+
DefaultByteCodeFile = "bpf_x86_bpfel.o"
2828
TcProgramName = "go-tc-counter-example"
2929
BpfProgramMapIndex = "tc_stats_map"
3030

@@ -36,7 +36,7 @@ const (
3636
TC_ACT_OK = 0
3737
)
3838

39-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" bpf ./bpf/tc_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
39+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" -target amd64,arm64,ppc64le,s390x bpf ./bpf/tc_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
4040
func main() {
4141
stop := make(chan os.Signal, 1)
4242
signal.Notify(stop, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)

‎examples/go-tracepoint-counter/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
const (
2222
TracepointProgramName = "go-tracepoint-counter-example"
2323
BpfProgramMapIndex = "tracepoint_stats_map"
24-
DefaultByteCodeFile = "bpf_bpfel.o"
24+
DefaultByteCodeFile = "bpf_x86_bpfel.o"
2525

2626
// MapsMountPoint is the "go-tracepoint-counter-maps" volumeMount "mountPath" from "deployment.yaml"
2727
MapsMountPoint = "/run/tracepoint/maps"
@@ -31,7 +31,7 @@ type Stats struct {
3131
Calls uint64
3232
}
3333

34-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" bpf ./bpf/tracepoint_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
34+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" -target amd64,arm64,ppc64le,s390x bpf ./bpf/tracepoint_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
3535
func main() {
3636
stop := make(chan os.Signal, 1)
3737
signal.Notify(stop, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)

‎examples/go-uprobe-counter/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
const (
2222
UprobeProgramName = "go-uprobe-counter-example"
2323
BpfProgramMapIndex = "uprobe_stats_map"
24-
DefaultByteCodeFile = "bpf_bpfel.o"
24+
DefaultByteCodeFile = "bpf_x86_bpfel.o"
2525

2626
// MapsMountPoint is the "go-uprobe-counter-maps" volumeMount "mountPath" from "deployment.yaml"
2727
MapsMountPoint = "/run/uprobe/maps"
@@ -31,7 +31,7 @@ type Stats struct {
3131
Counter uint64
3232
}
3333

34-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" bpf ./bpf/uprobe_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
34+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" -target amd64,arm64,ppc64le,s390x bpf ./bpf/uprobe_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
3535
func main() {
3636
stop := make(chan os.Signal, 1)
3737
signal.Notify(stop, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)

‎examples/go-uretprobe-counter/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
MapsMountPoint = "/run/uretprobe/maps"
2727
)
2828

29-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" -target amd64 bpf ./bpf/uretprobe_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
29+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" -target amd64,arm64,ppc64le,s390x bpf ./bpf/uretprobe_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
3030

3131
func main() {
3232
stop := make(chan os.Signal, 1)

‎examples/go-xdp-counter/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Stats struct {
2424
}
2525

2626
const (
27-
DefaultByteCodeFile = "bpf_bpfel.o"
27+
DefaultByteCodeFile = "bpf_x86_bpfel.o"
2828
XdpProgramName = "go-xdp-counter-example"
2929
BpfProgramMapIndex = "xdp_stats_map"
3030

@@ -36,7 +36,7 @@ const (
3636
XDP_ACT_OK = 2
3737
)
3838

39-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" bpf ./bpf/xdp_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
39+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -no-strip -cflags "-O2 -g -Wall" -target amd64,arm64,ppc64le,s390x bpf ./bpf/xdp_counter.c -- -I.:/usr/include/bpf:/usr/include/linux
4040
func main() {
4141
stop := make(chan os.Signal, 1)
4242
signal.Notify(stop, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)

‎tests/integration-test/bpf/build_push_images.sh

-104
This file was deleted.

‎tests/integration-test/src/tests/basic.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn test_load_unload_xdp() {
5656
lt,
5757
&XDP_PASS_IMAGE_LOC,
5858
XDP_PASS_FILE_LOC,
59-
Some(XDP_PASS_NAME),
59+
XDP_PASS_NAME,
6060
None, // metadata
6161
None, // map_owner_id
6262
);
@@ -95,7 +95,7 @@ fn test_map_sharing_load_unload_xdp() {
9595
&load_type,
9696
&XDP_COUNTER_IMAGE_LOC,
9797
"", // file_path
98-
None,
98+
XDP_COUNTER_NAME,
9999
None, // metadata
100100
None, // map_owner_id
101101
);
@@ -131,7 +131,7 @@ fn test_map_sharing_load_unload_xdp() {
131131
&load_type,
132132
&XDP_COUNTER_IMAGE_LOC,
133133
"", // file_path
134-
None,
134+
XDP_COUNTER_NAME,
135135
None, // metadata
136136
map_owner_id_u32,
137137
);
@@ -227,6 +227,7 @@ fn test_load_unload_tc() {
227227
lt,
228228
&TC_PASS_IMAGE_LOC,
229229
TC_PASS_FILE_LOC,
230+
TC_PASS_NAME,
230231
);
231232
loaded_ids.push(prog_id.unwrap());
232233
}
@@ -263,6 +264,7 @@ fn test_load_unload_tracepoint() {
263264
&TRACEPOINT_IMAGE_LOC,
264265
TRACEPOINT_FILE_LOC,
265266
TRACEPOINT_TRACEPOINT_NAME,
267+
TRACEPOINT_NAME,
266268
);
267269
loaded_ids.push(prog_id.unwrap());
268270
}
@@ -409,7 +411,7 @@ fn test_list_with_metadata() {
409411
lt,
410412
&XDP_PASS_IMAGE_LOC,
411413
XDP_PASS_FILE_LOC,
412-
Some(XDP_PASS_NAME),
414+
XDP_PASS_NAME,
413415
None, // metadata
414416
None, // map_owner_id
415417
);
@@ -427,7 +429,7 @@ fn test_list_with_metadata() {
427429
&LoadType::Image,
428430
&XDP_PASS_IMAGE_LOC,
429431
XDP_PASS_FILE_LOC,
430-
Some(XDP_PASS_NAME),
432+
XDP_PASS_NAME,
431433
Some(vec![key]),
432434
None, // map_owner_id
433435
);

‎tests/integration-test/src/tests/e2e.rs

+26-9
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn test_proceed_on_xdp() {
4848
&LoadType::Image,
4949
&XDP_PASS_IMAGE_LOC,
5050
XDP_PASS_FILE_LOC,
51-
Some(XDP_PASS_NAME),
51+
XDP_PASS_NAME,
5252
None, // metadata
5353
None, // map_owner_id
5454
);
@@ -78,7 +78,7 @@ fn test_proceed_on_xdp() {
7878
&LoadType::Image,
7979
&XDP_PASS_IMAGE_LOC,
8080
XDP_PASS_FILE_LOC,
81-
Some(XDP_PASS_NAME),
81+
XDP_PASS_NAME,
8282
None, // metadata
8383
None, // map_owner_id
8484
);
@@ -109,7 +109,7 @@ fn test_proceed_on_xdp() {
109109
&LoadType::Image,
110110
&XDP_PASS_IMAGE_LOC,
111111
XDP_PASS_FILE_LOC,
112-
Some(XDP_PASS_NAME),
112+
XDP_PASS_NAME,
113113
None, // metadata
114114
None, // map_owner_id
115115
);
@@ -159,7 +159,7 @@ fn test_unload_xdp() {
159159
&LoadType::Image,
160160
&XDP_PASS_IMAGE_LOC,
161161
XDP_PASS_FILE_LOC,
162-
Some(XDP_PASS_NAME),
162+
XDP_PASS_NAME,
163163
None, // metadata
164164
None, // map_owner_id
165165
);
@@ -176,7 +176,7 @@ fn test_unload_xdp() {
176176
&LoadType::Image,
177177
&XDP_PASS_IMAGE_LOC,
178178
XDP_PASS_FILE_LOC,
179-
Some(XDP_PASS_NAME),
179+
XDP_PASS_NAME,
180180
None, // metadata
181181
None, // map_owner_id
182182
);
@@ -193,7 +193,7 @@ fn test_unload_xdp() {
193193
&LoadType::Image,
194194
&XDP_PASS_IMAGE_LOC,
195195
XDP_PASS_FILE_LOC,
196-
Some(XDP_PASS_NAME),
196+
XDP_PASS_NAME,
197197
None, // metadata
198198
None, // map_owner_id
199199
);
@@ -259,6 +259,7 @@ fn test_proceed_on_tc() {
259259
&LoadType::Image,
260260
&TC_PASS_IMAGE_LOC,
261261
TC_PASS_FILE_LOC,
262+
TC_PASS_NAME,
262263
);
263264
loaded_ids.push(prog_id.unwrap());
264265

@@ -272,6 +273,7 @@ fn test_proceed_on_tc() {
272273
&LoadType::Image,
273274
&TC_PASS_IMAGE_LOC,
274275
TC_PASS_FILE_LOC,
276+
TC_PASS_NAME,
275277
);
276278
loaded_ids.push(prog_id.unwrap());
277279

@@ -301,6 +303,7 @@ fn test_proceed_on_tc() {
301303
&LoadType::Image,
302304
&TC_PASS_IMAGE_LOC,
303305
TC_PASS_FILE_LOC,
306+
TC_PASS_NAME,
304307
);
305308
loaded_ids.push(prog_id.unwrap());
306309

@@ -314,6 +317,7 @@ fn test_proceed_on_tc() {
314317
&LoadType::Image,
315318
&TC_PASS_IMAGE_LOC,
316319
TC_PASS_FILE_LOC,
320+
TC_PASS_NAME,
317321
);
318322
loaded_ids.push(prog_id.unwrap());
319323

@@ -346,6 +350,7 @@ fn test_proceed_on_tc() {
346350
&LoadType::Image,
347351
&TC_PASS_IMAGE_LOC,
348352
TC_PASS_FILE_LOC,
353+
TC_PASS_NAME,
349354
);
350355
loaded_ids.push(prog_id.unwrap());
351356

@@ -359,6 +364,7 @@ fn test_proceed_on_tc() {
359364
&LoadType::Image,
360365
&TC_PASS_IMAGE_LOC,
361366
TC_PASS_FILE_LOC,
367+
TC_PASS_NAME,
362368
);
363369
loaded_ids.push(prog_id.unwrap());
364370

@@ -432,6 +438,7 @@ fn test_unload_tc() {
432438
&LoadType::Image,
433439
&TC_PASS_IMAGE_LOC,
434440
TC_PASS_FILE_LOC,
441+
TC_PASS_NAME,
435442
);
436443
loaded_ids.push(prog_id.unwrap());
437444

@@ -445,6 +452,7 @@ fn test_unload_tc() {
445452
&LoadType::Image,
446453
&TC_PASS_IMAGE_LOC,
447454
TC_PASS_FILE_LOC,
455+
TC_PASS_NAME,
448456
);
449457
loaded_ids.push(prog_id.unwrap());
450458

@@ -460,6 +468,7 @@ fn test_unload_tc() {
460468
&LoadType::Image,
461469
&TC_PASS_IMAGE_LOC,
462470
TC_PASS_FILE_LOC,
471+
TC_PASS_NAME,
463472
);
464473
loaded_ids.push(prog_id.unwrap());
465474

@@ -473,6 +482,7 @@ fn test_unload_tc() {
473482
&LoadType::Image,
474483
&TC_PASS_IMAGE_LOC,
475484
TC_PASS_FILE_LOC,
485+
TC_PASS_NAME,
476486
);
477487
loaded_ids.push(prog_id.unwrap());
478488

@@ -488,6 +498,7 @@ fn test_unload_tc() {
488498
&LoadType::Image,
489499
&TC_PASS_IMAGE_LOC,
490500
TC_PASS_FILE_LOC,
501+
TC_PASS_NAME,
491502
);
492503

493504
debug!("Installing 3rd tc egress program");
@@ -500,6 +511,7 @@ fn test_unload_tc() {
500511
&LoadType::Image,
501512
&TC_PASS_IMAGE_LOC,
502513
TC_PASS_FILE_LOC,
514+
TC_PASS_NAME,
503515
);
504516

505517
// Don't save the 3rd prog ids because we will unload them explicitly below.
@@ -570,7 +582,7 @@ fn test_program_execution_with_global_variables() {
570582
&LoadType::Image,
571583
&XDP_PASS_IMAGE_LOC,
572584
XDP_PASS_FILE_LOC,
573-
Some(XDP_PASS_NAME),
585+
XDP_PASS_NAME,
574586
None, // metadata
575587
None, // map_owner_id
576588
);
@@ -589,6 +601,7 @@ fn test_program_execution_with_global_variables() {
589601
&LoadType::Image,
590602
&TC_PASS_IMAGE_LOC,
591603
TC_PASS_FILE_LOC,
604+
TC_PASS_NAME,
592605
);
593606

594607
loaded_ids.push(prog_id.unwrap());
@@ -605,6 +618,7 @@ fn test_program_execution_with_global_variables() {
605618
&LoadType::Image,
606619
&TC_PASS_IMAGE_LOC,
607620
TC_PASS_FILE_LOC,
621+
TC_PASS_NAME,
608622
);
609623

610624
loaded_ids.push(prog_id.unwrap());
@@ -618,6 +632,7 @@ fn test_program_execution_with_global_variables() {
618632
&TRACEPOINT_IMAGE_LOC,
619633
TRACEPOINT_FILE_LOC,
620634
TRACEPOINT_TRACEPOINT_NAME,
635+
TRACEPOINT_NAME,
621636
);
622637

623638
loaded_ids.push(prog_id.unwrap());
@@ -722,7 +737,7 @@ fn test_load_unload_xdp_maps() {
722737
&LoadType::Image,
723738
&XDP_COUNTER_IMAGE_LOC,
724739
"", // file_path
725-
Some(XDP_COUNTER_NAME),
740+
XDP_COUNTER_NAME,
726741
None, // metadata
727742
None, // map_owner_id
728743
);
@@ -759,6 +774,7 @@ fn test_load_unload_tc_maps() {
759774
&LoadType::Image,
760775
&TC_COUNTER_IMAGE_LOC,
761776
"",
777+
TC_COUNTER_NAME,
762778
);
763779
let binding = stdout.unwrap();
764780

@@ -787,10 +803,11 @@ fn test_load_unload_tracepoint_maps() {
787803
&TRACEPOINT_COUNTER_IMAGE_LOC,
788804
"",
789805
TRACEPOINT_TRACEPOINT_NAME,
806+
TRACEPOINT_COUNTER_NAME,
790807
);
791808
let binding = stdout.unwrap();
792809

793-
debug!("Verify tracepiont_counter map pin directory was created, and maps were pinned");
810+
debug!("Verify tracepoint_counter map pin directory was created, and maps were pinned");
794811

795812
let map_pin_path = bpfman_output_map_pin_path(&binding);
796813
assert!(PathBuf::from(map_pin_path)

‎tests/integration-test/src/tests/error.rs

+22-10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ fn common_load_parameter_testing() {
6161
lt,
6262
INVALID_XDP_IMAGE_LOC,
6363
INVALID_XDP_FILE_LOC,
64+
TC_PASS_NAME,
6465
);
6566
assert!(error_prog_id.is_err());
6667
// Make sure bpfman is still accessible after command
@@ -76,7 +77,7 @@ fn common_load_parameter_testing() {
7677
&LoadType::File,
7778
&XDP_PASS_IMAGE_LOC,
7879
XDP_PASS_FILE_LOC,
79-
Some(NONEXISTENT_XDP_PASS_NAME),
80+
NONEXISTENT_XDP_PASS_NAME,
8081
None, // metadata
8182
None, // map_owner_id
8283
);
@@ -93,7 +94,7 @@ fn common_load_parameter_testing() {
9394
&LoadType::Image,
9495
&XDP_PASS_IMAGE_LOC,
9596
XDP_PASS_FILE_LOC,
96-
Some(NONEXISTENT_XDP_PASS_NAME),
97+
NONEXISTENT_XDP_PASS_NAME,
9798
None, // metadata
9899
None, // map_owner_id
99100
);
@@ -110,7 +111,7 @@ fn common_load_parameter_testing() {
110111
&LoadType::File,
111112
&XDP_PASS_IMAGE_LOC,
112113
XDP_PASS_FILE_LOC,
113-
Some(INVALID_XDP_PASS_NAME),
114+
INVALID_XDP_PASS_NAME,
114115
None, // metadata
115116
None, // map_owner_id
116117
);
@@ -126,6 +127,7 @@ fn common_load_parameter_testing() {
126127
&TRACEPOINT_IMAGE_LOC,
127128
TRACEPOINT_FILE_LOC,
128129
TRACEPOINT_TRACEPOINT_NAME,
130+
TRACEPOINT_NAME,
129131
);
130132
assert!(error_prog_id.is_err());
131133
// Make sure bpfman is still accessible after command
@@ -141,7 +143,7 @@ fn common_load_parameter_testing() {
141143
&LoadType::File,
142144
&XDP_PASS_IMAGE_LOC,
143145
XDP_PASS_FILE_LOC,
144-
Some(XDP_PASS_NAME),
146+
XDP_PASS_NAME,
145147
Some(vec![key]), // metadata
146148
None, // map_owner_id
147149
);
@@ -158,7 +160,7 @@ fn common_load_parameter_testing() {
158160
&LoadType::File,
159161
&XDP_PASS_IMAGE_LOC,
160162
XDP_PASS_FILE_LOC,
161-
Some(XDP_PASS_NAME),
163+
XDP_PASS_NAME,
162164
None, // metadata
163165
None, // map_owner_id
164166
);
@@ -316,6 +318,7 @@ fn tc_load_parameter_testing() {
316318
&LoadType::Image,
317319
&TC_PASS_IMAGE_LOC,
318320
TC_PASS_FILE_LOC,
321+
TC_PASS_NAME,
319322
);
320323
assert!(error_prog_id.is_err());
321324
// Make sure bpfman is still accessible after command
@@ -331,6 +334,7 @@ fn tc_load_parameter_testing() {
331334
&LoadType::Image,
332335
&TC_PASS_IMAGE_LOC,
333336
TC_PASS_FILE_LOC,
337+
TC_PASS_NAME,
334338
);
335339
assert!(error_prog_id.is_err());
336340
// Make sure bpfman is still accessible after command
@@ -346,6 +350,7 @@ fn tc_load_parameter_testing() {
346350
&LoadType::Image,
347351
&TC_PASS_IMAGE_LOC,
348352
TC_PASS_FILE_LOC,
353+
TC_PASS_NAME,
349354
);
350355
assert!(error_prog_id.is_err());
351356
// Make sure bpfman is still accessible after command
@@ -361,6 +366,7 @@ fn tc_load_parameter_testing() {
361366
&LoadType::File,
362367
&TC_PASS_IMAGE_LOC,
363368
TC_PASS_FILE_LOC,
369+
TC_PASS_NAME,
364370
);
365371
assert!(error_prog_id.is_err());
366372
// Make sure bpfman is still accessible after command
@@ -377,6 +383,7 @@ fn tc_load_parameter_testing() {
377383
&LoadType::File,
378384
&TC_PASS_IMAGE_LOC,
379385
TC_PASS_FILE_LOC,
386+
TC_PASS_NAME,
380387
);
381388
assert!(error_prog_id.is_err());
382389
// Make sure bpfman is still accessible after command
@@ -432,6 +439,7 @@ fn tracepoint_load_parameter_testing() {
432439
&TRACEPOINT_IMAGE_LOC,
433440
TRACEPOINT_FILE_LOC,
434441
"invalid", // tracepoint
442+
TRACEPOINT_NAME,
435443
);
436444
assert!(error_prog_id.is_err());
437445
// Make sure bpfman is still accessible after command
@@ -448,6 +456,7 @@ fn tracepoint_load_parameter_testing() {
448456
&FENTRY_IMAGE_LOC,
449457
FENTRY_FILE_LOC,
450458
TRACEPOINT_TRACEPOINT_NAME,
459+
TRACEPOINT_NAME,
451460
);
452461
assert!(error_prog_id.is_err());
453462
// Make sure bpfman is still accessible after command
@@ -577,7 +586,7 @@ fn xdp_load_parameter_testing() {
577586
&LoadType::Image,
578587
&XDP_PASS_IMAGE_LOC,
579588
XDP_PASS_FILE_LOC,
580-
Some(XDP_PASS_NAME),
589+
XDP_PASS_NAME,
581590
None, // metadata
582591
None, // map_owner_id
583592
);
@@ -594,7 +603,7 @@ fn xdp_load_parameter_testing() {
594603
&LoadType::Image,
595604
&XDP_PASS_IMAGE_LOC,
596605
XDP_PASS_FILE_LOC,
597-
Some(XDP_PASS_NAME),
606+
XDP_PASS_NAME,
598607
None, // metadata
599608
None, // map_owner_id
600609
);
@@ -611,7 +620,7 @@ fn xdp_load_parameter_testing() {
611620
&LoadType::File,
612621
&XDP_PASS_IMAGE_LOC,
613622
XDP_PASS_FILE_LOC,
614-
Some(XDP_PASS_NAME),
623+
XDP_PASS_NAME,
615624
None, // metadata
616625
None, // map_owner_id
617626
);
@@ -629,7 +638,7 @@ fn xdp_load_parameter_testing() {
629638
&LoadType::File,
630639
&XDP_PASS_IMAGE_LOC,
631640
XDP_PASS_FILE_LOC,
632-
Some(XDP_PASS_NAME),
641+
XDP_PASS_NAME,
633642
None, // metadata
634643
None, // map_owner_id
635644
);
@@ -747,6 +756,7 @@ fn test_invalid_parameters() {
747756
&TRACEPOINT_IMAGE_LOC,
748757
TRACEPOINT_FILE_LOC,
749758
TRACEPOINT_TRACEPOINT_NAME,
759+
TRACEPOINT_NAME,
750760
);
751761

752762
if let Ok(id) = prog_id {
@@ -767,7 +777,7 @@ fn test_invalid_parameters() {
767777
&LoadType::File,
768778
&XDP_PASS_IMAGE_LOC,
769779
XDP_PASS_FILE_LOC,
770-
Some(XDP_PASS_NAME),
780+
XDP_PASS_NAME,
771781
None, // metadata
772782
None, // map_owner_id
773783
);
@@ -784,6 +794,7 @@ fn test_invalid_parameters() {
784794
&LoadType::Image,
785795
&TC_PASS_IMAGE_LOC,
786796
TC_PASS_FILE_LOC,
797+
TC_PASS_NAME,
787798
);
788799
if let Ok(id) = prog_id {
789800
loaded_ids.push(id);
@@ -798,6 +809,7 @@ fn test_invalid_parameters() {
798809
&LoadType::File,
799810
&TC_PASS_IMAGE_LOC,
800811
TC_PASS_FILE_LOC,
812+
TC_PASS_NAME,
801813
);
802814
if let Ok(id) = prog_id {
803815
loaded_ids.push(id);

‎tests/integration-test/src/tests/utils.rs

+38-31
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,28 @@ lazy_static! {
6262
.unwrap_or_else(|_| String::from("quay.io/bpfman-bytecode/fexit:latest"));
6363
}
6464

65-
pub const XDP_PASS_FILE_LOC: &str = "tests/integration-test/bpf/.output/xdp_pass.bpf.o";
66-
pub const TC_PASS_FILE_LOC: &str = "tests/integration-test/bpf/.output/tc_pass.bpf.o";
67-
pub const TRACEPOINT_FILE_LOC: &str = "tests/integration-test/bpf/.output/tp_openat.bpf.o";
68-
pub const UPROBE_FILE_LOC: &str = "tests/integration-test/bpf/.output/uprobe.bpf.o";
69-
pub const URETPROBE_FILE_LOC: &str = "tests/integration-test/bpf/.output/uprobe.bpf.o";
70-
pub const KPROBE_FILE_LOC: &str = "tests/integration-test/bpf/.output/kprobe.bpf.o";
71-
pub const KRETPROBE_FILE_LOC: &str = "tests/integration-test/bpf/.output/kprobe.bpf.o";
72-
pub const FENTRY_FILE_LOC: &str = "tests/integration-test/bpf/.output/fentry.bpf.o";
73-
pub const FEXIT_FILE_LOC: &str = "tests/integration-test/bpf/.output/fentry.bpf.o";
65+
pub const XDP_PASS_FILE_LOC: &str =
66+
"tests/integration-test/bpf/.output/xdp_pass.bpf/bpf_x86_bpfel.o";
67+
pub const TC_PASS_FILE_LOC: &str = "tests/integration-test/bpf/.output/tc_pass.bpf/bpf_x86_bpfel.o";
68+
pub const TRACEPOINT_FILE_LOC: &str =
69+
"tests/integration-test/bpf/.output/tp_openat.bpf/bpf_x86_bpfel.o";
70+
pub const UPROBE_FILE_LOC: &str = "tests/integration-test/bpf/.output/uprobe.bpf/bpf_x86_bpfel.o";
71+
pub const URETPROBE_FILE_LOC: &str =
72+
"tests/integration-test/bpf/.output/uprobe.bpf/bpf_x86_bpfel.o";
73+
pub const KPROBE_FILE_LOC: &str = "tests/integration-test/bpf/.output/kprobe.bpf/bpf_x86_bpfel.o";
74+
pub const KRETPROBE_FILE_LOC: &str =
75+
"tests/integration-test/bpf/.output/kprobe.bpf/bpf_x86_bpfel.o";
76+
pub const FENTRY_FILE_LOC: &str = "tests/integration-test/bpf/.output/fentry.bpf/bpf_x86_bpfel.o";
77+
pub const FEXIT_FILE_LOC: &str = "tests/integration-test/bpf/.output/fentry.bpf/bpf_x86_bpfel.o";
7478

7579
pub const XDP_PASS_NAME: &str = "pass";
7680
pub const XDP_COUNTER_NAME: &str = "xdp_stats";
81+
pub const TC_PASS_NAME: &str = "pass";
82+
pub const TC_COUNTER_NAME: &str = "stats";
7783
pub const FENTRY_FEXIT_KERNEL_FUNCTION_NAME: &str = "do_unlinkat";
7884
pub const TRACEPOINT_TRACEPOINT_NAME: &str = "syscalls/sys_enter_openat";
85+
pub const TRACEPOINT_NAME: &str = "enter_openat";
86+
pub const TRACEPOINT_COUNTER_NAME: &str = "tracepoint_kill_recorder";
7987
pub const UPROBE_KERNEL_FUNCTION_NAME: &str = "main";
8088
pub const UPROBE_KERNEL_CONT_PID_FUNCTION_NAME: &str = "malloc";
8189
pub const UPROBE_TARGET: &str = "libc";
@@ -111,6 +119,7 @@ fn execute_bpfman(args: Vec<&str>) -> Result<String> {
111119
match Command::cargo_bin("bpfman")
112120
.expect("bpfman missing")
113121
.args(args)
122+
.env("RUST_LOG", "debug")
114123
.ok()
115124
{
116125
Ok(output) => {
@@ -140,7 +149,7 @@ pub fn add_xdp(
140149
load_type: &LoadType,
141150
image_url: &str,
142151
file_path: &str,
143-
name: Option<&str>,
152+
name: &str,
144153
metadata: Option<Vec<&str>>,
145154
map_owner_id: Option<u32>,
146155
) -> (Result<String>, Result<String>) {
@@ -175,9 +184,7 @@ pub fn add_xdp(
175184
args.extend(["--map-owner-id", owner_id.as_str()]);
176185
}
177186

178-
if let Some(n) = name {
179-
args.extend(["--name", n]);
180-
}
187+
args.extend(["--name", name]);
181188

182189
match load_type {
183190
LoadType::Image => args.extend(["--image-url", image_url, "--pull-policy", "Always"]),
@@ -223,6 +230,7 @@ pub fn add_tc(
223230
load_type: &LoadType,
224231
image_url: &str,
225232
file_path: &str,
233+
name: &str,
226234
) -> (Result<String>, Result<String>) {
227235
let mut args = vec!["load"];
228236
match load_type {
@@ -241,10 +249,10 @@ pub fn add_tc(
241249

242250
match load_type {
243251
LoadType::Image => args.extend(["--image-url", image_url, "--pull-policy", "Always"]),
244-
LoadType::File => args.extend(["-n", "pass", "--path", file_path]),
252+
LoadType::File => args.extend(["--path", file_path]),
245253
}
246254

247-
args.extend(["tc", "--direction", direction, "--iface", iface]);
255+
args.extend(["-n", name, "tc", "--direction", direction, "--iface", iface]);
248256

249257
let p: String = if priority == INVALID_INTEGER {
250258
"invalid_int".to_string()
@@ -279,6 +287,7 @@ pub fn add_tracepoint(
279287
image_url: &str,
280288
file_path: &str,
281289
tracepoint: &str,
290+
name: &str,
282291
) -> (Result<String>, Result<String>) {
283292
let mut args = vec!["load"];
284293
match load_type {
@@ -297,10 +306,10 @@ pub fn add_tracepoint(
297306

298307
match load_type {
299308
LoadType::Image => args.extend(["--image-url", image_url, "--pull-policy", "Always"]),
300-
LoadType::File => args.extend(["-n", "enter_openat", "--path", file_path]),
309+
LoadType::File => args.extend(["--path", file_path]),
301310
}
302311

303-
args.extend(["tracepoint", "--tracepoint", tracepoint]);
312+
args.extend(["-n", name, "tracepoint", "--tracepoint", tracepoint]);
304313

305314
match execute_bpfman(args) {
306315
Ok(stdout) => {
@@ -349,9 +358,11 @@ pub fn add_uprobe(
349358

350359
match load_type {
351360
LoadType::Image => args.extend(["--image-url", image_url, "--pull-policy", "Always"]),
352-
LoadType::File => args.extend(["-n", "my_uprobe", "--path", file_path]),
361+
LoadType::File => args.extend(["--path", file_path]),
353362
}
354363

364+
args.extend(["-n", "my_uprobe"]);
365+
355366
if let Some(pid) = container_pid {
356367
args.extend([
357368
"uprobe",
@@ -409,10 +420,10 @@ pub fn add_uretprobe(
409420

410421
match load_type {
411422
LoadType::Image => args.extend(["--image-url", image_url, "--pull-policy", "Always"]),
412-
LoadType::File => args.extend(["-n", "my_uretprobe", "--path", file_path]),
423+
LoadType::File => args.extend(["--path", file_path]),
413424
}
414425

415-
args.extend(["uprobe", "-f", fn_name, "-r"]);
426+
args.extend(["-n", "my_uretprobe", "uprobe", "-f", fn_name, "-r"]);
416427

417428
if let Some(t) = target {
418429
args.extend(["-t", t]);
@@ -460,10 +471,10 @@ pub fn add_kprobe(
460471

461472
match load_type {
462473
LoadType::Image => args.extend(["--image-url", image_url, "--pull-policy", "Always"]),
463-
LoadType::File => args.extend(["-n", "my_kprobe", "--path", file_path]),
474+
LoadType::File => args.extend(["--path", file_path]),
464475
}
465476

466-
args.extend(["kprobe", "-f", fn_name]);
477+
args.extend(["-n", "my_kprobe", "kprobe", "-f", fn_name]);
467478

468479
if let Some(pid) = container_pid {
469480
args.extend(["--container-pid", pid]);
@@ -508,10 +519,10 @@ pub fn add_kretprobe(
508519

509520
match load_type {
510521
LoadType::Image => args.extend(["--image-url", image_url, "--pull-policy", "Always"]),
511-
LoadType::File => args.extend(["-n", "my_kretprobe", "--path", file_path]),
522+
LoadType::File => args.extend(["--path", file_path]),
512523
}
513524

514-
args.extend(["kprobe", "--retprobe", "-f", fn_name]);
525+
args.extend(["-n", "my_kretprobe", "kprobe", "--retprobe", "-f", fn_name]);
515526

516527
match execute_bpfman(args) {
517528
Ok(stdout) => {
@@ -548,18 +559,14 @@ pub fn add_fentry_or_fexit(
548559
match load_type {
549560
LoadType::Image => args.extend(["--image-url", image_url, "--pull-policy", "Always"]),
550561
LoadType::File => {
551-
if fentry {
552-
args.extend(["-n", "test_fentry", "--path", file_path]);
553-
} else {
554-
args.extend(["-n", "test_fexit", "--path", file_path]);
555-
}
562+
args.extend(["--path", file_path]);
556563
}
557564
}
558565

559566
if fentry {
560-
args.extend(["fentry", "-f", fn_name]);
567+
args.extend(["-n", "test_fentry", "fentry", "-f", fn_name]);
561568
} else {
562-
args.extend(["fexit", "-f", fn_name]);
569+
args.extend(["-n", "test_fexit", "fexit", "-f", fn_name]);
563570
}
564571

565572
match execute_bpfman(args) {

‎xtask/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dialoguer = { workspace = true }
2626
diff = { workspace = true }
2727
hex = { workspace = true, features = ["std"] }
2828
lazy_static = { workspace = true }
29+
log = { workspace = true }
2930
public-api = { workspace = true }
3031
rustdoc-json = { workspace = true }
3132
rustup-toolchain = { workspace = true }

‎xtask/public-api/bpfman.txt

+86
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ pub bpfman::errors::BpfmanError::InternalError(alloc::string::String)
2222
pub bpfman::errors::BpfmanError::InvalidAttach(alloc::string::String)
2323
pub bpfman::errors::BpfmanError::InvalidInterface
2424
pub bpfman::errors::BpfmanError::NotLoaded
25+
pub bpfman::errors::BpfmanError::ProgramNotFoundInBytecode
26+
pub bpfman::errors::BpfmanError::ProgramNotFoundInBytecode::bytecode_image: alloc::string::String
27+
pub bpfman::errors::BpfmanError::ProgramNotFoundInBytecode::expected_prog_name: alloc::string::String
28+
pub bpfman::errors::BpfmanError::ProgramNotFoundInBytecode::program_names: alloc::vec::Vec<alloc::string::String>
2529
pub bpfman::errors::BpfmanError::RpcRecvError(tokio::sync::oneshot::error::RecvError)
2630
pub bpfman::errors::BpfmanError::RpcSendError(anyhow::Error)
2731
pub bpfman::errors::BpfmanError::TooManyPrograms
@@ -94,6 +98,8 @@ pub bpfman::errors::ParseError::InvalidBytecodeLocation
9498
pub bpfman::errors::ParseError::InvalidBytecodeLocation::location: alloc::string::String
9599
pub bpfman::errors::ParseError::InvalidDirection
96100
pub bpfman::errors::ParseError::InvalidDirection::direction: alloc::string::String
101+
pub bpfman::errors::ParseError::InvalidMapType
102+
pub bpfman::errors::ParseError::InvalidMapType::map: alloc::string::String
97103
pub bpfman::errors::ParseError::InvalidProbeType
98104
pub bpfman::errors::ParseError::InvalidProbeType::probe: alloc::string::String
99105
pub bpfman::errors::ParseError::InvalidProceedOn
@@ -373,6 +379,84 @@ impl<T> typenum::type_operators::Same for bpfman::types::Location
373379
pub type bpfman::types::Location::Output = T
374380
impl<V, T> ppv_lite86::types::VZip<V> for bpfman::types::Location where V: ppv_lite86::types::MultiLane<T>
375381
pub fn bpfman::types::Location::vzip(self) -> V
382+
pub enum bpfman::types::MapType
383+
pub bpfman::types::MapType::Arena
384+
pub bpfman::types::MapType::Array
385+
pub bpfman::types::MapType::ArrayOfMaps
386+
pub bpfman::types::MapType::BloomFilter
387+
pub bpfman::types::MapType::CgroupArray
388+
pub bpfman::types::MapType::CgroupStorage
389+
pub bpfman::types::MapType::CgrpStorage
390+
pub bpfman::types::MapType::Cpumap
391+
pub bpfman::types::MapType::Devmap
392+
pub bpfman::types::MapType::DevmapHash
393+
pub bpfman::types::MapType::Hash
394+
pub bpfman::types::MapType::HashOfMaps
395+
pub bpfman::types::MapType::InodeStorage
396+
pub bpfman::types::MapType::LpmTrie
397+
pub bpfman::types::MapType::LruHash
398+
pub bpfman::types::MapType::LruPerCpuHash
399+
pub bpfman::types::MapType::PerCpuArray
400+
pub bpfman::types::MapType::PerCpuCgroupStorage
401+
pub bpfman::types::MapType::PerCpuHash
402+
pub bpfman::types::MapType::PerfEventArray
403+
pub bpfman::types::MapType::ProgArray
404+
pub bpfman::types::MapType::Queue
405+
pub bpfman::types::MapType::ReuseportSockarray
406+
pub bpfman::types::MapType::Ringbuf
407+
pub bpfman::types::MapType::SkStorage
408+
pub bpfman::types::MapType::Sockhash
409+
pub bpfman::types::MapType::Sockmap
410+
pub bpfman::types::MapType::Stack
411+
pub bpfman::types::MapType::StackTrace
412+
pub bpfman::types::MapType::StructOps
413+
pub bpfman::types::MapType::TaskStorage
414+
pub bpfman::types::MapType::Unspec
415+
pub bpfman::types::MapType::UserRingbuf
416+
pub bpfman::types::MapType::Xskmap
417+
impl core::convert::From<u32> for bpfman::types::MapType
418+
pub fn bpfman::types::MapType::from(value: u32) -> Self
419+
impl core::fmt::Debug for bpfman::types::MapType
420+
pub fn bpfman::types::MapType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
421+
impl core::fmt::Display for bpfman::types::MapType
422+
pub fn bpfman::types::MapType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
423+
impl core::marker::Freeze for bpfman::types::MapType
424+
impl core::marker::Send for bpfman::types::MapType
425+
impl core::marker::Sync for bpfman::types::MapType
426+
impl core::marker::Unpin for bpfman::types::MapType
427+
impl core::panic::unwind_safe::RefUnwindSafe for bpfman::types::MapType
428+
impl core::panic::unwind_safe::UnwindSafe for bpfman::types::MapType
429+
impl<T, U> core::convert::Into<U> for bpfman::types::MapType where U: core::convert::From<T>
430+
pub fn bpfman::types::MapType::into(self) -> U
431+
impl<T, U> core::convert::TryFrom<U> for bpfman::types::MapType where U: core::convert::Into<T>
432+
pub type bpfman::types::MapType::Error = core::convert::Infallible
433+
pub fn bpfman::types::MapType::try_from(value: U) -> core::result::Result<T, <T as core::convert::TryFrom<U>>::Error>
434+
impl<T, U> core::convert::TryInto<U> for bpfman::types::MapType where U: core::convert::TryFrom<T>
435+
pub type bpfman::types::MapType::Error = <U as core::convert::TryFrom<T>>::Error
436+
pub fn bpfman::types::MapType::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
437+
impl<T> alloc::string::ToString for bpfman::types::MapType where T: core::fmt::Display + core::marker::Sized
438+
pub fn bpfman::types::MapType::to_string(&self) -> alloc::string::String
439+
impl<T> core::any::Any for bpfman::types::MapType where T: 'static + core::marker::Sized
440+
pub fn bpfman::types::MapType::type_id(&self) -> core::any::TypeId
441+
impl<T> core::borrow::Borrow<T> for bpfman::types::MapType where T: core::marker::Sized
442+
pub fn bpfman::types::MapType::borrow(&self) -> &T
443+
impl<T> core::borrow::BorrowMut<T> for bpfman::types::MapType where T: core::marker::Sized
444+
pub fn bpfman::types::MapType::borrow_mut(&mut self) -> &mut T
445+
impl<T> core::convert::From<T> for bpfman::types::MapType
446+
pub fn bpfman::types::MapType::from(t: T) -> T
447+
impl<T> crossbeam_epoch::atomic::Pointable for bpfman::types::MapType
448+
pub type bpfman::types::MapType::Init = T
449+
pub const bpfman::types::MapType::ALIGN: usize
450+
pub unsafe fn bpfman::types::MapType::deref<'a>(ptr: usize) -> &'a T
451+
pub unsafe fn bpfman::types::MapType::deref_mut<'a>(ptr: usize) -> &'a mut T
452+
pub unsafe fn bpfman::types::MapType::drop(ptr: usize)
453+
pub unsafe fn bpfman::types::MapType::init(init: <T as crossbeam_epoch::atomic::Pointable>::Init) -> usize
454+
impl<T> tracing::instrument::Instrument for bpfman::types::MapType
455+
impl<T> tracing::instrument::WithSubscriber for bpfman::types::MapType
456+
impl<T> typenum::type_operators::Same for bpfman::types::MapType
457+
pub type bpfman::types::MapType::Output = T
458+
impl<V, T> ppv_lite86::types::VZip<V> for bpfman::types::MapType where V: ppv_lite86::types::MultiLane<T>
459+
pub fn bpfman::types::MapType::vzip(self) -> V
376460
pub enum bpfman::types::ProbeType
377461
pub bpfman::types::ProbeType::Kprobe
378462
pub bpfman::types::ProbeType::Kretprobe
@@ -556,6 +640,8 @@ pub fn bpfman::types::ProgramType::clone(&self) -> bpfman::types::ProgramType
556640
impl core::cmp::Eq for bpfman::types::ProgramType
557641
impl core::cmp::PartialEq for bpfman::types::ProgramType
558642
pub fn bpfman::types::ProgramType::eq(&self, other: &bpfman::types::ProgramType) -> bool
643+
impl core::convert::From<aya_obj::obj::ProgramSection> for bpfman::types::ProgramType
644+
pub fn bpfman::types::ProgramType::from(value: aya_obj::obj::ProgramSection) -> Self
559645
impl core::convert::From<bpfman::types::ProgramType> for u32
560646
pub fn u32::from(val: bpfman::types::ProgramType) -> Self
561647
impl core::convert::TryFrom<alloc::string::String> for bpfman::types::ProgramType

‎xtask/src/build_ebpf.rs

+43-61
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,13 @@ use std::{
55
process::Command,
66
};
77

8-
use anyhow::{bail, Context, Result};
8+
use anyhow::{bail, Context};
99
use clap::Parser;
1010

1111
use crate::workspace::WORKSPACE_ROOT;
1212

13-
#[derive(Debug, Copy, Clone)]
14-
pub enum Architecture {
15-
BpfEl,
16-
BpfEb,
17-
}
18-
19-
impl std::str::FromStr for Architecture {
20-
type Err = String;
21-
22-
fn from_str(s: &str) -> Result<Self, Self::Err> {
23-
Ok(match s {
24-
"bpfel-unknown-none" => Architecture::BpfEl,
25-
"bpfeb-unknown-none" => Architecture::BpfEb,
26-
_ => return Err("invalid target".to_owned()),
27-
})
28-
}
29-
}
30-
31-
impl std::fmt::Display for Architecture {
32-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33-
f.write_str(match self {
34-
Architecture::BpfEl => "bpfel-unknown-none",
35-
Architecture::BpfEb => "bpfeb-unknown-none",
36-
})
37-
}
38-
}
39-
4013
#[derive(Debug, Parser)]
4114
pub struct Options {
42-
/// Optional: Set the endianness of the BPF target
43-
#[clap(default_value = "bpfel-unknown-none", long)]
44-
pub target: Architecture,
4515
/// Optional: Build the release target
4616
#[clap(long)]
4717
pub release: bool,
@@ -77,8 +47,7 @@ fn build_ebpf_files(
7747
if let Some(ext) = p.extension() {
7848
if ext == "c" {
7949
let mut out = PathBuf::from(&out_path);
80-
out.push(p.file_name().unwrap());
81-
out.set_extension("o");
50+
out.push(p.file_stem().unwrap());
8251
compile_with_clang(&p, &out, &include_path)?;
8352
}
8453
}
@@ -123,34 +92,47 @@ fn compile_with_clang<P: Clone + AsRef<Path>>(
12392
Ok(val) => val,
12493
Err(_) => String::from("/usr/bin/clang"),
12594
};
126-
let arch = match std::env::consts::ARCH {
127-
"x86_64" => "x86",
128-
"aarch64" => "arm64",
129-
_ => std::env::consts::ARCH,
130-
};
131-
let mut cmd = Command::new(clang);
132-
cmd.arg(format!("-I{}", include_path.as_ref().to_string_lossy()))
133-
.arg("-g")
134-
.arg("-O2")
135-
.arg("-target")
136-
.arg("bpf")
137-
.arg("-c")
138-
.arg(format!("-D__TARGET_ARCH_{arch}"))
139-
.arg(src.as_ref().as_os_str())
140-
.arg("-o")
141-
.arg(out.as_ref().as_os_str());
142-
143-
let output = cmd.output().context("Failed to execute clang")?;
144-
if !output.status.success() {
145-
bail!(
146-
"Failed to compile BPF programs\n \
147-
stdout=\n \
148-
{}\n \
149-
stderr=\n \
150-
{}\n",
151-
String::from_utf8(output.stdout).unwrap(),
152-
String::from_utf8(output.stderr).unwrap()
153-
);
95+
// (Clang arch string, used to define the clang -target flag, as per
96+
// "clang -print-targets",
97+
// Linux arch string, used to define __TARGET_ARCH_xzy macros used by
98+
// https://github.com/libbpf/libbpf/blob/master/src/bpf_tracing.h)
99+
//
100+
let arches = Vec::from([
101+
("bpfel", "x86"),
102+
("bpfel", "arm64"),
103+
("bpfeb", "s390"),
104+
("bpfel", "powerpc"),
105+
]);
106+
for (target, arch) in arches {
107+
// remove the .bpf postfix
108+
let mut outfile = out.as_ref().to_path_buf();
109+
fs::create_dir_all(&outfile)?;
110+
// make sure our filenames are compataible with cilium/ebpf
111+
outfile.push(format!("bpf_{arch}_{target}.o"));
112+
let mut cmd = Command::new(clang.clone());
113+
cmd.arg(format!("-I{}", include_path.as_ref().to_string_lossy()))
114+
.arg("-g")
115+
.arg("-O2")
116+
.arg("-target")
117+
.arg(target)
118+
.arg("-c")
119+
.arg(format!("-D__TARGET_ARCH_{}", arch))
120+
.arg(src.as_ref().as_os_str())
121+
.arg("-o")
122+
.arg(outfile);
123+
124+
let output = cmd.output().context("Failed to execute clang")?;
125+
if !output.status.success() {
126+
bail!(
127+
"Failed to compile BPF programs\n \
128+
stdout=\n \
129+
{}\n \
130+
stderr=\n \
131+
{}\n",
132+
String::from_utf8(output.stdout).unwrap(),
133+
String::from_utf8(output.stderr).unwrap()
134+
);
135+
}
154136
}
155137

156138
Ok(())

‎xtask/src/integration_test.rs

+57
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ pub struct Options {
1616
/// Example: cargo xtask integration-test -- test_load_unload_tracepoint_maps test_load_unload_tc_maps
1717
#[clap(name = "tests", verbatim_doc_comment, last = true)]
1818
pub run_args: Vec<String>,
19+
/// Optional: The tag used for all the integration-test bytecode images.
20+
/// Example cargo xtask integration-test --bytecode-image-tag test-tag
21+
#[clap(short, long, default_value = "latest")]
22+
pub bytecode_image_tag: String,
1923
}
2024

2125
/// Build the project
@@ -49,9 +53,62 @@ pub fn test(opts: Options) -> Result<(), anyhow::Error> {
4953
args.push(bin_path.as_str());
5054
args.append(&mut run_args);
5155

56+
let tag = opts.bytecode_image_tag;
57+
let bytecode_images: Vec<(String, String)> = vec![
58+
(
59+
"XDP_PASS_IMAGE_LOC".to_string(),
60+
format!("quay.io/bpfman-bytecode/xdp_pass:{tag}"),
61+
),
62+
(
63+
"TC_PASS_IMAGE_LOC".to_string(),
64+
format!("quay.io/bpfman-bytecode/tc_pass:{tag}"),
65+
),
66+
(
67+
"TRACEPOINT_IMAGE_LOC".to_string(),
68+
format!("quay.io/bpfman-bytecode/tracepoint:{}", tag),
69+
),
70+
(
71+
"UPROBE_IMAGE_LOC".to_string(),
72+
format!("quay.io/bpfman-bytecode/uprobe:{}", tag),
73+
),
74+
(
75+
"URETPROBE_IMAGE_LOC".to_string(),
76+
format!("quay.io/bpfman-bytecode/uretprobe:{}", tag),
77+
),
78+
(
79+
"KPROBE_IMAGE_LOC".to_string(),
80+
format!("quay.io/bpfman-bytecode/kprobe:{}", tag),
81+
),
82+
(
83+
"KRETPROBE_IMAGE_LOC".to_string(),
84+
format!("quay.io/bpfman-bytecode/kretprobe:{}", tag),
85+
),
86+
(
87+
"XDP_COUNTER_IMAGE_LOC".to_string(),
88+
format!("quay.io/bpfman-bytecode/go-xdp-counter:{}", tag),
89+
),
90+
(
91+
"TC_COUNTER_IMAGE_LOC".to_string(),
92+
format!("quay.io/bpfman-bytecode/go-tc-counter:{}", tag),
93+
),
94+
(
95+
"TRACEPOINT_COUNTER_IMAGE_LOC".to_string(),
96+
format!("quay.io/bpfman-bytecode/go-tracepoint-counter:{tag}"),
97+
),
98+
(
99+
"FENTRY_IMAGE_LOC".to_string(),
100+
format!("quay.io/bpfman-bytecode/fentry:{tag}"),
101+
),
102+
(
103+
"FEXIT_IMAGE_LOC".to_string(),
104+
format!("quay.io/bpfman-bytecode/fexit:{tag}"),
105+
),
106+
];
107+
52108
// spawn the command
53109
let err = Command::new(args.first().expect("No first argument"))
54110
.args(args.iter().skip(1))
111+
.envs(bytecode_images)
55112
.exec();
56113

57114
// we shouldn't get here unless the command failed to spawn

‎xtask/src/run.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ use std::{os::unix::process::CommandExt, path::PathBuf, process::Command};
33
use anyhow::Context as _;
44
use clap::Parser;
55

6-
use crate::build_ebpf::{build_ebpf, Architecture, Options as BuildOptions};
6+
use crate::build_ebpf::{build_ebpf, Options as BuildOptions};
77

88
#[derive(Debug, Parser)]
99
pub struct Options {
10-
/// Optional: Set the endianness of the BPF target
11-
#[clap(default_value = "bpfel-unknown-none", long)]
12-
pub bpf_target: Architecture,
1310
/// Optional: Build and run the release target
1411
#[clap(long)]
1512
pub release: bool,
@@ -45,7 +42,6 @@ fn build(opts: &Options) -> Result<(), anyhow::Error> {
4542
pub fn run(opts: Options) -> Result<(), anyhow::Error> {
4643
// build our ebpf program followed by our application
4744
build_ebpf(BuildOptions {
48-
target: opts.bpf_target,
4945
release: opts.release,
5046
compile_rust_ebpf: opts.compile_rust_ebpf,
5147
libbpf_dir: PathBuf::from(&opts.libbpf_dir),

0 commit comments

Comments
 (0)
Please sign in to comment.