aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorStan Grishin <stangri@melmac.ca>2022-12-22 18:52:41 +0000
committerStan Grishin <stangri@melmac.ca>2022-12-22 18:52:41 +0000
commitedbcb97b78d36a813e6aa04f6b6ff9bc20be2eb3 (patch)
tree39003e144e77ca487aa682502a4da31e7b3f44f7 /net
parent96b2cd70e108d3ca4b9327881b00f1300c7f8cd0 (diff)
pbr: bugfix: Makefile, rt_tables fix
Signed-off-by: Stan Grishin <stangri@melmac.ca>
Diffstat (limited to 'net')
2 files changed, 12 insertions, 7 deletions
diff --git a/net/pbr/Makefile b/net/pbr/Makefile
index e5b967ff0..7ec156ac7 100644
--- a/net/pbr/Makefile
+++ b/net/pbr/Makefile
@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=pbr
PKG_VERSION:=1.0.1
-PKG_RELEASE:=1
+PKG_RELEASE:=3
PKG_LICENSE:=GPL-3.0-or-later
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
@@ -20,7 +20,7 @@ define Package/pbr/default
URL:=https://docs.openwrt.melmac.net/pbr/
DEPENDS:=+ip-full +jshn +jsonfilter +resolveip
CONFLICTS:=vpnbypass vpn-policy-routing
- PROVIDES:=pbr vpnbypass vpn-policy-routing
+ PROVIDES:=vpnbypass vpn-policy-routing
PKGARCH:=all
endef
diff --git a/net/pbr/files/etc/init.d/pbr.init b/net/pbr/files/etc/init.d/pbr.init
index 3ee9a9b8c..16aae0596 100755
--- a/net/pbr/files/etc/init.d/pbr.init
+++ b/net/pbr/files/etc/init.d/pbr.init
@@ -264,8 +264,8 @@ is_service_running_nft() { [ -x "$nft" ] && [ -n "$(get_mark_nft_chains)" ]; }
# is_service_running_nft() { [ -x "$nft" ] && [ -s "$nftPermFile" ]; }
is_service_running() { if is_nft; then is_service_running_nft; else is_service_running_iptables; fi; }
is_netifd_table() { local iface="$1"; [ "$(uci -q get "network.${iface}.ip4table")" = "${packageName}_${iface%6}" ]; }
-get_rt_tables_id() { grep "${packageName}_${iface}" /etc/iproute2/rt_tables | awk '{print $1;}'; }
-get_rt_tables_next_id() { echo "$(($(sort -r -n /etc/iproute2/rt_tables | grep -o -E -m 1 "^[0-9]+")+1))"; }
+get_rt_tables_id() { local iface="$1"; grep "${packageName}_${iface}" '/etc/iproute2/rt_tables' | awk '{print $1;}'; }
+get_rt_tables_next_id() { echo "$(($(sort -r -n '/etc/iproute2/rt_tables' | grep -o -E -m 1 "^[0-9]+")+1))"; }
_check_config() { local en; config_get_bool en "$1" 'enabled' 1; [ "$en" -gt 0 ] && _cfg_enabled=0; }
is_config_enabled() {
local cfg="$1" _cfg_enabled=1
@@ -1658,12 +1658,16 @@ interface_routing() {
$ip_full -6 rule add fwmark "${mark}/${fw_mask}" table "$tid" priority "$priority" || ipv6_error=1
fi
else
- sed -i "/${ipTablePrefix}_${iface}/d" /etc/iproute2/rt_tables
+ if ! grep -q "$tid ${ipTablePrefix}_${iface}" '/etc/iproute2/rt_tables'; then
+ sed -i "/${ipTablePrefix}_${iface}/d" '/etc/iproute2/rt_tables'
+ sync
+ echo "$tid ${ipTablePrefix}_${iface}" >> '/etc/iproute2/rt_tables'
+ sync
+ fi
$ip_full -4 rule del fwmark "${mark}/${fw_mask}" table "$tid" >/dev/null 2>&1
$ip_full -4 route flush table "$tid" >/dev/null 2>&1
if [ -n "$gw4" ] || [ "$strict_enforcement" -ne 0 ]; then
ipv4_error=0
- echo "$tid ${ipTablePrefix}_${iface}" >> /etc/iproute2/rt_tables
if [ -z "$gw4" ]; then
$ip_full -4 route add unreachable default table "$tid" >/dev/null 2>&1 || ipv4_error=1
else
@@ -1754,7 +1758,8 @@ EOF
$ip_full rule del fwmark "${mark}/${fw_mask}" table "$tid" >/dev/null 2>&1
if ! is_netifd_table "$iface"; then
$ip_full route flush table "$tid" >/dev/null 2>&1
- sed -i "/${ipTablePrefix}_${iface}/d" /etc/iproute2/rt_tables
+ sed -i "/${ipTablePrefix}_${iface}/d" '/etc/iproute2/rt_tables'
+ sync
fi
return "$s"
;;