Browse Source

Merge pull request #147 from tohojo/iptables-compat

Iptables compat fixes
Toke Høiland-Jørgensen 1 year ago
parent
commit
7ce734ea19
4 changed files with 21 additions and 0 deletions
  1. 2 0
      platform/openwrt/sqm.conf
  2. 2 0
      src/defaults.sh
  3. 16 0
      src/functions.sh
  4. 1 0
      src/simple.qos

+ 2 - 0
platform/openwrt/sqm.conf

@@ -3,3 +3,5 @@ SQM_STATE_DIR=/var/run/sqm
 SQM_QDISC_STATE_DIR=${SQM_STATE_DIR}/available_qdiscs
 SQM_CHECK_QDISCS="fq_codel codel pie sfq cake"
 SQM_SYSLOG=1
+IP6TABLES_BINARY=$(command -v ip6tables-nft)
+IPTABLES_BINARY=$(command -v iptables-nft)

+ 2 - 0
src/defaults.sh

@@ -33,8 +33,10 @@
 [ -z "$IP_BINARY" ] && IP_BINARY=$(command -v ip)
 [ -z "$IPTABLES" ] && IPTABLES=iptables_wrapper
 [ -z "$IPTABLES_BINARY" ] && IPTABLES_BINARY=$(command -v iptables)
+[ -z "$IPTABLES_BINARY" ] && IPTABLES_BINARY=$(command -v iptables-nft)
 [ -z "$IP6TABLES" ] && IP6TABLES=ip6tables_wrapper
 [ -z "$IP6TABLES_BINARY" ] && IP6TABLES_BINARY=$(command -v ip6tables)
+[ -z "$IP6TABLES_BINARY" ] && IP6TABLES_BINARY=$(command -v ip6tables-nft)
 [ -z "$IPTABLES_ARGS" ] && IPTABLES_ARGS="-w 1"
 
 

+ 16 - 0
src/functions.sh

@@ -174,6 +174,22 @@ ip6tables_wrapper(){
     cmd_wrapper ip6tables ${IP6TABLES_BINARY} "$@"
 }
 
+verify_iptables()
+{
+    local ret
+    ret=0
+
+    if [ -z "$IPTABLES_BINARY" ]; then
+        sqm_error "No iptables binary found, please install 'iptables' or 'iptables-nft' to use this script"
+        ret=1
+    fi
+    if [ -z "$IP6TABLES_BINARY" ]; then
+        sqm_error "No ip6tables binary found, please install 'ip6tables' or 'ip6tables-nft' to use this script"
+        ret=1
+    fi
+    return $ret
+}
+
 # wrapper to call tc to allow debug logging
 tc_wrapper(){
     cmd_wrapper tc ${TC_BINARY} "$@"

+ 1 - 0
src/simple.qos

@@ -230,5 +230,6 @@ ingress() {
 sqm_prepare_script() {
     do_modules
     verify_qdisc "htb" || return 1
+    verify_iptables || return 1
     ipt_setup
 }