Commit Graph

21578 Commits

Author SHA1 Message Date
Vincent Li
13530fa1ef xdp-tools: remove dns query from xdp-dnsrrl
also change user space xdp_dns_log program to
use map /sys/fs/bpf/xdp-dns-denylist/dns_ringbuf

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-10-02 20:20:48 +00:00
Vincent Li
f9c8259050 Add xdpdnsctrl program for safe execution
add xdpdnsctrl to start/stop/status XDP
program from xdpdns.cgi safely.

permission of xdpdnsctrl

chown root.nobody /usr/local/bin/xdpdnsctrl
chmod u+s /usr/local/bin/xdpdnsctrl

result:

-rwsr-x--- 1 root nobody 14672 Mar 19 09:58 /usr/local/bin/xdpdnsctrl
2024-10-02 18:31:21 +00:00
Vincent Li
d30a7b2318 xdp-dns: add start/stop init script and settings
add xdpdns init script to load/unload xdp_dns_denylist
program and run xdp_dns_log to log dns query to system log

rm log/configroot log/initscripts to build image

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-10-02 18:23:44 +00:00
Vincent Li
652ab98e1a xdp-tools: add xdp-dns system logging
add bpf ringbuf to xdp-dns program and
user space program to log DNS query to
system log.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-10-01 23:45:03 +00:00
Vincent Li
17d5413bc2 README: update TLS/SSL SNI blocklist to XDP
Lunatik sni filter currently does not work
for BPFire when chrome browser is used due to
clienthello > 1500 bytes, XDP TLS/SSL has
the same issue, to block domain access, it
appears XDP DNS domain blocking works more
reliable than SNI, so if there is need to block
chrome browser for some domain, use XDP DNS
domain blocking as mitigation.

see https://github.com/vincentmli/BPFire/issues/40

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-10-01 00:28:37 +00:00
Vincent Li
c1281a47ea lunatik: checksum update
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-30 16:28:51 +00:00
Vincent Li
32c15c3fe3 xdp-tools: add xdp-sni
add XDP TLS/SSL SNI parsing

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-30 03:24:30 +00:00
Vincent Li
1b9810cfd9 Merge pull request #45 from selboo/bpfire
修复: 前端端口和后端端口显示错位问题
2024-09-26 07:00:43 -07:00
Selboo
781187a6d3 修复: 前端端口和后端端口显示错位问题 2024-09-26 17:33:50 +08:00
Vincent Li
2cf44838bf lfs/linux: install perf tool from linux source
compile and install perf tool from linux
source for performance monitoring.

change the setting before run perf

echo -1 > /proc/sys/kernel/perf_event_paranoid
echo 0 > /proc/sys/kernel/kptr_restrict

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-23 23:44:53 +00:00
Vincent Li
6f60c4696f lfs/flash-images: missing serial linux command
Add the missing serial linux command so the
flash image can be converted to qcow2, the
bpfire qcow2 image can be deployed in KVM
virtual environment through serial console
installation.

for exmaple:

virsh define BPFire-VM.xml
virsh start BPFire-VM
virsh console BPFire-VM

we will have serial console access to BPFire
VM and the installation will start.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-23 17:56:26 +00:00
Vincent Li
f89feeb197 kernel: use BPFire logo in kernel
how to generate logo format:

apt-get install netpbm

1 convert png format to ppm format

pngtopnm bpfire-logo.png > bpfire-logo.ppm

2 reduce the color count to 224

ppmquant 224 bpfire-logo.ppm > bpfire-logo-224.ppm

3 convert ppm raw format to ascii format

pnmnoraw bpfire-logo-224.ppm > bpfire-logo-ascii.ppm
cp bpfire-logo-ascii.ppm config/kernel/

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-21 02:41:51 +00:00
Vincent Li
e5ee2e8127 grub2: use bpfire logo in grub2 splash
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-21 02:41:51 +00:00
Vincent Li
89baa34b8d Revert "grub: replace ipfire logo with bpfire logo"
This reverts commit bb773a05d5.

drivers/video/logo/logo_linux_clut224.ppm: Binary PNM is not supported
Use pnmnoraw(1) to convert it to ASCII PNM
make[6]: *** [drivers/video/logo/Makefile:31: drivers/video/logo/logo_linux_clut224.c] Error 1
make[5]: *** [scripts/Makefile.build:485: drivers/video/logo] Error 2
make[4]: *** [scripts/Makefile.build:485: drivers/video] Error 2

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-21 02:41:51 +00:00
Vincent Li
ecad4000f2 lunatik: change /lib/modules kernel path to 6.10
whenever compile kernel due to kernel change
lunatik needs to be recompiled too since
lunatik depends on kernel

change filter example Makefile to depend on
current kernel build version

diff --git a/examples/filter/Makefile b/examples/filter/Makefile
index f7eb0f6d..e30566a2 100644
--- a/examples/filter/Makefile
+++ b/examples/filter/Makefile
@@ -1,10 +1,12 @@
 # SPDX-FileCopyrightText: (c) 2023-2024 Ring Zero Desenvolvimento de Software LTDA
 # SPDX-License-Identifier: MIT OR GPL-2.0-only

+VMLINUX_BTF_PATH = /lib/modules/${shell uname -r}/build
+
 all: vmlinux https.o

 vmlinux:
-       bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
+       bpftool btf dump file $(VMLINUX_BTF_PATH)/vmlinux format c > vmlinux.h

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-21 02:41:51 +00:00
Vincent Li
1f42b720d0 kernel: upgrade to 6.10.11
upgrade kernel to recent stable release 6.10.11

1, scripts/kconfig/merge_config.sh does not work for 6.10.11
2, vmlinux BTF binary name changed in 6.10.11
3, remove rtl8812au for now since it has compiling error
4, remove 5.15 nfqueue patch since it does not apply cleanly

also see [0]

[0]: https://github.com/vincentmli/BPFire/issues/41

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-21 02:39:49 +00:00
Vincent Li
bb773a05d5 grub: replace ipfire logo with bpfire logo
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-20 21:31:43 +00:00
Vincent Li
7586e5e517 kernel: disable BTF mismatch
BTF mismatch is not an issue since
we addressed lunatik kernel module
BTF mismatch issue using the same
chroot binary vmlinux BTF.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-18 22:27:39 +00:00
Vincent Li
e5464739c9 README: update XDP DNS and SNI blocklist feature
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-17 23:33:31 +00:00
Vincent Li
0e29b73703 Revert "lunatik: 'bpf_luaxdp_run': BTF not found in kernel"
This reverts commit cacf5f209d.

libbpf version is irrelevant, revert the change

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-17 17:23:27 +00:00
Vincent Li
6723112498 lunatik: missing module BTF kfuncs not regstered
error when run lunatik which loads lunatik kernel modules

root@bpfire-2 lua]# lunatik run examples/filter/sni false

[root@bpfire-2 lua]# dmesg

[  330.411665] lunatik: loading out-of-tree module taints kernel.
[  330.411680] lunatik: module verification failed: signature and/or required key missing - tainting kernel
[  330.433955] Kernel module BTF mismatch detected, BTF debug info may be unavailable for some modules
[  330.767701] missing module BTF, cannot register kfuncs

BPFire chroot build mount /sys/kernel/btf/vmlinux which is
the host binary vmlinux BTF to build against lunatik kernel module,
which result in above error. adjust BPFire kernel build to save
the binary vmlinux BTF to chroot
/lib/modules/6.6.15-ipfire/build/vmlinux for lunatik kernel module.

create the vmlinux.h from the same binary vmlinux BTF for the ebpf https.o

lunatik kernel module is depending on kernel build, adjust the lunatik
build accordingly when kerne upgrade in future.

See https://github.com/vincentmli/BPFire/issues/40
see https://github.com/luainkernel/lunatik/issues/189

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-17 17:22:22 +00:00
Vincent Li
cacf5f209d lunatik: 'bpf_luaxdp_run': BTF not found in kernel
xdp-loader to load https.o result in error below:

libbpf: loading kernel BTF '/sys/kernel/btf/vmlinux': 0
  libbpf: extern (func ksym) 'bpf_luaxdp_run': not found in kernel or module BTFs
  libbpf: failed to load object '/usr/lib/bpf/https.o'
 libxdp: Failed to load program filter_https: Invalid argument
Couldn't attach XDP program on iface 'green0': Invalid argument(-22)

xdp-tools/xdp-loader is built statically with libbpf 1.2
should not be xdp-loader libbpf issue

still try to upgrade bpfire libbpf to 1.3.0 for testing

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-16 01:00:40 +00:00
Vincent Li
dc97ffb40e lunatik: Unknown symbol in module
lunatik requires lunatik_sym.h before build
generate the symbols in chroot build.

remove lunatik_sym.h in origin lunatik source Makefile

root@r210:/home/vincent/go/src/github.com/vincentmli/BPFire/cache/lunatik-5.3.2# git diff
diff --git a/Makefile b/Makefile
index ec172541..1c72f3e1 100644
--- a/Makefile
+++ b/Makefile
@@ -3,14 +3,14 @@

 MODULES_INSTALL_PATH = /lib/modules/${shell uname -r}
 SCRIPTS_INSTALL_PATH = /lib/modules/lua
-LUNATIK_INSTALL_PATH = /usr/local/sbin
-LUA_API = lua/lua.h lua/lauxlib.h lua/lualib.h
+LUNATIK_INSTALL_PATH = /usr/sbin
+LUNATIK_EBPF_INSTALL_PATH = /usr/lib/bpf
 KDIR ?= ${MODULES_INSTALL_PATH}/build
 RM = rm -f
 MKDIR = mkdir -p -m 0755
 INSTALL = install -o root -g root

-all: lunatik_sym.h
+all:
        ${MAKE} -C ${KDIR} M=${PWD} CONFIG_LUNATIK=m    \
        CONFIG_LUNATIK_RUN=m CONFIG_LUNATIK_RUNTIME=y CONFIG_LUNATIK_DEVICE=m   \
        CONFIG_LUNATIK_LINUX=m CONFIG_LUNATIK_NOTIFIER=m CONFIG_LUNATIK_SOCKET=m \
@@ -46,6 +46,7 @@ examples_install:
        ${INSTALL} -m 0644 examples/echod/*.lua ${SCRIPTS_INSTALL_PATH}/examples/echod
        ${MKDIR} ${SCRIPTS_INSTALL_PATH}/examples/filter
        ${INSTALL} -m 0644 examples/filter/*.lua ${SCRIPTS_INSTALL_PATH}/examples/filter
+       ${INSTALL} -m 0644 examples/filter/*.o ${LUNATIK_EBPF_INSTALL_PATH}
        ${MKDIR} ${SCRIPTS_INSTALL_PATH}/examples/dnsblock
        ${INSTALL} -m 0644 examples/dnsblock/*.lua ${SCRIPTS_INSTALL_PATH}/examples/dnsblock
        ${MKDIR} ${SCRIPTS_INSTALL_PATH}/examples/dnsdoctor
@@ -69,7 +70,3 @@ install: scripts_install modules_install

 uninstall: scripts_uninstall modules_uninstall
        depmod -a
-
-lunatik_sym.h: $(LUA_API)
-       ${shell ./gensymbols.sh $(LUA_API) > lunatik_sym.h}
-

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-15 18:48:48 +00:00
Vincent Li
133baf8fc0 lunatik : kernel config change
kernel requires module to be signed, disable force
signing for now.

insmod: ERROR: could not insert module /lib/modules/6.6.15-ipfire/lunatik/lunatik.ko: Key was rejected by service

set CONFIG_MODULE_SIG_FORCE=n

failed to validate module [lunatik] BTF: -22

set CONFIG_MODULE_ALLOW_BTF_MISMATCH=y

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-15 18:41:35 +00:00
Vincent Li
7212a66761 lunatik: re-arrange lunatik and kernel build order
lunatik kernel modules requires kernel to be built first
so /lib/modules is available for lunatik

lunatik also requires resolve_btfids under:

/lib/modules/$(VER)-$(VERSUFIX)/build/tools/bpf/resolve_btfids/

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-15 02:27:17 +00:00
Vincent Li
c690c0c447 lunatik: add lunatik addon
lunatik has LuaXDP that supports scripting XDP
for TLS SNI parsing and many other scripting
featuers for kernel.

see lunatik build workaround in detail

https://github.com/luainkernel/lunatik/issues/189
https://github.com/vincentmli/BPFire/issues/40

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-14 22:46:06 +00:00
Vincent Li
74cf8a3943 xdp-tools: add XDP DNS domain denylist
upgrade xdp-tools and add XDP DNS domain
denylist bpf and user space program.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-12 17:12:16 +00:00
Vincent Li
49d330f2a8 LoxiLB: increase the default session timeout
increase default inactive timeout for established
sessions like ssh session

diff --git a/pkg/loxinet/rules.go b/pkg/loxinet/rules.go
index a67d974..27a9c08 100644
--- a/pkg/loxinet/rules.go
+++ b/pkg/loxinet/rules.go
@@ -85,7 +85,7 @@ const (
        DflHostProbeTimeout        = 60        // Default probe timeout for end-point host
        InitHostProbeTimeout       = 15        // Initial probe timeout for end-point host
        MaxHostProbeTime           = 24 * 3600 // Max possible host health check duration
-       LbDefaultInactiveTimeout   = 4 * 60    // Default inactive timeout for established sessions
+       LbDefaultInactiveTimeout   = 10 * 60   // Default inactive timeout for established sessions
        LbDefaultInactiveNSTimeout = 20        // Default inactive timeout for non-session oriented protocols
        LbMaxInactiveTimeout       = 24 * 3600 // Maximum inactive timeout for established sessions
        MaxEndPointCheckers        = 4         // Maximum helpers to check endpoint health

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-10 03:03:28 +00:00
Vincent Li
3e3b5c0e89 UI: adjust credits for BPFire/IPFire support
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-10 03:03:22 +00:00
Vincent Li
6047d1079b fireinfo: remove fireinfo profile collection
should not send bpfire user profile to ipfire
to confuse ipfire community, bpfire could setup
such profile collection in the future.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-09 04:29:19 +00:00
Vincent Li
c834aa67d4 WebUI: change donation link to bpfire maintainer
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-09 04:29:12 +00:00
Vincent Li
24d3822f82 WebUI: remove ipfire release update info
User should not update ipfire because that
would remove all BPFire eBPF applications

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-09 00:32:30 +00:00
Vincent Li
3579fd95a1 xdp-dns: attach xdp-dns prog to green0 interface
To block or rate limit DNS query from green
network client, the xdp-dns program should
be attached to green0 interface to scan the
DNS query. attach to red0 interface only get
the DNS response packet from red0(WAN), not
matching the DNS query we want.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-09 00:32:30 +00:00
Vincent Li
a6f4f1dc2e README: update BPFire project README
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-09-09 00:32:24 +00:00
Vincent Li
85540f1359 loxilib: upgrade to current development tree
test new loxilb features like fullproxy L7

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-08-28 21:05:18 +00:00
Vincent Li
17f5f3d6cf loxicmd: upgrade to current development tree
test new loxilb features like fullproxy L7 proxy

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-08-28 21:03:55 +00:00
Vincent Li
be30db19f3 golang: upgrade golang to 1.23.0 release
when add loxilb development tree, loxilb requires go >= 1.23.0

    ranlib libloxilbdp.a
    make[3]: Leaving directory '/usr/src/loxilb-0.9.x/loxilb-ebpf/kernel'
    make[2]: Leaving directory '/usr/src/loxilb-0.9.x/loxilb-ebpf'
    go: go.mod requires go >= 1.23.0 (running go 1.22.0)
    make[1]: *** [Makefile:14: build] Error 1
    make[1]: Leaving directory '/usr/src/loxilb-0.9.x'
    make: *** [loxilb:76: /usr/src/log/loxilb-0.9.x] Error 2

after upgrading golang to 1.23.0, loxilb development tree result in error

    make[2]: Leaving directory '/usr/src/loxilb-0.9.x/loxilb-ebpf'
    # runtime
    /usr/lib/go/src/runtime/mbitmap_noallocheaders.go:53:2: mallocHeaderSize redeclared in this block
    /usr/lib/go/src/runtime/mbitmap.go:71:2: other declaration of mallocHeaderSize
    /usr/lib/go/src/runtime/mbitmap_noallocheaders.go:54:2: minSizeForMallocHeader redeclared in this block

the workaround is to remove build/usr/lib/go directory, then
rm log/go-1.23.0, ./make.sh build to re-add go 1.23.0

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-08-28 15:43:13 +00:00
Vincent Li
5f9125b044 loxilb UI: save loxilb configuration
save IP/LB/FW configuration from loxilb UI so
when loxilb restart or bpfire reboot, the configuration
can be restored.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-08-25 16:41:31 +00:00
Vincent Li
84eba5982a loxicmd: upgrade to 0.9.6 release
adopted loxicmd changes in https://github.com/vincentmli/BPFire/issues/30
to work out the UI permission issue.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-08-25 14:12:54 +00:00
Vincent Li
cc0eebaa2f LoxiLB: upgrade to loxilb 0.9.6
upgrade loxilb to 0.9.6 release

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-08-23 18:16:26 +00:00
Vincent Li
acc96d0726 kernel: enable CONFIG_DEBUG_FS
allow syscall tracing with eBPF like
bcc libbpf-tools opensnoop to trouble
shoot open syscall for UI user nobody
unable to run loxicmd save -a -c /var/ipfire/loxilib/

see https://github.com/vincentmli/BPFire/issues/30

mount -t debugfs none /sys/kernel/debug/

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-13 02:14:51 +00:00
Vincent Li
6d3717d9c7 keepalived UI: add dummy ip for HA state tracking
add dummy ip 192.0.2.1 in virutal_ipaddress from (TEST-NET-1)
according to https://www.rfc-editor.org/rfc/rfc5737#section-3
for keepalived HA state tracking, the Master will always
have the dummy ip assigned to green0.

add refresh button for HA state refresh

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-13 02:14:41 +00:00
Vincent Li
56a1588f96 vim: Disable vim automatic visual mode on mouse select
when mouse select, vim automatically turns into
visual mode, this is not convienent when copy
and paste in vim with mouse select. create this
setting for root user.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-09 02:41:58 +00:00
Vincent Li
aa7d243558 langs: installer/setup Chinese translation
complete the chinese translation referenced below
https://git.ipfire.org/?p=people/ummeegge/ipfire-2.x.git;a=commit;h=ca149dc8e2e24f3cfcf7bbc1e2333b2b6d43e0e4

Asked ChatGPT to translate English in msgid to msgstr in Chinese and
ChatGPT did the translation automatically with correct format.  copied
from ChatGPT and pasted in po.zh

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-09 01:47:46 +00:00
Vincent Li
dcb6b5e117 LoxiLB UI: get VIP from ipconfigfile
in HA scenario, the shared/floating VIP
is not configured on the red0 interface

when setup LoxiLB lb from the UI in standby
BPFire, some VIPs are missing since these
VIPs are only configured in the active BPFire.

get VIPs from /var/ipfire/loxilb/ipconfigfile

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-09 01:47:46 +00:00
Vincent Li
067bbaf136 LoxiLB: rename UI ipconfig to ipconfigfile
when run loxicmd save -a -c /var/ipfire/loxilb/
ipconfig directory will be created, which conflicts
with loxilb UI that also save virtual ip to
/var/ipfire/loxilb/ipconfig, so rename ipconfig to
ipconfigfile.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-09 01:47:46 +00:00
Vincent Li
02724e7427 LoxiLB: enable firewall SNAT for green network
when loxilb is enabled and started, enable the
firewall SNAT for green network so green network
could have initiate outgoing traffic like internet
access.

we can achieve this by restoring firewall SNAT setting
from default /var/ipfire/loxilb/FWconfig.txt when loxilb
start up with --config-path=/var/ipfire/loxilb thanks
to the enhancement addressed in issue:

https://github.com/loxilb-io/loxilb/issues/706

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-09 01:47:46 +00:00
Vincent Li
9f7cd8358f LoxiLB: upgrade to loxilb development branch
LoxiLB 0.9.4 lack of SNAT feature for egress traffic
initiated from BPFire green network, when loxilb is
enabled, it breaks BPFire green network client Internet
access, this issue is fixed in the loxilb development
branch, temporarily I make loxilb development branch
as 0.9.5 in BPFire so I could test the SNAT feature and
it works.

see detail in https://github.com/loxilb-io/loxilb/issues/718

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-09 01:47:37 +00:00
Vincent Li
a06eab4ae1 keepalived vs/rs UI: add virtual/real server UI
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-05 21:46:07 +00:00
Vincent Li
0f54cfef92 keepalived/ipvs: move ipvsadm to core package
prepare keepalived with ipvs for layer 4
load balancer

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2024-07-02 20:52:49 +00:00