docs: add prompt for lack of kernel config item

This commit is contained in:
mzz2017 2023-02-01 21:15:58 +08:00
parent 22e64effe0
commit 1d12d14882
2 changed files with 24 additions and 3 deletions

View File

@ -12,7 +12,9 @@ import (
"github.com/v2rayA/dae/common"
"github.com/v2rayA/dae/pkg/ebpf_internal"
"net/netip"
"os"
"reflect"
"strings"
)
type _bpfLpmKey struct {
@ -97,7 +99,7 @@ func BatchUpdate(m *ebpf.Map, keys interface{}, values interface{}, opts *ebpf.B
}
type bpfObjectsLan struct {
// NOTICE: Consider to update me if any program added.
// FIXME: Consider to update me if any program added.
//bpfPrograms
TproxyEgress *ebpf.Program `ebpf:"tproxy_egress"`
TproxyIngress *ebpf.Program `ebpf:"tproxy_ingress"`
@ -106,7 +108,7 @@ type bpfObjectsLan struct {
}
type bpfObjectsWan struct {
// NOTICE: Consider to update me if any program added.
// FIXME: Consider to update me if any program added.
//bpfPrograms
Inet6Bind *ebpf.Program `ebpf:"inet6_bind"`
InetAutobind *ebpf.Program `ebpf:"inet_autobind"`
@ -120,6 +122,19 @@ type bpfObjectsWan struct {
bpfMaps
}
func IsNotSupportFtraceError(err error) bool {
// FATA[0001] loading objects: field Inet6Bind: program
// inet6_bind: load program: invalid argument
return strings.HasSuffix(err.Error(), os.ErrInvalid.Error()) && strings.Contains(err.Error(),
"field Inet6Bind: program") // FIXME: Consider to update me if any program added.
}
func IsNoBtfError(err error) bool {
// FATA[0001] loading objects: field Inet6Bind: program inet6_bind:
// apply CO-RE relocations: load kernel spec: no BTF found for kernel version 5.15.90: not supported
return strings.Contains(err.Error(), "no BTF found for kernel version")
}
func AssignBpfObjects(to *bpfObjects, from interface{}) {
vTo := reflect.Indirect(reflect.ValueOf(to))
vFrom := reflect.Indirect(reflect.ValueOf(from))

View File

@ -133,7 +133,13 @@ retryLoadBpf:
}
}
}
return nil, fmt.Errorf("loading objects: %v", err)
err := fmt.Errorf("loading objects: %w", err)
if IsNotSupportFtraceError(err) {
err = fmt.Errorf("%w: Maybe your kernel has no ftrace support. Make sure the kernel config items are on: CONFIG_FUNCTION_TRACER, CONFIG_FUNCTION_GRAPH_TRACER, CONFIG_STACK_TRACER, CONFIG_DYNAMIC_FTRACE", err)
} else if IsNoBtfError(err) {
err = fmt.Errorf("%w: Make sure the kernel config item is on: CONFIG_DEBUG_INFO_BTF", err)
}
return nil, err
}
if _, ok := obj.(*bpfObjects); !ok {
// Reverse takeover.