It's not possible to disable a static route that is set to use a gateway that is disabled using the edit dialogue.
If you attempt to edit a static route to disable it and the gateway set is already disabled you will receive the following:
The following input errors were detected:
The gateway '192.168.114.22' is a different Address Family as network '192.168.119.0'.
It can be disabled using the enable/disable button on the System > Routing, Routes tab.
Related to this. If you are disabling a route and gateway and first disable and save route then disable and save the gateway then apply the changes, the route is not removed from the system routing table.
Fix #4813 validation of enable/disable of gateways and static routes
1) A disabled gateway can always be enabled - no extra validation
2) When disabling an enabled gateway, check to see that the gateway is
not used in any gateway group or enabled static route (similar tests to
what is already checked before deleting a gateway).
3) A static route can always be disabled - no extra checks needed.
4) When enabling a static route, check that the selected gateway is
enabled - you cannot have a static route enabled on a disabled gateway.
5) Do the address family cross-check between static route and gateway
even when the static route is disabled - we do not want to save
mismatched IP address families in any case.
This covers all the cases I can see to ensure that the enable/disable
status combinations of Gateways and Static Routes is always valid.
#1 Updated by Phillip Davis about 5 years ago
I just made a pull request for the first tiny error I noticed:
I am happy to look at this stuff. I have some code to check and;
a) not allow you to enable a route that uses a disabled gateway - either by the enable/disable buttons on the front Routes page, or by clearing the disabled checkbox when editing the route.
b) check the address family thing better, so if the route is disabled it will allow it to match with a gateway that is disabled (which is the problem with the silly message) - thus checking the address family matches even if the route and gateway are disabled.
The other problem is that the user can disable a gateway that has enabled routes. That code should also check and only allow the user to disable a gateway if all routes using it are already disabled. I will fix that up also.
After all that there should only be valid changes able to made made from the GUI. Hopefully those changes will all be implemented correctly - but I will check that because the "Related to this" paragraph looks like it will still be a problem.
Isn't input validation fun :)
#2 Updated by Phillip Davis about 5 years ago
Validation of enable/disable of gateways and static routes
Pull request: https://github.com/pfsense/pfsense/pull/1738
That stops any invalid combinations of enabled/disabled gateways and static routes from being saved, and allows the valid ones.
In the next day or 2 I will try what happens if you make various changes to static routes and gateways without pressing apply after every step. And will fix whatever inconsistency I can see there.