fix: caddy cannot accept connections (#262)

* fix: caddy cannot accept connections

* chore: deprecate -D__REMOVE_BPF_PRINTK

---------

Co-authored-by: dae-bot[bot] <136105375+dae-bot[bot]@users.noreply.github.com>
This commit is contained in:
mzz
2023-08-06 01:43:17 +08:00
committed by GitHub
parent f5d713f04f
commit 7ef8205d41
7 changed files with 8 additions and 21 deletions

View File

@ -102,7 +102,6 @@ jobs:
mkdir -p ./build/
export CGO_ENABLED=0
export GOFLAGS="-trimpath -modcacherw"
export CFLAGS="-D__REMOVE_BPF_PRINTK"
export OUTPUT=build/dae-$ASSET_NAME
export VERSION=${{ steps.get_version.outputs.VERSION }}
export CLANG=clang-15

View File

@ -102,7 +102,6 @@ jobs:
mkdir -p ./build/
export CGO_ENABLED=0
export GOFLAGS="-trimpath -modcacherw"
export CFLAGS="-D__REMOVE_BPF_PRINTK"
export OUTPUT=build/dae-$ASSET_NAME
export VERSION=${{ steps.get_version.outputs.VERSION }}
export CLANG=clang-15

View File

@ -118,7 +118,6 @@ jobs:
mkdir -p ./build/
export CGO_ENABLED=0
export GOFLAGS="-trimpath -modcacherw"
export CFLAGS="-D__REMOVE_BPF_PRINTK"
export OUTPUT=build/dae-$ASSET_NAME
export VERSION=${{ steps.get_version.outputs.VERSION }}
export CLANG=clang-15

View File

@ -231,7 +231,7 @@ retryLoadBpf:
if strings.Contains(err.Error(), "no BTF found for kernel version") {
err = fmt.Errorf("%w: you should re-compile linux kernel with BTF configurations; see docs for more information", err)
} else if strings.Contains(err.Error(), "unknown func bpf_trace_printk") {
err = fmt.Errorf(`%w: please try to compile dae without bpf_printk; example of cross-compilation to arm64: make GOARCH=arm64 CGO_ENABLED=0 CFLAGS="-D__REMOVE_BPF_PRINTK"`, err)
err = fmt.Errorf(`%w: please try to compile dae without bpf_printk"`, err)
} else if strings.Contains(err.Error(), "unknown func bpf_probe_read") {
err = fmt.Errorf(`%w: please re-compile linux kernel with CONFIG_BPF_EVENTS=y and CONFIG_KPROBE_EVENTS=y"`, err)
}

View File

@ -18,9 +18,13 @@
// #define __DEBUG_ROUTING
// #define __PRINT_ROUTING_RESULT
// #define __PRINT_SETUP_PROCESS_CONNNECTION
// #define __REMOVE_BPF_PRINTK
// #define __DEBUG
// #define __UNROLL_ROUTE_LOOP
#ifndef __DEBUG
#undef bpf_printk
#define bpf_printk(...) (void)0
#endif
// #define likely(x) x
// #define unlikely(x) x
#define likely(x) __builtin_expect((x), 1)
@ -1362,10 +1366,6 @@ int tproxy_lan_ingress(struct __sk_buff *skb) {
sk = bpf_skc_lookup_tcp(skb, &tuple, tuple_size, BPF_F_CURRENT_NETNS, 0);
if (sk) {
if (tuples.dport == bpf_ntohs(445)) {
// samba. It is safe because the smb port cannot be customized.
goto sk_accept;
}
if (sk->state != BPF_TCP_LISTEN) {
is_old_conn = true;
goto assign;
@ -1487,6 +1487,7 @@ assign:
bpf_printk("bpf_sk_assign: %d, perhaps you have other TPROXY programs "
"(such as v2ray) running?",
ret);
return TC_ACT_OK;
} else {
bpf_printk("bpf_sk_assign: %d", ret);
}

View File

@ -1,15 +1,5 @@
# Troubleshooting
## Unknown bpf_trace_printk
```console
invalid argument: unknown func bpf_trace_printk
```
Solution:
Compile dae with CFLAG `-D__REMOVE_BPF_PRINTK`. See [build-by-yourself](user-guide/build-by-yourself.md).
## No network after `dae suspend`
Do not set dae as the DNS in DHCP setting. For example, you can set `223.5.5.5` as DNS in your DHCP setting.
@ -77,4 +67,4 @@ If you use `clang-13` to compile dae, you may encounter this problem.
There are ways to resolve it:
1. Method 1: Use `clang-15` or higher versions to compile dae. Or just download dae from [releases](https://github.com/daeuniverse/dae/releases).
2. Method 2: Add CFLAGS `-D__UNROLL_ROUTE_LOOP` while compiling. However, it will increse memory occupation (or swap space) at the eBPF loading stage (about 180MB). For example, compile dae to ARM64 using `make CGO_ENABLED=0 GOARCH=arm64 CFLAGS="-D__UNROLL_ROUTE_LOOP -D__REMOVE_BPF_PRINTK"`.
2. Method 2: Add CFLAGS `-D__UNROLL_ROUTE_LOOP` while compiling. However, it will increse memory occupation (or swap space) at the eBPF loading stage (about 180MB). For example, compile dae to ARM64 using `make CGO_ENABLED=0 GOARCH=arm64 CFLAGS="-D__UNROLL_ROUTE_LOOP"`.

View File

@ -19,7 +19,6 @@ cd dae
git submodule update --init
## Minimal dependency build
make GOFLAGS="-buildvcs=false" \
CFLAGS="-D__REMOVE_BPF_PRINTK" \
CC=clang
## Normal build