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

refactor/optimize(bpf): rework bpf route with bpf_loop #580

Merged
merged 14 commits into from
Oct 29, 2024
Merged
2 changes: 1 addition & 1 deletion .github/workflows/kernel-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
strategy:
fail-fast: false
matrix:
kernel: [ '5.15-20240305.092417', '6.1-20240305.092417', '6.6-20240305.092417' ]
kernel: [ '6.1-20240305.092417', '6.6-20240305.092417' ]
timeout-minutes: 10
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ STRIP ?= llvm-strip
CFLAGS := -O2 -Wall -Werror $(CFLAGS)
TARGET ?= bpfel,bpfeb
OUTPUT ?= dae
MAX_MATCH_SET_LEN ?= 64
MAX_MATCH_SET_LEN ?= 1024
CFLAGS := -DMAX_MATCH_SET_LEN=$(MAX_MATCH_SET_LEN) $(CFLAGS)
NOSTRIP ?= n
STRIP_PATH := $(shell command -v $(STRIP) 2>/dev/null)
Expand Down
3 changes: 2 additions & 1 deletion common/consts/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (i OutboundIndex) IsReserved() bool {

var (
MaxMatchSetLen_ = ""
MaxMatchSetLen = 32 * 2
MaxMatchSetLen = 32 * 32
)

func init() {
Expand Down Expand Up @@ -157,6 +157,7 @@ var (
UserspaceBatchUpdateLpmTrieFeatureVersion = internal.Version{5, 13, 0}
BpfTimerFeatureVersion = internal.Version{5, 15, 0}
HelperBpfGetFuncIpVersionFeatureVersion = internal.Version{5, 15, 0}
BpfLoopFeatureVersion = internal.Version{5, 17, 0}
)

const (
Expand Down
8 changes: 8 additions & 0 deletions control/control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (

"github.com/bits-and-blooms/bloom/v3"
"github.com/cilium/ebpf"
"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/features"
"github.com/cilium/ebpf/rlimit"
"github.com/daeuniverse/dae/common"
"github.com/daeuniverse/dae/common/assets"
Expand Down Expand Up @@ -101,6 +103,12 @@ func NewControlPlane(
}
/// Check linux kernel requirements.
// Check version from high to low to reduce the number of user upgrading kernel.
if err := features.HaveProgramHelper(ebpf.SchedCLS, asm.FnLoop); err != nil {
return nil, fmt.Errorf("%w: your kernel version %v does not support bpf_loop (needed by routing); expect >=%v; upgrade your kernel and try again",
err,
kernelVersion.String(),
consts.BpfLoopFeatureVersion.String())
}
if requirement := consts.ChecksumFeatureVersion; kernelVersion.Less(requirement) {
return nil, fmt.Errorf("your kernel version %v does not support checksum related features; expect >=%v; upgrade your kernel and try again",
kernelVersion.String(),
Expand Down
Loading
Loading