mwan3: fix bug when one interface is a prefix of another
correctly terminate interface status checks with new lines so that interface status does not get confused when one interface is a prefix of another interface. Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
This commit is contained in:
parent
189f92da4a
commit
5faa99f3b8
1 changed files with 12 additions and 11 deletions
|
@ -361,7 +361,7 @@ mwan3_set_general_iptables()
|
||||||
local IPT current update error
|
local IPT current update error
|
||||||
for IPT in "$IPT4" "$IPT6"; do
|
for IPT in "$IPT4" "$IPT6"; do
|
||||||
[ "$IPT" = "$IPT6" ] && [ $NO_IPV6 -ne 0 ] && continue
|
[ "$IPT" = "$IPT6" ] && [ $NO_IPV6 -ne 0 ] && continue
|
||||||
current="$($IPT -S)"
|
current="$($IPT -S)"$'\n'
|
||||||
update="*mangle"
|
update="*mangle"
|
||||||
if [ -n "${current##*-N mwan3_ifaces_in*}" ]; then
|
if [ -n "${current##*-N mwan3_ifaces_in*}" ]; then
|
||||||
mwan3_push_update -N mwan3_ifaces_in
|
mwan3_push_update -N mwan3_ifaces_in
|
||||||
|
@ -463,13 +463,14 @@ mwan3_create_iface_iptables()
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
current="$($IPT -S)"
|
|
||||||
|
current="$($IPT -S)"$'\n'
|
||||||
update="*mangle"
|
update="*mangle"
|
||||||
if [ -n "${current##*-N mwan3_ifaces_in*}" ]; then
|
if [ -n "${current##*-N mwan3_ifaces_in*}" ]; then
|
||||||
mwan3_push_update -N mwan3_ifaces_in
|
mwan3_push_update -N mwan3_ifaces_in
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${current##*-N mwan3_iface_in_$1*}" ]; then
|
if [ -n "${current##*-N mwan3_iface_in_$1$'\n'*}" ]; then
|
||||||
mwan3_push_update -N "mwan3_iface_in_$1"
|
mwan3_push_update -N "mwan3_iface_in_$1"
|
||||||
else
|
else
|
||||||
mwan3_push_update -F "mwan3_iface_in_$1"
|
mwan3_push_update -F "mwan3_iface_in_$1"
|
||||||
|
@ -487,7 +488,7 @@ mwan3_create_iface_iptables()
|
||||||
-m comment --comment "$1" \
|
-m comment --comment "$1" \
|
||||||
-j MARK --set-xmark "$(mwan3_id2mask id MMX_MASK)/$MMX_MASK"
|
-j MARK --set-xmark "$(mwan3_id2mask id MMX_MASK)/$MMX_MASK"
|
||||||
|
|
||||||
if [ -n "${current##*-A mwan3_ifaces_in -m mark --mark 0x0/$MMX_MASK -j mwan3_iface_in_${1}*}" ]; then
|
if [ -n "${current##*-A mwan3_ifaces_in -m mark --mark 0x0/$MMX_MASK -j mwan3_iface_in_${1}$'\n'*}" ]; then
|
||||||
mwan3_push_update -A mwan3_ifaces_in \
|
mwan3_push_update -A mwan3_ifaces_in \
|
||||||
-m mark --mark 0x0/$MMX_MASK \
|
-m mark --mark 0x0/$MMX_MASK \
|
||||||
-j "mwan3_iface_in_$1"
|
-j "mwan3_iface_in_$1"
|
||||||
|
@ -705,7 +706,7 @@ mwan3_set_policy()
|
||||||
IPT="$IPT6"
|
IPT="$IPT6"
|
||||||
IPTR="$IPT6R"
|
IPTR="$IPT6R"
|
||||||
fi
|
fi
|
||||||
current="$($IPT -S)"
|
current="$($IPT -S)"$'\n'
|
||||||
update="*mangle"
|
update="*mangle"
|
||||||
|
|
||||||
if [ "$family" = "ipv4" ] && [ $is_offline -eq 0 ]; then
|
if [ "$family" = "ipv4" ] && [ $is_offline -eq 0 ]; then
|
||||||
|
@ -784,9 +785,9 @@ mwan3_create_policies_iptables()
|
||||||
|
|
||||||
for IPT in "$IPT4" "$IPT6"; do
|
for IPT in "$IPT4" "$IPT6"; do
|
||||||
[ "$IPT" = "$IPT6" ] && [ $NO_IPV6 -ne 0 ] && continue
|
[ "$IPT" = "$IPT6" ] && [ $NO_IPV6 -ne 0 ] && continue
|
||||||
current="$($IPT -S)"
|
current="$($IPT -S)"$'\n'
|
||||||
update="*mangle"
|
update="*mangle"
|
||||||
if [ -n "${current##*-N mwan3_policy_$1*}" ]; then
|
if [ -n "${current##*-N mwan3_policy_$1$'\n'*}" ]; then
|
||||||
mwan3_push_update -N "mwan3_policy_$1"
|
mwan3_push_update -N "mwan3_policy_$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -844,7 +845,7 @@ mwan3_set_sticky_iptables()
|
||||||
mwan3_get_iface_id id "$1"
|
mwan3_get_iface_id id "$1"
|
||||||
|
|
||||||
[ -n "$id" ] || return 0
|
[ -n "$id" ] || return 0
|
||||||
if [ -z "${current##*-N mwan3_iface_in_$1*}" ]; then
|
if [ -z "${current##*-N mwan3_iface_in_$1$'\n'*}" ]; then
|
||||||
mwan3_push_update -I "mwan3_rule_$rule" \
|
mwan3_push_update -I "mwan3_rule_$rule" \
|
||||||
-m mark --mark "$(mwan3_id2mask id MMX_MASK)/$MMX_MASK" \
|
-m mark --mark "$(mwan3_id2mask id MMX_MASK)/$MMX_MASK" \
|
||||||
-m set ! --match-set "mwan3_sticky_$rule" src,src \
|
-m set ! --match-set "mwan3_sticky_$rule" src,src \
|
||||||
|
@ -946,12 +947,12 @@ mwan3_set_user_iptables_rule()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $rule_policy -eq 1 ] && [ -n "${current##*-N $policy*}" ]; then
|
if [ $rule_policy -eq 1 ] && [ -n "${current##*-N $policy$'\n'*}" ]; then
|
||||||
mwan3_push_update -N "$policy"
|
mwan3_push_update -N "$policy"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $rule_policy -eq 1 ] && [ "$sticky" -eq 1 ]; then
|
if [ $rule_policy -eq 1 ] && [ "$sticky" -eq 1 ]; then
|
||||||
if [ -n "${current##*-N mwan3_rule_$1*}" ]; then
|
if [ -n "${current##*-N mwan3_rule_$1$'\n'*}" ]; then
|
||||||
mwan3_push_update -N "mwan3_rule_$1"
|
mwan3_push_update -N "mwan3_rule_$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1046,7 +1047,7 @@ mwan3_set_user_rules()
|
||||||
fi
|
fi
|
||||||
[ "$ipv" = "ipv6" ] && [ $NO_IPV6 -ne 0 ] && continue
|
[ "$ipv" = "ipv6" ] && [ $NO_IPV6 -ne 0 ] && continue
|
||||||
update="*mangle"
|
update="*mangle"
|
||||||
current="$($IPT -S)"
|
current="$($IPT -S)"$'\n'
|
||||||
|
|
||||||
|
|
||||||
if [ -n "${current##*-N mwan3_rules*}" ]; then
|
if [ -n "${current##*-N mwan3_rules*}" ]; then
|
||||||
|
|
Loading…
Reference in a new issue