small-package/natflow/files/natflow-boot.init

61 lines
1.9 KiB
Plaintext
Raw Normal View History

2023-01-28 01:28:48 +08:00
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
START=95
2023-08-28 23:35:56 +08:00
disable_gro_gso() {
2023-01-28 01:28:48 +08:00
which ethtool &>/dev/null || return 0
for eth in $(ifconfig | grep "^eth\|^dsa" | awk '{print $1}' | sort | uniq); do
2023-08-28 23:35:56 +08:00
ethtool -k "$eth" | grep -q "generic-receive-offload: off" || {
2023-01-28 01:28:48 +08:00
ethtool -K "$eth" gro off
2023-06-12 23:35:39 +08:00
logger -t natflow "disable gro for <$eth>"
2023-01-28 01:28:48 +08:00
}
2023-08-28 23:35:56 +08:00
ethtool -k "$eth" | grep -q "generic-segmentation-offload: off" || {
ethtool -K "$eth" gso off
logger -t natflow "disable gso for <$eth>"
}
2023-01-28 01:28:48 +08:00
done
}
start() {
test -c /dev/natflow_ctl || return 0
2023-08-28 23:35:56 +08:00
disable_gro_gso
2023-01-28 01:28:48 +08:00
hwnat_wed=$(uci get natflow.main.hwnat_wed 2>/dev/null || echo 0)
hwnat=$(uci get natflow.main.hwnat 2>/dev/null || echo 0)
enabled=$(uci get natflow.main.enabled 2>/dev/null || echo 0)
debug=$(uci get natflow.main.debug 2>/dev/null || echo 3)
delay_pkts=$(uci get natflow.main.delay_pkts 2>/dev/null || echo 0)
skip_qos_to_slow_path=$(uci get natflow.main.skip_qos_to_slow_path 2>/dev/null || echo 0)
ifname_filter=$(uci get natflow.main.ifname_filter 2>/dev/null)
2023-12-10 09:21:03 +08:00
echo "debug=$debug" >/dev/natflow_ctl
echo "disabled=$((!enabled))" >/dev/natflow_ctl
grep -q "hwnat=" </dev/natflow_ctl && echo "hwnat=$hwnat" >/dev/natflow_ctl
grep -q "hwnat_wed_disabled=" </dev/natflow_ctl && echo "hwnat_wed_disabled=$((!hwnat_wed))" >/dev/natflow_ctl
2023-11-28 16:22:44 +08:00
if [ "${hwnat_wed}" = "1" ]; then
for p in /sys/module/*/parameters/wed_enable; do
2023-12-10 09:21:03 +08:00
test -e "$p" && echo Y >"$p"
2023-11-28 16:22:44 +08:00
done
else
for p in /sys/module/*/parameters/wed_enable; do
2023-12-10 09:21:03 +08:00
test -e "$p" && echo N >"$p"
2023-11-28 16:22:44 +08:00
done
fi
2023-09-08 16:26:06 +08:00
2023-12-10 09:21:03 +08:00
echo "delay_pkts=$delay_pkts" >/dev/natflow_ctl
echo "skip_qos_to_slow_path=$skip_qos_to_slow_path" >/dev/natflow_ctl
2023-01-28 01:28:48 +08:00
echo ifname_clear >/dev/natflow_ctl
for ifn in ${ifname_filter}; do
2023-12-10 09:21:03 +08:00
echo "ifname_add=$ifn" >/dev/natflow_ctl
2023-01-28 01:28:48 +08:00
done
}
stop() {
test -c /dev/natflow_ctl || return 0
echo disabled=1 >/dev/natflow_ctl
}
restart() {
start
}