mirror of
https://github.com/openwrt/packages.git
synced 2026-10-14 09:56:47 +04:00
pbr: bugfix 1.2.2-6
* fixes partial cherry-pick from main Signed-off-by: Stan Grishin <stangri@melmac.ca>
This commit is contained in:
1 parent
793274a78e
commit
e7e6b3b284
6 files changed
+435
-454
No files matched your search
+28
-107
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# Copyright 2017-2025 MOSSDeF, Stan Grishin (stangri@melmac.ca).
|
||||
# Copyright 2017-2026 MOSSDeF, Stan Grishin (stangri@melmac.ca).
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
@@ -11,58 +11,42 @@ PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/pbr/default
|
||||
define Package/pbr
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=Policy Based Routing Service with nft/nft set support
|
||||
URL:=https://github.com/mossdef-org/pbr/
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/pbr
|
||||
$(call Package/pbr/default)
|
||||
TITLE+= with nft/nft set support
|
||||
DEPENDS+=+kmod-nft-core +kmod-nft-nat +nftables-json
|
||||
VARIANT:=nftables
|
||||
DEFAULT_VARIANT:=1
|
||||
endef
|
||||
|
||||
define Package/pbr-netifd
|
||||
$(call Package/pbr/default)
|
||||
TITLE+= with nft/nft set and netifd support
|
||||
VARIANT:=netifd
|
||||
endef
|
||||
|
||||
define Package/pbr/default/description
|
||||
This service enables policy-based routing for WAN interfaces and various VPN tunnels.
|
||||
DEPENDS:= \
|
||||
+ip-full \
|
||||
+jshn \
|
||||
+jsonfilter \
|
||||
+resolveip \
|
||||
+!BUSYBOX_DEFAULT_AWK:gawk \
|
||||
+!BUSYBOX_DEFAULT_GREP:grep \
|
||||
+!BUSYBOX_DEFAULT_SED:sed \
|
||||
+kmod-nft-core \
|
||||
+kmod-nft-nat \
|
||||
+nftables-json
|
||||
endef
|
||||
|
||||
define Package/pbr/description
|
||||
$(call Package/pbr/default/description)
|
||||
This service enables policy-based routing for WAN interfaces and various VPN tunnels.
|
||||
This version supports OpenWrt (23.05 and newer) with firewall4/nft.
|
||||
endef
|
||||
|
||||
define Package/pbr-netifd/description
|
||||
$(call Package/pbr/default/description)
|
||||
This version supports OpenWrt with (23.05 and newer) firewall4/nft.
|
||||
This version uses OpenWrt native netifd/tables to set up interfaces. This is a WIP.
|
||||
endef
|
||||
|
||||
define Package/pbr/default/conffiles
|
||||
define Package/pbr/conffiles
|
||||
/etc/config/pbr
|
||||
endef
|
||||
|
||||
Package/pbr/conffiles = $(Package/pbr/default/conffiles)
|
||||
Package/pbr-netifd/conffiles = $(Package/pbr/default/conffiles)
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/pbr/default/install
|
||||
define Package/pbr/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/etc/init.d/pbr $(1)/etc/init.d/pbr
|
||||
$(SED) "s|^\(readonly PKG_VERSION\).*|\1='$(PKG_VERSION)-r$(PKG_RELEASE)'|" $(1)/etc/init.d/pbr
|
||||
@@ -73,31 +57,20 @@ define Package/pbr/default/install
|
||||
$(INSTALL_DATA) ./files/usr/share/pbr/pbr.user.dnsprefetch $(1)/usr/share/pbr/pbr.user.dnsprefetch
|
||||
$(INSTALL_DATA) ./files/usr/share/pbr/pbr.user.aws $(1)/usr/share/pbr/pbr.user.aws
|
||||
$(INSTALL_DATA) ./files/usr/share/pbr/pbr.user.netflix $(1)/usr/share/pbr/pbr.user.netflix
|
||||
$(INSTALL_DIR) $(1)/usr/share/nftables.d
|
||||
$(CP) ./files/usr/share/nftables.d/* $(1)/usr/share/nftables.d/
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/90-pbr $(1)/etc/uci-defaults/90-pbr
|
||||
endef
|
||||
|
||||
define Package/pbr/install
|
||||
$(call Package/pbr/default/install,$(1))
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/91-pbr-nft $(1)/etc/uci-defaults/91-pbr-nft
|
||||
endef
|
||||
|
||||
define Package/pbr-netifd/install
|
||||
$(call Package/pbr/default/install,$(1))
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/91-pbr-netifd $(1)/etc/uci-defaults/91-pbr-netifd
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/90-pbr $(1)/etc/uci-defaults/90-pbr
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/91-pbr-nft $(1)/etc/uci-defaults/91-pbr-nft
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/99-pbr-version $(1)/etc/uci-defaults/99-pbr-version
|
||||
endef
|
||||
|
||||
define Package/pbr/postinst
|
||||
#!/bin/sh
|
||||
# check if we are on real system
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
chmod -x /etc/init.d/pbr || true
|
||||
fw4 -q reload || true
|
||||
chmod +x /etc/init.d/pbr || true
|
||||
/etc/init.d/pbr netifd check && {
|
||||
echo -n "Reinstalling pbr netifd integration... "
|
||||
/etc/init.d/pbr netifd install >/dev/null 2>&1 && echo "OK" || echo "FAIL"
|
||||
}
|
||||
echo -n "Installing rc.d symlink for pbr... "
|
||||
/etc/init.d/pbr enable && echo "OK" || echo "FAIL"
|
||||
fi
|
||||
@@ -109,9 +82,13 @@ define Package/pbr/prerm
|
||||
# check if we are on real system
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
echo -n "Stopping pbr service... "
|
||||
/etc/init.d/pbr stop quiet >/dev/null 2>&1 && echo "OK" || echo "FAIL"
|
||||
/etc/init.d/pbr stop >/dev/null 2>&1 && echo "OK" || echo "FAIL"
|
||||
echo -n "Removing rc.d symlink for pbr... "
|
||||
/etc/init.d/pbr disable && echo "OK" || echo "FAIL"
|
||||
/etc/init.d/pbr netifd check && {
|
||||
echo -n "Uninstalling pbr netifd integration... "
|
||||
/etc/init.d/pbr netifd uninstall >/dev/null 2>&1 && echo "OK" || echo "FAIL"
|
||||
}
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
@@ -125,60 +102,4 @@ fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/pbr-netifd/postinst
|
||||
#!/bin/sh
|
||||
# check if we are on real system
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
chmod -x /etc/init.d/pbr || true
|
||||
fw4 -q reload || true
|
||||
chmod +x /etc/init.d/pbr || true
|
||||
echo -n "Installing rc.d symlink for pbr-netifd... "
|
||||
/etc/init.d/pbr enable && echo "OK" || echo "FAIL"
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/pbr-netifd/prerm
|
||||
#!/bin/sh
|
||||
# check if we are on real system
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
echo -n "Stopping pbr-netifd service... "
|
||||
/etc/init.d/pbr stop quiet >/dev/null 2>&1 && echo "OK" || echo "FAIL"
|
||||
echo -n "Removing rc.d symlink for pbr... "
|
||||
/etc/init.d/pbr disable && echo "OK" || echo "FAIL"
|
||||
echo -n "Cleaning up /etc/iproute2/rt_tables... "
|
||||
if sed -i '/pbr_/d' /etc/iproute2/rt_tables; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
echo -n "Cleaning up /etc/config/network... "
|
||||
uci -q delete 'network.pbr_default' || true
|
||||
uci -q delete 'network.pbr_default6' || true
|
||||
uci commit network || true
|
||||
if sed -i '/ip.table.*pbr_/d' /etc/config/network; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
echo -n "Restarting Network... "
|
||||
if /etc/init.d/network restart >/dev/null 2>&1; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/pbr-netifd/postrm
|
||||
#!/bin/sh
|
||||
# check if we are on real system
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
fw4 -q reload || true
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,pbr))
|
||||
# $(eval $(call BuildPackage,pbr-netifd))
|
||||
@@ -0,0 +1,18 @@
|
||||
# Policy-Based Routing (pbr)
|
||||
|
||||
[](https://openwrt.org)
|
||||
[](https://docs.openwrt.melmac.ca/pbr/)
|
||||
[](https://github.com/stangri/pbr/blob/master/LICENSE)
|
||||
|
||||
Flexible policy-based routing (PBR) framework for OpenWrt.
|
||||
Allows routing specific traffic (by IP, MAC, port, protocol, or domain) through a specific WAN, VPN, or tunnel.
|
||||
|
||||
## Features
|
||||
|
||||
- Route by IP, MAC, port, or domain name
|
||||
- Works with WAN, VPNs (WireGuard, OpenVPN), or tunnels
|
||||
- Lightweight shell-based implementation
|
||||
- Optional Web UI integration via LuCI
|
||||
|
||||
**Full documentation:**
|
||||
[https://docs.openwrt.melmac.ca/pbr/](https://docs.openwrt.melmac.ca/pbr/)
|
||||
@@ -7,7 +7,6 @@ config pbr 'config'
|
||||
option nft_set_counter '0'
|
||||
option nft_set_flags_interval '1'
|
||||
option nft_set_flags_timeout '0'
|
||||
option nft_set_gc_interval ''
|
||||
option nft_set_policy 'performance'
|
||||
option nft_user_set_counter '0'
|
||||
option procd_boot_trigger_delay '5000'
|
||||
|
||||
+385
-341
File diff suppressed because it is too large.
Load diff
@@ -11,7 +11,6 @@ fi
|
||||
|
||||
# Transition from older versions of pbr
|
||||
sed -i "s/resolver_ipset/resolver_set/g" /etc/config/pbr
|
||||
sed -i "s/iptables_rule_option/rule_create_option/g" /etc/config/pbr
|
||||
sed -i "s/'FORWARD'/'forward'/g" /etc/config/pbr
|
||||
sed -i "s/'INPUT'/'input'/g" /etc/config/pbr
|
||||
sed -i "s/'OUTPUT'/'output'/g" /etc/config/pbr
|
||||
|
||||
@@ -10,15 +10,15 @@ else
|
||||
fi
|
||||
|
||||
# Transition resolver_set depending on dnsmasq support
|
||||
if [ "$(uci_get pbr config resolver_set)" != 'dnsmasq.nftset' ]; then
|
||||
if [ "$(uci_get "$packageName" 'config' 'resolver_set')" != 'dnsmasq.nftset' ]; then
|
||||
if check_dnsmasq_nftset; then
|
||||
output "Setting resolver_set to 'dnsmasq.nftset'... "
|
||||
uci_set pbr config resolver_set 'dnsmasq.nftset' && output_okn || output_failn
|
||||
uci_set "$packageName" 'config' 'resolver_set' 'dnsmasq.nftset' && output_okn || output_failn
|
||||
else
|
||||
output "Setting resolver_set to 'none'... "
|
||||
uci_set pbr config resolver_set 'none' && output_okn || output_failn
|
||||
uci_set "$packageName" 'config' 'resolver_set' 'none' && output_okn || output_failn
|
||||
fi
|
||||
uci_commit pbr
|
||||
uci_commit "$packageName"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in new issue
Block a user