vpn-policy-routing: support phys-dev policies

Signed-off-by: Stan Grishin <stangri@melmac.net>
This commit is contained in:
Stan Grishin
2020-05-04 22:47:32 +00:00
parent f24f339eb1
commit 7bb2ccd4e1
3 changed files with 15 additions and 5 deletions
@@ -122,7 +122,7 @@ is_ipv6_global() { [ "${1:0:4}" = "2001" ]; }
# is_ipv6_global() { is_ipv6 "$1" && ! is_ipv6_link_local "$1" && ! is_ipv6_link_local "$1"; }
is_netmask() { local ip="${1%/*}"; [ "$ip" != "$1" ] && is_ipv4 "$ip"; }
is_domain() { [ "${1//[a-zA-Z-]}" != "$1" ]; }
is_phys_dev() { [ "${1:0:1}" = "@" ] && ip -4 r | grep -q "^${1:1}"; }
is_phys_dev() { [ "${1:0:1}" = "@" ] && ip l show | grep -E -q "^\\d+\\W+${1:1}"; }
is_turris() { /bin/ubus -S call system board | /bin/grep 'Turris' | /bin/grep -q '15.05'; }
is_chaos_calmer() { ubus -S call system board | grep -q 'Chaos Calmer'; }
dnsmasq_kill() { killall -q -HUP dnsmasq; }
@@ -369,7 +369,7 @@ insert_policy() {
unset valueNeg; value="$laddr";
fi
if is_phys_dev "$value"; then
param="$param $valueNeg -i ${value:1}"
param="$param $valueNeg -m physdev --physdev-in ${value:1}"
elif is_mac_address "$value"; then
param="$param -m mac $valueNeg --mac-source $value"
elif [ "${appendLocalPolicy//-d}" != "$appendLocalPolicy" ] && [ -n "$raddr" ]; then