Skip to content

Commit

Permalink
Fix when CONFIG_PID_NS is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
zmj64351508 committed Sep 24, 2024
1 parent bee4acb commit 7439460
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions ebpf/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,19 @@ func (s *session) Start() error {
}

_, nsIno, err := getPIDNamespace()
if err != nil {
return fmt.Errorf("unable to get pid namespace %w", err)
}
err = spec.RewriteConstants(map[string]interface{}{
"global_config": pyrobpf.ProfileGlobalConfigT{
NsPidIno: nsIno,
},
})
if err != nil {
return fmt.Errorf("pyrobpf rewrite constants %w", err)
// if the file does not exist, CONFIG_PID_NS is not supported, so we just ignore the error
if !os.IsNotExist(err) {
if err != nil {
return fmt.Errorf("unable to get pid namespace %w", err)
}
err = spec.RewriteConstants(map[string]interface{}{
"global_config": pyrobpf.ProfileGlobalConfigT{
NsPidIno: nsIno,
},
})
if err != nil {
return fmt.Errorf("pyrobpf rewrite constants %w", err)
}
}
err = spec.LoadAndAssign(&s.bpf, opts)
if err != nil {
Expand Down

0 comments on commit 7439460

Please sign in to comment.