Skip to content
Open
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
157 changes: 157 additions & 0 deletions net/bpftune/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=bpftune
PKG_VERSION:=0.4.2-f562f77
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/KyleGospo/bpftune.git
Comment on lines +12 to +13

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: two things about the move to the fork's git tree:

  • PKG_SOURCE_PROTO:=git is a last resort in this feed when a release tarball exists; the previous revision fetched a codeload tarball, and that form works against a fork commit too.
  • bpftune and bpftune-full are now built from this fork as well, yet still advertise URL:=https://github.com/oracle/bpftune on lines 38 and 44. Is the non-gaming build meant to track oracle instead?

Generated by Claude Code

PKG_SOURCE_DATE:=2026-08-26
PKG_SOURCE_VERSION:=f562f776aac16478a2eeae1bf4871a66dd0070c3
PKG_MIRROR_HASH:=fb49aaad19ee711226b8bf62ded281e7346750c4e4d08909b2a37ac58765438c
PKG_BUILD_DIR:=$(BUILD_DIR)/$(if $(BUILD_VARIANT),bpftune-$(BUILD_VARIANT)/)bpftune-$(PKG_VERSION)

PKG_LICENSE:=GPL-2.0-WITH-Linux-syscall-note

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this changed from GPL-2.0-or-later while PKG_LICENSE_FILES still points at the same COPYING, and the commit message says nothing about it. The Linux-syscall-note exception normally covers kernel UAPI headers rather than a userspace project — what in the fork's licensing prompted the switch?


Generated by Claude Code

PKG_LICENSE_FILES:=COPYING
PKG_MAINTAINER:=Shon Sebastian <fluffball3@proton.me>

PKG_BUILD_DEPENDS:=bpf-headers

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/bpf.mk

define Package/bpftune/default
SECTION:=net
CATEGORY:=Network
DEPENDS:=+@KERNEL_BPF_EVENTS +@KERNEL_CGROUPS +@KERNEL_CGROUP_BPF \
+kmod-tcp-bbr +libnl-route +libcap +libbpf \
$(BPF_DEPENDS)
endef

define Package/bpftune
$(call Package/bpftune/default)
URL:=https://github.com/oracle/bpftune
TITLE:=BPF driven auto-tuning (needs TCP_CONG_HTCP and TCP_CONG_DCTCP)
CONFLICTS:=bpftune-gaming bpftune-gaming-full
endef

define Package/bpftune-full
$(call Package/bpftune/default)
URL:=https://github.com/oracle/bpftune
TITLE:=bpftune with BTF support (might cause crashloops on limited hardware).
DEPENDS:=+bpftune +@KERNEL_DEBUG_INFO +@KERNEL_DEBUG_INFO_BTF \
+@KERNEL_NAMESPACES +@KERNEL_NET_NS
endef

define Package/bpftune-gaming
$(call Package/bpftune/default)
URL:=https://github.com/KyleGospo/bpftune
TITLE:=Fork of bpftune with gaming tuner without BTF support (needs TCP_CONG_HTCP and TCP_CONG_DCTCP)
VARIANT:=gaming
CONFLICTS:=bpftune bpftune-full
endef
Comment on lines +51 to +57

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bpftune-gaming installs the same paths as bpftune (/usr/sbin/bpftune, /usr/lib/libbpftune.so*, the tuner plugins, /etc/init.d/bpftune, /etc/config/bpftune) but nothing declares the clash, so both can be selected and the second install overwrites the first. Add a CONFLICTS here and the matching entries to the other three packages.

Suggested change
define Package/bpftune-gaming
$(call Package/bpftune/default)
URL:=https://github.com/KyleGospo/bpftune
TITLE:=Fork of bpftune with gaming tuner without BTF support (needs TCP_CONG_HTCP and TCP_CONG_DCTCP)
VARIANT:=gaming
endef
define Package/bpftune-gaming
$(call Package/bpftune/default)
URL:=https://github.com/KyleGospo/bpftune
TITLE:=Fork of bpftune with gaming tuner without BTF support (needs TCP_CONG_HTCP and TCP_CONG_DCTCP)
VARIANT:=gaming
CONFLICTS:=bpftune
endef

Generated by Claude Code


define Package/bpftune-gaming-full
$(call Package/bpftune/default)
URL:=https://github.com/KyleGospo/bpftune
TITLE:=bpftune-gaming with BTF support (might cause crashloops on limited hardware)
DEPENDS:=+bpftune-gaming +@KERNEL_DEBUG_INFO +@KERNEL_DEBUG_INFO_BTF \
+@KERNEL_NAMESPACES +@KERNEL_NET_NS
endef

define Package/bpftune/description
bpftune aims to provide lightweight, always-on auto-tuning of system
behaviour. By using BPF observability features, we can continuously
monitor and adjust system behaviour at a fine grain. (Needs TCP_CONG_HTCP
and TCP_CONG_DCTCP from target/linux/generic/config-<version> manually enabled
to function correctly. Runs on no-BTF mode).
endef

define Package/bpftune-full/description
bpftune with BTF support for intended functionality. Needs TCP_CONG_HTCP
and TCP_CONG_DCTCP from target/linux/generic/config-<version> manually enabled
to function, and KERNEL_DEBUG_INFO_REDUCED disabled manually. This package enables
KERNEL_NET_NS and KERNEL_DEBUG_INFO_BTF as well which might cause crashloops on
limited hardware eg. single core cpu routers.
endef

define Package/bpftune-gaming/description
Fork of bpftune which adds separate tuner and changes for gaming. (Needs
TCP_CONG_HTCP and TCP_CONG_DCTCP from target/linux/generic/config-<version>
manually enabled to function correctly. Runs on no-BTF mode).
endef

define Package/bpftune-gaming-full/description
bpftune-gaming with BTF support for intended functionality. Needs TCP_CONG_HTCP
and TCP_CONG_DCTCP from target/linux/generic/config-<version> manually enabled
to function, and KERNEL_DEBUG_INFO_REDUCED disabled manually. This package enables
KERNEL_NET_NS and KERNEL_DEBUG_INFO_BTF as well which might cause crashloops on
limited hardware eg. single core cpu routers.
endef

bpf_srcarch=$(subst \
aarch64,arm64,$(subst \
armeb,arm,$(subst \
i386,x86,$(subst \
x86_64,x86,$(subst \
loongarch64,loongarch,$(subst \
mipsel,mips,$(subst \
mips64,mips,$(subst \
powerpc64,powerpc,$(subst \
riscv64,riscv,$(1))))))))))

BPF_SRCARCH:=$(call bpf_srcarch,$(ARCH))

MAKE_FLAGS += \
BPFTUNE_VERSION="$(PKG_VERSION)-$(PKG_RELEASE)" \
SRCARCH="$(BPF_SRCARCH)" \
BPF_TARGET="$(BPF_TARGET)" \
BPF_CLANG="$(CLANG)" \
LLVM_STRIP="$(LLVM_STRIP)" \
PKG_BUILD_DIR=$(PKG_BUILD_DIR) \
GAMING_BUILD=$(if $(filter gaming,$(BUILD_VARIANT)),true)

define Package/bpftune/conffiles
/etc/config/bpftune
endef
Comment on lines +119 to +121

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conffiles is read per package (package-pack.mk:383), so bpftune-full, bpftune-gaming and bpftune-gaming-full ship /etc/config/bpftune through the shared install block with nothing marking it as a config file — user edits are lost on upgrade for those three.

Suggested change
define Package/bpftune/conffiles
/etc/config/bpftune
endef
define Package/bpftune/conffiles
/etc/config/bpftune
endef
define Package/bpftune-full/conffiles
/etc/config/bpftune
endef
define Package/bpftune-gaming/conffiles
/etc/config/bpftune
endef
define Package/bpftune-gaming-full/conffiles
/etc/config/bpftune
endef

Generated by Claude Code

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved by dropping the install blocks from the two -full packages, thanks


Generated by Claude Code

define Package/bpftune-gaming/conffiles
/etc/config/bpftune
endef

define Package/bpftune/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bpftune $(1)/usr/sbin/bpftune
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/libbpftune.so.0.4.2 $(1)/usr/lib/libbpftune.so.0.4.2
$(LN) libbpftune.so.0.4.2 $(1)/usr/lib/libbpftune.so
$(INSTALL_DIR) $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/tcp_buffer_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/route_table_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/neigh_table_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/sysctl_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/tcp_conn_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/netns_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/net_buffer_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/ip_frag_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/udp_buffer_tuner.so $(1)/usr/lib/bpftune
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DATA) ./files/bpftune.confd $(1)/etc/config/bpftune

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With config_load now gone from the init script, nothing reads this file, so the command_args override it advertises has no effect — and it is shell syntax sitting in the UCI directory, which is not what /etc/config/ is for. Either make it a real UCI section and read it with config_get in start_service, or drop the file together with its conffiles entry and the /etc/config INSTALL_DIR on line 105.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved by converting it to a UCI section read with config_get, thanks


Generated by Claude Code

$(INSTALL_BIN) ./files/bpftune.initd $(1)/etc/init.d/bpftune
endef

define Package/bpftune-gaming/install
$(call Package/bpftune/install)
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/gaming_tuner.so $(1)/usr/lib/bpftune
endef

$(eval $(call BuildPackage,bpftune))
$(eval $(call BuildPackage,bpftune-full))
$(eval $(call BuildPackage,bpftune-gaming))
$(eval $(call BuildPackage,bpftune-gaming-full))
2 changes: 2 additions & 0 deletions net/bpftune/files/bpftune.confd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config defaults 'defaults'
option command_args "-R -c /sys/fs/cgroup"
37 changes: 37 additions & 0 deletions net/bpftune/files/bpftune.initd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh /etc/rc.common
# SPDX-License-Identifier: GPL-2.0-or-later

USE_PROCD=1

START=81

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the PR description says the service is disabled by default, but default_postinst runs enable and start for every script in /etc/init.d/, so bpftune runs from install. If opt-in is intended it has to be arranged explicitly; otherwise the description should be corrected.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved by correcting the PR description, thanks


Generated by Claude Code

STOP=81

NAME=bpftune
PROG=/usr/sbin/bpftune
CONFIG=/etc/config/bpftune

ARGS="-R -c /sys/fs/cgroup"
EXTRA_COMMANDS="checkconf"

checkconf() {
config_load 'bpftune'
config_get ARGS defaults command_args "$ARGS"
$PROG -S $ARGS 2>&1
}

start_pre() {
checkconf > /dev/null 2>&1
}

start_service()
{
if ! start_pre; then
return 1
fi

procd_open_instance
procd_set_param file $CONFIG
procd_set_param command $PROG $ARGS
procd_set_param respawn
procd_close_instance
}
28 changes: 28 additions & 0 deletions net/bpftune/patches/build-src-only.patch

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patches in this feed carry a numeric prefix that pins apply order (010-, 100-, 500-, …); all four files here are unprefixed. Also give fix-libbpftune.patch a descriptive subject and a Signed-off-by: — the sigval_t → union sigval and struct sockaddr cast changes are musl/portability fixes with a real upstream to send them to, unlike the OpenWrt-only build hacks in the other three.


Generated by Claude Code

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I'll look into it. Thanks for the advice.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From ef5d2d5e44dfc4e38e53da92843731b6317aa32d Mon Sep 17 00:00:00 2001
From: Shon Sebastian <fluffball3@proton.me>
Date: Tue, 22 Sep 2026 03:25:50 +0530
Subject: [PATCH] build src only

Simplify build

Signed-off-by: Shon Sebastian <fluffball3@proton.me>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 5e93dc0..c23a5f0 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ INSTALLPATH = $(installprefix)

.PHONY: all clean

-all: srcdir docdir testdir
+all: srcdir

srcdir:
cd src; make
--
2.55.0

128 changes: 128 additions & 0 deletions net/bpftune/patches/fix-Makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
From cb358f17dd1c6b7154f36fe94d2dc5479d6e95c6 Mon Sep 17 00:00:00 2001
From: Shon Sebastian <fluffball3@proton.me>
Date: Tue, 22 Sep 2026 03:23:21 +0530
Subject: [PATCH] fix Makefile

Adapts build for openwrt

Signed-off-by: Shon Sebastian <fluffball3@proton.me>
---
src/Makefile | 53 ++++++++++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 85a6d55..cb80c11 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -15,21 +15,17 @@
# License along with this program. If not, see <https://www.gnu.org/licenses/>.
#

-ARCH ?= $(shell uname -m)
-SRCARCH ?= $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
- -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \
- -e s/aarch64.*/arm64/ )
-
CLANG ?= clang
GCC_BPF ?=
LLC ?= llc
LLVM_STRIP ?= llvm-strip
BPFTOOL ?= bpftool
-BPF_INCLUDE := /usr/include
-BPF_LOCAL_INCLUDE := /usr/local/include
-BPF_CFLAGS := -g -fno-stack-protector -Wall -Wno-incompatible-pointer-types-discards-qualifiers
-NL_INCLUDE := /usr/include/libnl3
-INCLUDES := -I../include -I$(BPF_INCLUDE) -I$(BPF_LOCAL_INCLUDE) -I$(NL_INCLUDE) -I../include/uapi
+BPF_CFLAGS += -g -fno-stack-protector -Wall -Wno-incompatible-pointer-types-discards-qualifiers
+
+INCLUDES := -I../include \
+ -I$(STAGING_DIR)/usr/include \
+ -I$(STAGING_DIR)/usr/include/libnl3
+
INSTALL ?= install

SBINPATH ?= $(shell rpm --eval '%{_sbindir}' 2>/dev/null)
@@ -52,7 +48,7 @@ else
DEFAULT_LIBDIR := lib64
endif

-libdir ?= $(DEFAULT_LIBDIR)
+libdir = lib
installprefix = $(DESTDIR)/$(prefix)

INSTALLPATH = $(installprefix)
@@ -75,7 +71,7 @@ endif
VERSION = 0.4.2
VERSION_SCRIPT := libbpftune.map

-CFLAGS = -fPIC -Wall -Wextra -g -I../include -std=c99
+CFLAGS += -fPIC -Wall -Wextra -g -std=c99

CFLAGS += -DBPFTUNE_VERSION='"$(BPFTUNE_VERSION)"' \
-DBPFTUNER_PREFIX_DIR='"$(prefix)"' \
@@ -92,12 +88,12 @@ VMLINUX_BTF_PATHS := /sys/kernel/btf/vmlinux /boot/vmlinux-$(KERNEL_REL)
VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \
$(wildcard $(VMLINUX_BTF_PATHS))))

-# Some systems ship with a vmlinux.h; use it.
-VMLINUX_H_PATH ?= /usr/include/$(ARCH)-linux-gnu/linux/bpf/
-VMLINUX_H_FILE := $(wildcard $(VMLINUX_H_PATH)/vmlinux.h)
+# Try to reach generated vmlinux.h if it exists
+VMLINUX_H_FILE := $(wildcard $(PKG_BUILD_DIR)/vmlinux.h)

+# Defaults to ../include/bpftune/vmlinux_aarch64.h as the best available fallback.
ifneq ($(VMLINUX_H_FILE),)
-BPF_CFLAGS += -DVMLINUX_H -I$(VMLINUX_H_PATH)
+BPF_CFLAGS += -DVMLINUX_H -I$(PKG_BUILD_DIR)
endif

OPATH :=
@@ -114,9 +110,15 @@ MAKEFLAGS += --no-print-directory
submake_extras := feature_display=0
endif

+ifneq ($(GAMING_BUILD),)
TUNERS = tcp_buffer_tuner route_table_tuner neigh_table_tuner sysctl_tuner \
tcp_conn_tuner netns_tuner net_buffer_tuner ip_frag_tuner \
udp_buffer_tuner gaming_tuner
+else
+TUNERS = tcp_buffer_tuner route_table_tuner neigh_table_tuner sysctl_tuner \
+ tcp_conn_tuner netns_tuner net_buffer_tuner ip_frag_tuner \
+ udp_buffer_tuner
+endif

TUNER_OBJS = $(patsubst %,%.o,$(TUNERS))
TUNER_SRCS = $(patsubst %,%.c,$(TUNERS))
@@ -209,18 +211,21 @@ $(OPATH)bpftune.o: $(OPATH)libbpftune.so
# check if GCC_BPF flag is set, otherwise use CLANG
ifeq ($(GCC_BPF),)
$(BPF_OBJS): $(patsubst %.o,%.c,$(BPF_OBJS)) ../include/bpftune/bpftune.bpf.h
- $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -O2 -target bpf \
- $(INCLUDES) -c $(patsubst %.o,%.c,$(@)) -o $(@)
+ $(BPF_CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -O2 -target $(BPF_TARGET) \
+ -I../include -c $(patsubst %.o,%.c,$(@)) -o $(@)
+ $(LLVM_STRIP) --strip-debug $(@)

$(LEGACY_BPF_OBJS): $(patsubst %.legacy.o,%.c,$(LEGACY_BPF_OBJS)) ../include/bpftune/bpftune.bpf.h
- $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_LEGACY -O2 -target bpf \
- $(INCLUDES) -c $(patsubst %.legacy.o,%.c,$(@)) \
- -o $(@)
+ $(BPF_CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_LEGACY -O2 -target $(BPF_TARGET) \
+ -I../include -c $(patsubst %.legacy.o,%.c,$(@)) \
+ -o $(@)
+ $(LLVM_STRIP) --strip-debug $(@)

$(NOBTF_BPF_OBJS): $(patsubst %.nobtf.o,%.c,$(NOBTF_BPF_OBJS)) ../include/bpftune/bpftune.bpf.h
- $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_NOBTF -O2 -target bpf \
- $(INCLUDES) -c $(patsubst %.nobtf.o,%.c,$(@)) \
- -o $(@)
+ $(BPF_CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_NOBTF -O2 -target $(BPF_TARGET) \
+ -I../include -c $(patsubst %.nobtf.o,%.c,$(@)) \
+ -o $(@)
+ $(LLVM_STRIP) --strip-debug $(@)
else
GCC_BPF_FLAGS := -g -O2 \
$(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) \
--
2.55.0

Loading