Remove redundant test for OpenVPN resync_needed
Check for disabled OpenVPN instances in openvpn_resync_if_needed
It is much cleaner if we check first for disabled OpenVPN instances, before diving into all the other checks. Note, the final openvpn_resync() does call other routines that finally check if the instance is disabled, but there are so many checks here for various conditions to be met before calling openvpn_resync that it looks better (safer) to bail out early if the instance is disabled.
Fix logic inn detecting if OpenVPN resync needed
Commit https://github.com/pfsense/pfsense/commit/f33dcc5c79c54af7daf91a81cfdd7f489e8cb67c reversed the logic sequence when testing if $resync_needed - the individual tests were changed from "==" to "!=" and so on, but the conjunction also need to be changed - "or" needs to be "and". I had noticed that VPNs on some gateway groups of mine didn't failover recently, but hadn't gone looking for the problem until now....
Introduce two new functions to be used on locking.
- try_lock: used for trying to get an EXCLUSIVE lock for a specified timeout by default of 5- unlock_force: which just releases any locks held on a specified lock
Use this new functions on rc.openvpn to avoid spurious stale locks around.
Add safety belts to code in rc.openvpn to avoid php errors to leave stale locks around
Handle comma-separated list arg to rc.openvpn
The argument passed to rc.openvpn can be a comma-separated list of gateways - not just 1 gateway. Enhance the code to loop and process each gateway.
Optimize which OpenVPN instances are restarted
Fix wrong check added on commit 1f64b66bf0 that was checking openvpn server twice and don't checking openvpn client
Handle gateway argument to rc.opnvpn
Various fixups to make this work. Now I can:- Unplug an interface, any OpenVPN servers/clients in a gateway group using that interface are restarted and come up on the highest tier available interface. OpenVPN servers/clients that are only on that interface go down, of course....
Support even openvpn specifying a gateway group on the interface
Correct syntax. Also support passing an interface as argument
Take into consideration the argument passed to the script and reload only related items
Handle case with no server or no client OpenVPN
If there are OpenVPN servers but not clients, this warning is emitted:Warning: Invalid argument supplied for foreach() in /etc/rc.openvpn on line 55This fixes handles that case, and the case of OpenVPN clients but no servers.
We should also resync openvpn clients since they can use gateway groups too.
Make the openvpn resync less intrusive, only trigger this if the OpenVPN interface is actually a gateway group name. Otherwise we skip.
Remove this filter configure call, something else will take care of this and we don't need to do that here.
Fix perms on rc.openvpn, seems to work with that set.
Add openvpn openvpn reload script