Skip to content

Commit a0fb2fd

Browse files
committed
pbr: update to 1.2.0-r2
Makefile: * stop shipping/dealing with the firewall hotplug (obsolete) * install a third user-script (dnsprefetch) by @Betonmischer Config: * remove obsolete options * include the new user script Init-script: * start much earlier so that on boot, the procd_add_raw_trigger works on all systems * create a ubus() helper function so that service delete does not produce "Command not found" * rename options to better reflect their function: * procd_lan_device to lan_device * procd_wan_interface to uplink_interface * procd_wan6_interface to uplink_interface6 * procd_wan6_metric to uplink_interface6_metric * wan_ip_rules_priority to uplink_ip_rules_priority * wan_mark to uplink_mark * visually separate run-time variables from variables loaded from config options * use ${IPKG_INSTROOT} when sourcing files in case it will ever run on build host in the future * fix typo in str_to_dnsmasq_nftset() * use pidof to kill dnsmasq in dnsmasq_kill() * add helper function uci_add_list_if_new() * add helper function uci_changes() * add helper function ubus() so that service delete does not produce "Command not found" * implement the dnsmasq features check similar to dnsmasq init script * add get_url() function similar to luci package * add/modify error and warning messages * change how mktemp is used for more reliable file creation * unset non-true boolean package config options on load for easier checks later * improve handling of nft/nft set options * fewer calls to resolver() and resolver() optimization to speed up the service * use softlinks instead of duplicating dnsmasq nftset files into each instance * prevent duplication of dnsmasq nftset elements * option to target a specific dest dns port in DNS policies * bugfix: more reliable interface reloads * display README links to errors/warnings sections if any errors/warnings discovered Uci-defaults: * transition from old options to new ones Signed-off-by: Stan Grishin <[email protected]> (cherry picked from commit 5d8e260) Signed-off-by: Stan Grishin <[email protected]>
1 parent eb39acf commit a0fb2fd

File tree

9 files changed

+978
-653
lines changed

9 files changed

+978
-653
lines changed

net/pbr/Makefile

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
include $(TOPDIR)/rules.mk
55

66
PKG_NAME:=pbr
7-
PKG_VERSION:=1.1.8
8-
PKG_RELEASE:=36
7+
PKG_VERSION:=1.2.1
8+
PKG_RELEASE:=17
99
PKG_LICENSE:=AGPL-3.0-or-later
1010
PKG_MAINTAINER:=Stan Grishin <[email protected]>
1111

@@ -75,34 +75,35 @@ define Package/pbr/default/install
7575
$(INSTALL_CONF) ./files/etc/config/pbr $(1)/etc/config/pbr
7676
$(INSTALL_DIR) $(1)/usr/share/pbr
7777
$(INSTALL_DATA) ./files/usr/share/pbr/.keep $(1)/usr/share/pbr/.keep
78-
$(INSTALL_DATA) ./files/usr/share/pbr/firewall.include $(1)/usr/share/pbr/firewall.include
78+
$(INSTALL_DATA) ./files/usr/share/pbr/pbr.user.dnsprefetch $(1)/usr/share/pbr/pbr.user.dnsprefetch
7979
$(INSTALL_DATA) ./files/usr/share/pbr/pbr.user.aws $(1)/usr/share/pbr/pbr.user.aws
8080
$(INSTALL_DATA) ./files/usr/share/pbr/pbr.user.netflix $(1)/usr/share/pbr/pbr.user.netflix
8181
$(INSTALL_DIR) $(1)/usr/share/nftables.d
8282
$(CP) ./files/usr/share/nftables.d/* $(1)/usr/share/nftables.d/
8383
$(INSTALL_DIR) $(1)/etc/uci-defaults
84-
$(INSTALL_BIN) ./files/etc/uci-defaults/90-pbr $(1)/etc/uci-defaults/90-pbr
84+
$(INSTALL_BIN) ./files/etc/uci-defaults/90-pbr $(1)/etc/uci-defaults/90-pbr
85+
$(INSTALL_BIN) ./files/etc/uci-defaults/91-pbr-nft $(1)/etc/uci-defaults/91-pbr-nft
86+
$(INSTALL_BIN) ./files/etc/uci-defaults/99-pbr-version $(1)/etc/uci-defaults/99-pbr-version
8587
endef
8688

8789
define Package/pbr/install
8890
$(call Package/pbr/default/install,$(1))
89-
$(INSTALL_DIR) $(1)/etc/uci-defaults
90-
$(INSTALL_BIN) ./files/etc/uci-defaults/91-pbr-nft $(1)/etc/uci-defaults/91-pbr-nft
9191
endef
9292

9393
define Package/pbr-netifd/install
9494
$(call Package/pbr/default/install,$(1))
9595
$(INSTALL_DIR) $(1)/etc/uci-defaults
96-
$(INSTALL_BIN) ./files/etc/uci-defaults/91-pbr-netifd $(1)/etc/uci-defaults/91-pbr-netifd
9796
endef
97+
# $(INSTALL_BIN) ./files/etc/uci-defaults/91-pbr-netifd $(1)/etc/uci-defaults/91-pbr-netifd
9898

9999
define Package/pbr/postinst
100100
#!/bin/sh
101101
# check if we are on real system
102102
if [ -z "$${IPKG_INSTROOT}" ]; then
103-
chmod -x /etc/init.d/pbr || true
104-
fw4 -q reload || true
105-
chmod +x /etc/init.d/pbr || true
103+
/etc/init.d/pbr netifd check && {
104+
echo -n "Reinstalling pbr netifd integration... "
105+
/etc/init.d/pbr netifd install >/dev/null 2>&1 && echo "OK" || echo "FAIL"
106+
}
106107
echo -n "Installing rc.d symlink for pbr... "
107108
/etc/init.d/pbr enable && echo "OK" || echo "FAIL"
108109
fi
@@ -113,11 +114,14 @@ define Package/pbr/prerm
113114
#!/bin/sh
114115
# check if we are on real system
115116
if [ -z "$${IPKG_INSTROOT}" ]; then
116-
uci -q delete firewall.pbr || true
117117
echo -n "Stopping pbr service... "
118-
/etc/init.d/pbr stop quiet >/dev/null 2>&1 && echo "OK" || echo "FAIL"
118+
/etc/init.d/pbr stop >/dev/null 2>&1 && echo "OK" || echo "FAIL"
119119
echo -n "Removing rc.d symlink for pbr... "
120120
/etc/init.d/pbr disable && echo "OK" || echo "FAIL"
121+
/etc/init.d/pbr netifd check && {
122+
echo -n "Uninstalling pbr netifd integration... "
123+
/etc/init.d/pbr netifd uninstall >/dev/null 2>&1 && echo "OK" || echo "FAIL"
124+
}
121125
fi
122126
exit 0
123127
endef
@@ -135,10 +139,9 @@ define Package/pbr-netifd/postinst
135139
#!/bin/sh
136140
# check if we are on real system
137141
if [ -z "$${IPKG_INSTROOT}" ]; then
138-
chmod -x /etc/init.d/pbr || true
139-
fw4 -q reload || true
140-
chmod +x /etc/init.d/pbr || true
141-
echo -n "Installing rc.d symlink for pbr-netifd... "
142+
echo -n "Installing pbr integration with netifd... "
143+
/etc/init.d/pbr netifd check && /etc/init.d/pbr netifd install >/dev/null 2>&1 && echo "OK" || echo "FAIL"
144+
echo -n "Installing rc.d symlink for pbr... "
142145
/etc/init.d/pbr enable && echo "OK" || echo "FAIL"
143146
fi
144147
exit 0
@@ -148,32 +151,12 @@ define Package/pbr-netifd/prerm
148151
#!/bin/sh
149152
# check if we are on real system
150153
if [ -z "$${IPKG_INSTROOT}" ]; then
151-
uci -q delete firewall.pbr || true
152-
echo -n "Stopping pbr-netifd service... "
153-
/etc/init.d/pbr stop quiet >/dev/null 2>&1 && echo "OK" || echo "FAIL"
154+
echo -n "Stopping pbr service... "
155+
/etc/init.d/pbr stop >/dev/null 2>&1 && echo "OK" || echo "FAIL"
154156
echo -n "Removing rc.d symlink for pbr... "
155157
/etc/init.d/pbr disable && echo "OK" || echo "FAIL"
156-
echo -n "Cleaning up /etc/iproute2/rt_tables... "
157-
if sed -i '/pbr_/d' /etc/iproute2/rt_tables; then
158-
echo "OK"
159-
else
160-
echo "FAIL"
161-
fi
162-
echo -n "Cleaning up /etc/config/network... "
163-
uci -q delete 'network.pbr_default' || true
164-
uci -q delete 'network.pbr_default6' || true
165-
uci commit network || true
166-
if sed -i '/ip.table.*pbr_/d' /etc/config/network; then
167-
echo "OK"
168-
else
169-
echo "FAIL"
170-
fi
171-
echo -n "Restarting Network... "
172-
if /etc/init.d/network restart >/dev/null 2>&1; then
173-
echo "OK"
174-
else
175-
echo "FAIL"
176-
fi
158+
echo -n "Uninstalling pbr integration with netifd... "
159+
/etc/init.d/pbr netifd check && /etc/init.d/pbr netifd uninstall >/dev/null 2>&1 && echo "OK" || echo "FAIL"
177160
fi
178161
exit 0
179162
endef

net/pbr/files/etc/config/pbr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
config pbr 'config'
2-
option debug_dnsmasq '0'
32
option enabled '0'
43
option verbosity '2'
54
option strict_enforcement '1'
65
option resolver_set 'dnsmasq.nftset'
76
list resolver_instance '*'
87
option ipv6_enabled '0'
98
list ignored_interface 'vpnserver'
10-
option boot_timeout '30'
119
option rule_create_option 'add'
1210
option procd_boot_trigger_delay '5000'
1311
option procd_reload_delay '1'
@@ -26,6 +24,10 @@ config pbr 'config'
2624
list webui_supported_protocol 'tcp udp'
2725
list webui_supported_protocol 'icmp'
2826

27+
config include
28+
option path '/usr/share/pbr/pbr.user.dnsprefetch'
29+
option enabled '0'
30+
2931
config include
3032
option path '/usr/share/pbr/pbr.user.aws'
3133
option enabled '0'

0 commit comments

Comments
 (0)