Skip to content

Commit

Permalink
Adjust global variables setting
Browse files Browse the repository at this point in the history
As pointed by Timo (and https://ebpf-go.dev/concepts/global-variables/),
we no longer need to use static, and then use Variables().Set() to
set it (RewriteConstants() is deprecated).

Suggested-by: Timo Beckers <timo@isovalent.com>
Signed-off-by: Martynas Pumputis <m@lambda.lt>
  • Loading branch information
brb authored and jschwinger233 committed Jan 9, 2025
1 parent 7a62217 commit 07fb445
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bpf/kprobe_pwru.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ struct config {
u32 shinfo_btf_id;
} __attribute__((packed));

static volatile const struct config CFG;
volatile const struct config CFG;
#define cfg (&CFG)

#define MAX_STACK_DEPTH 50
Expand Down
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ func main() {
if err != nil {
log.Fatalf("Failed to get pwru config: %v", err)
}
if err := bpfSpec.RewriteConstants(map[string]interface{}{
"CFG": pwruConfig,
}); err != nil {
if err := bpfSpec.Variables["CFG"].Set(pwruConfig); err != nil {
log.Fatalf("Failed to rewrite config: %v", err)
}

Expand Down

0 comments on commit 07fb445

Please sign in to comment.