Skip to content

Commit

Permalink
functions: Add verify_iptables to explicitly check if iptables is found
Browse files Browse the repository at this point in the history
Add a new function to explicitly check if we found an iptables binary on
startup; and call this from simple.qos so we can error out when this
happens.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Jan 25, 2022
1 parent 5463adb commit 9323c3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} "$@"
Expand Down
1 change: 1 addition & 0 deletions src/simple.qos
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,6 @@ ingress() {
sqm_prepare_script() {
do_modules
verify_qdisc "htb" || return 1
verify_iptables || return 1
ipt_setup
}

0 comments on commit 9323c3a

Please sign in to comment.