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 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
7 changes: 6 additions & 1 deletion pkg/bpf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// #include "cluster/cluster.pb-c.h"
import "C"
import (
"errors"
"fmt"
"hash/fnv"
"os"
Expand Down Expand Up @@ -68,6 +69,7 @@
}

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

Check warning on line 72 in pkg/bpf/bpf.go

View check run for this annotation

Codecov / codecov/patch

pkg/bpf/bpf.go#L72

Added line #L72 was not covered by tests
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,10 @@
}()

if err = l.obj.Load(); err != nil {
return fmt.Errorf("bpf Load failed, %s", err)
if errors.As(err, &ve) {
return fmt.Errorf("bpf Load failed: %+v", ve)

Check warning on line 85 in pkg/bpf/bpf.go

View check run for this annotation

Codecov / codecov/patch

pkg/bpf/bpf.go#L84-L85

Added lines #L84 - L85 were not covered by tests
}
return fmt.Errorf("bpf Load failed: %v", err)

Check warning on line 87 in pkg/bpf/bpf.go

View check run for this annotation

Codecov / codecov/patch

pkg/bpf/bpf.go#L87

Added line #L87 was not covered by tests
}

if err = l.obj.Attach(); err != nil {
Expand Down
17 changes: 14 additions & 3 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,18 +57,26 @@

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

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

defer func() {
if err != nil {
l.Stop()

Check warning on line 68 in pkg/bpf/bpf_kmesh_l4_workload.go

View check run for this annotation

Codecov / codecov/patch

pkg/bpf/bpf_kmesh_l4_workload.go#L68

Added line #L68 was not covered by tests
}
}()

if err = l.workloadObj.Load(); err != nil {
l.Stop()
return fmt.Errorf("bpf Load failed, %s", err)
if errors.As(err, &ve) {
return fmt.Errorf("bpf Load failed: %+v", ve)

Check warning on line 74 in pkg/bpf/bpf_kmesh_l4_workload.go

View check run for this annotation

Codecov / codecov/patch

pkg/bpf/bpf_kmesh_l4_workload.go#L73-L74

Added lines #L73 - L74 were not covered by tests
}
return fmt.Errorf("bpf Load failed: %v", err)

Check warning on line 76 in pkg/bpf/bpf_kmesh_l4_workload.go

View check run for this annotation

Codecov / codecov/patch

pkg/bpf/bpf_kmesh_l4_workload.go#L76

Added line #L76 was not covered by tests
}

if err = l.workloadObj.Attach(); err != nil {
l.Stop()
return fmt.Errorf("bpf Attach failed, %s", err)
}
l.bpfLogLevel = l.workloadObj.SockConn.BpfLogLevel
Expand Down
Loading