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

fix verifier log omitted #800

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion pkg/bpf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package bpf
// #include "cluster/cluster.pb-c.h"
import "C"
import (
"errors"
"fmt"
"hash/fnv"
"os"
Expand Down Expand Up @@ -68,6 +69,7 @@ func NewBpfLoader(config *options.BpfConfig) *BpfLoader {
}

func (l *BpfLoader) StartAdsMode() (err error) {
var ve *ebpf.VerifierError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be var ve ebpf.VerifierError, otherwise the below &ve will panic

Copy link
Contributor Author

@weli-l weli-l Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be var ve ebpf.VerifierError, otherwise the below &ve will panic

The function we finally call is

func ErrorWithLog(source string, err error, log []byte, truncated bool) *VerifierError {
       ... ...
}

So, this ve should be *ebpf.VerifierError, And actually when I change *ebpf.VerifierError to ebpf.VerifierError, it will panic
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IC, this is related to VerifierError implementation

if l.obj, err = NewBpfKmesh(l.config); err != nil {
return err
}
Expand All @@ -79,7 +81,11 @@ func (l *BpfLoader) StartAdsMode() (err error) {
}()

if err = l.obj.Load(); err != nil {
return fmt.Errorf("bpf Load failed, %s", err)
l.Stop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed there is a defer above

if errors.As(err, &ve) {
return fmt.Errorf("bpf Load failed: %+v", ve)
}
return fmt.Errorf("bpf Load failed: %v", err)
}

if err = l.obj.Attach(); err != nil {
Expand Down
17 changes: 15 additions & 2 deletions pkg/bpf/bpf_kmesh_l4_workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
package bpf

import (
"errors"
"fmt"

"github.com/cilium/ebpf"

"kmesh.net/kmesh/daemon/options"
)

Expand Down Expand Up @@ -54,14 +57,24 @@ func newWorkloadBpf(cfg *options.BpfConfig) (*BpfKmeshWorkload, error) {

func (l *BpfLoader) StartWorkloadMode() error {
var err error
var ve *ebpf.VerifierError

if l.workloadObj, err = newWorkloadBpf(l.config); err != nil {
return err
}

if err = l.workloadObj.Load(); err != nil {
defer func() {
if err != nil {
l.Stop()
}
}()

if err = l.obj.Load(); err != nil {
l.Stop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

return fmt.Errorf("bpf Load failed, %s", err)
if errors.As(err, &ve) {
return fmt.Errorf("bpf Load failed: %+v", ve)
}
return fmt.Errorf("bpf Load failed: %v", err)
}

if err = l.workloadObj.Attach(); err != nil {
Expand Down
Loading