Skip to content

Commit f66a73a

Browse files
committed
fix(tproxy): check_kernel_feature 增加 /sys/module 运行时检测回退
1 parent d6ebfb1 commit f66a73a

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/module/scripts/network/tproxy.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,18 +488,23 @@ check_kernel_feature() {
488488
local feature="$1"
489489
local config_name="CONFIG_${feature}"
490490

491+
# Check compile-time config (/proc/config.gz)
491492
if [ -f "$TMPDIR/kernel_config.cache" ]; then
492493
if grep -qE "^${config_name}=[ym]$" "$TMPDIR/kernel_config.cache" 2> /dev/null; then
493-
log Debug "Kernel feature $feature is enabled"
494+
log Debug "Kernel feature $feature is enabled (config)"
494495
return 0
495-
else
496-
log Warn "Kernel feature $feature is disabled or not found"
497-
return 1
498496
fi
499-
else
500-
log Warn "Kernel config cache not available, cannot check $feature"
501-
return 1
502497
fi
498+
499+
# check runtime loaded modules (/sys/module/)
500+
local module_name=$(echo "$feature" | tr 'A-Z' 'a-z')
501+
if [ -d "/sys/module/$module_name" ]; then
502+
log Debug "Kernel feature $feature is enabled (loaded module)"
503+
return 0
504+
fi
505+
506+
log Warn "Kernel feature $feature is disabled or not found"
507+
return 1
503508
}
504509

505510
check_tproxy_support() {

0 commit comments

Comments
 (0)