Policy-Based-Routing (pbr) package discussion

I tried pbr with my openvpn setup and have a couple suggestions

pbr 1.1.0-7 running on OpenWrt 22.03.3. 

 diff /etc/init.d/pbr  /tmp/pbr.ORIG
229c229
< is_ovpn() { local dev; dev="$(uci -q get "network.${1}.device")"; [ "${dev:0:3}" = "tun" ] || [ "${dev:0:3}" = "tap" ] || [ -f "/sys/devices/virtual/net/${dev}/tun_flags" ]; }
---
> is_ovpn() { local dev; dev="$(uci -q get "network.${1}.dev")"; [ "${dev:0:3}" = "tun" ] || [ "${dev:0:3}" = "tap" ] || [ -f "/sys/devices/virtual/net/${dev}/tun_flags" ]; }
1883c1883
<       network_get_physdev dev "$iface"
---
>       network_get_device dev "$iface"

the first change allows 22.03 to find the openvpn tun interfaces

the second seems to help find the dev for the tunnel more reliably. If I stopped the openvpn using init.d and restart them "network_get_device" didn't return the dev most of the time but network_get_physdev did. This discussion has more details Lib functions network

1 Like