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 <[email protected]>
Signed-off-by: Martynas Pumputis <[email protected]>
  • Loading branch information
brb committed Jan 8, 2025
1 parent 9407434 commit 5a785cf
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 5a785cf

Please sign in to comment.