Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/olsajiri/tailcalls #3002

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checkpatch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- name: Run checkpatch.pl
uses: docker://quay.io/cilium/cilium-checkpatch:2f0f4f512e795d5668ea4e7ef0ba85abc75eb225@sha256:f307bf0315954e8b8c31edc1864d949bf211b0c6522346359317d757b5a6cea0
with:
args: "-- --ignore PREFER_DEFINED_ATTRIBUTE_MACRO,C99_COMMENTS,OPEN_ENDED_LINE,PREFER_KERNEL_TYPES,REPEATED_WORD,SPDX_LICENSE_TAG,LONG_LINE,LONG_LINE_STRING,LONG_LINE_COMMENT,TRACE_PRINTK"
args: "-- --ignore PREFER_DEFINED_ATTRIBUTE_MACRO,C99_COMMENTS,OPEN_ENDED_LINE,PREFER_KERNEL_TYPES,REPEATED_WORD,SPDX_LICENSE_TAG,LONG_LINE,LONG_LINE_STRING,LONG_LINE_COMMENT,TRACE_PRINTK,AVOID_EXTERNS"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/alecthomas/kong v1.2.1
github.com/bombsimon/logrusr/v4 v4.1.0
github.com/cilium/cilium v1.17.0-pre.1
github.com/cilium/ebpf v0.16.0
github.com/cilium/ebpf v0.16.1-0.20241017091859-59f2044b26b5
github.com/cilium/little-vm-helper v0.0.19
github.com/cilium/lumberjack/v2 v2.3.0
github.com/cilium/tetragon/api v0.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cilium/cilium v1.17.0-pre.1 h1:HIJgJ8mtGrz6fgRI6YA/TPAsx2s06rmJTvmVe8RiilA=
github.com/cilium/cilium v1.17.0-pre.1/go.mod h1:OM+QqlLdnaaQiGA9/OTTeVDBLyZYtwVDIbcTMMAm1gU=
github.com/cilium/ebpf v0.16.0 h1:+BiEnHL6Z7lXnlGUsXQPPAE7+kenAd4ES8MQ5min0Ok=
github.com/cilium/ebpf v0.16.0/go.mod h1:L7u2Blt2jMM/vLAVgjxluxtBKlz3/GWjB0dMOEngfwE=
github.com/cilium/ebpf v0.16.1-0.20241017091859-59f2044b26b5 h1:09rId+70PyTuXqz7E6k5bLxFj7yqYKHfxRAye+i5VAU=
github.com/cilium/ebpf v0.16.1-0.20241017091859-59f2044b26b5/go.mod h1:g+Zxp5bVKYJy9/njLFYE+mNTcw1P8TnE59/2Qq2Pr3I=
github.com/cilium/hive v0.0.0-20240926131619-aa37668760f2 h1:xZn7yvMbK1+Au6D/YLKEMdcEsyMt6Qu7CUv+yQHGqv0=
github.com/cilium/hive v0.0.0-20240926131619-aa37668760f2/go.mod h1:6tW1eCwSq8Wz8IVtpZE0MemoCWSrEOUa8aLKotmBRCo=
github.com/cilium/little-vm-helper v0.0.19 h1:eJeJM/03MGLrLUXXTBDZo2JoX5cIbm5+9iWjoHgpy/M=
Expand Down
4 changes: 4 additions & 0 deletions pkg/sensors/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ func (s *Sensor) loadMap(bpfDir string, m *program.Map) error {
m.SetMaxEntries(int(max))
}

// Disable content loading at this point, we just care about the map,
// the content will be loaded when the whole object gets loaded.
mapSpec.Contents = nil

if err := m.LoadOrCreatePinnedMap(pinPath, mapSpec); err != nil {
return fmt.Errorf("failed to load map '%s' for sensor '%s': %w", m.Name, s.Name, err)
}
Expand Down
38 changes: 37 additions & 1 deletion pkg/sensors/program/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,42 @@ func installTailCalls(bpfDir string, spec *ebpf.CollectionSpec, coll *ebpf.Colle
return nil
}

// MissingConstantsError is returned by [rewriteConstants].
type MissingConstantsError struct {
// The constants missing from .rodata.
Constants []string
}

func (m *MissingConstantsError) Error() string {
return fmt.Sprintf("some constants are missing from .rodata: %s", strings.Join(m.Constants, ", "))
}

func rewriteConstants(spec *ebpf.CollectionSpec, consts map[string]interface{}) error {
var missing []string

for n, c := range consts {
v, ok := spec.Variables[n]
if !ok {
missing = append(missing, n)
continue
}

if !v.Constant() {
return fmt.Errorf("variable %s is not a constant", n)
}

if err := v.Set(c); err != nil {
return fmt.Errorf("rewriting constant %s: %w", n, err)
}
}

if len(missing) != 0 {
return fmt.Errorf("rewrite constants: %w", &MissingConstantsError{Constants: missing})
}

return nil
}

func doLoadProgram(
bpfDir string,
load *Program,
Expand All @@ -756,7 +792,7 @@ func doLoadProgram(
}

if load.RewriteConstants != nil {
if err := spec.RewriteConstants(load.RewriteConstants); err != nil {
if err := rewriteConstants(spec, load.RewriteConstants); err != nil {
return nil, fmt.Errorf("rewritting constants in spec failed: %w", err)
}
}
Expand Down
6 changes: 6 additions & 0 deletions vendor/github.com/cilium/ebpf/.golangci.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/cilium/ebpf/CODEOWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vendor/github.com/cilium/ebpf/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions vendor/github.com/cilium/ebpf/asm/instruction.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions vendor/github.com/cilium/ebpf/btf/btf.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 40 additions & 39 deletions vendor/github.com/cilium/ebpf/btf/ext_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/github.com/cilium/ebpf/btf/kernel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/cilium/ebpf/btf/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading