Skip to content

Commit

Permalink
Merge branch 'main' into gray/sockmap
Browse files Browse the repository at this point in the history
  • Loading branch information
sumire88 authored Mar 30, 2024
2 parents 6dd2d01 + 36fa05b commit dceeade
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions common/consts/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ var (
ProgTypeSkLookupFeatureVersion = internal.Version{5, 9, 0}
SockmapFeatureVersion = internal.Version{5, 10, 0}
UserspaceBatchUpdateLpmTrieFeatureVersion = internal.Version{5, 13, 0}
HelperBpfGetFuncIpVersionFeatureVersion = internal.Version{5, 15, 0}
)

const (
Expand Down
2 changes: 1 addition & 1 deletion control/kern/headers
Submodule headers updated 3 files
+97,288 −0 vmlinux-arm64.h
+120,799 −0 vmlinux-x86.h
+11 −120,798 vmlinux.h
2 changes: 1 addition & 1 deletion control/kern/tproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ int tproxy_lan_ingress(struct __sk_buff *skb)
// Assign to control plane.
control_plane:
prep_redirect_to_control_plane(skb, link_h_len, &tuples, l4proto, &ethh, 0, &tcph);
return bpf_redirect_peer(PARAM.dae0_ifindex, 0);
return bpf_redirect(PARAM.dae0_ifindex, 0);

direct:
return TC_ACT_OK;
Expand Down
4 changes: 4 additions & 0 deletions docs/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ This feature requires kernel version of the machine >= 5.10.

Note that if you bind dae to WAN only, dae only provide network service for local programs and not impact traffic coming in from other interfaces.

`Use trace command`

If you want to use `dae trace` command to triage network connectivity issue, the kernel version is required to be >= 5.15.

## Kernel Configurations

Usually, mainstream desktop distributions have these items turned on. But in order to reduce kernel size, some items are turned off by default on embedded device distributions like OpenWRT, Armbian, etc.
Expand Down
4 changes: 4 additions & 0 deletions docs/zh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

如果你只在 `wan_interface` 中填写了接口或 `auto`,而未在 `lan_interface` 中填写内容,那么从局域网中传来的流量将无法被代理。如果你想同时代理本机和局域网流量,请同时填写 `wan_interface``lan_interface`

`使用 trace 命令`

如果你想用 `dae trace` 命令来诊断网络连通性问题,所在的设备内核版本要求 >= 5.15 。

## 内核配置选项

通常,主流桌面发行版都会打开这些选项。但是为了减小内核大小,在嵌入式设备发行版(如 OpenWRT、Armbian 等)上这些选项可能处于关闭状态。使用以下命令在你的设备上显示内核配置选项:
Expand Down
2 changes: 1 addition & 1 deletion trace/kern/headers
Submodule headers updated 3 files
+97,288 −0 vmlinux-arm64.h
+120,799 −0 vmlinux-x86.h
+11 −120,798 vmlinux.h
2 changes: 1 addition & 1 deletion trace/kern/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ filter_l3_and_l4(struct sk_buff *skb)
static __always_inline void
set_meta(struct meta *meta, struct sk_buff *skb, struct pt_regs *ctx)
{
meta->pc = BPF_CORE_READ(ctx, ip);
meta->pc = bpf_get_func_ip(ctx);
meta->skb = (__u64)skb;
meta->second_param = PT_REGS_PARM2(ctx);
meta->mark = BPF_CORE_READ(skb, mark);
Expand Down
11 changes: 11 additions & 0 deletions trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/ringbuf"
"github.com/daeuniverse/dae/common/consts"
internal "github.com/daeuniverse/dae/pkg/ebpf_internal"
"github.com/sirupsen/logrus"
)

Expand All @@ -42,6 +44,15 @@ func init() {
}

func StartTrace(ctx context.Context, ipVersion int, l4ProtoNo uint16, port int, outputFile string) (err error) {
kernelVersion, err := internal.KernelVersion()
if err != nil {
return fmt.Errorf("failed to get kernel version: %w", err)
}
if requirement := consts.HelperBpfGetFuncIpVersionFeatureVersion; kernelVersion.Less(requirement) {
return fmt.Errorf("your kernel version %v does not support bpf_get_func_ip; expect >=%v; upgrade your kernel and try again",
kernelVersion.String(),
requirement.String())
}
objs, err := rewriteAndLoadBpf(ipVersion, l4ProtoNo, port)
if err != nil {
return
Expand Down

0 comments on commit dceeade

Please sign in to comment.