From a6742b7f82c875572eee696de796fac906dccb57 Mon Sep 17 00:00:00 2001 From: travis laduke Date: Fri, 23 Dec 2022 16:09:53 -0800 Subject: [PATCH] Prevent shadowing VM routes as default route (macOS) If you have a VM host like parallels, sometimes you get these link-local default routes: ``` netstat -nrfinet | grep "default\|\/1" 0/1 10.2.0.12 UGScg feth4823 default 192.168.82.1 UGScg en1 0/1 192.168.82.1 UGScIg en1 default link#22 UCSIg bridge101 ! 128.0/1 10.2.0.12 UGSc feth4823 128.0/1 192.168.82.1 UGScI en1 ``` (the link#22 one) The _getRTEs function inclused these routes in the list it makes as like: device: bridge101, target: 0.0.0.0/0 If it happens to be first in the list, bridge101 gets selected as the default route. Then Full Tunnel Mode doesn't work. The other routes in the list are like: device: en1 target: 192.168.1.0/24 via: metric: 0 ifscope: 0 device: en1 target: 192.168.1.1/32 via: metric: 0 ifscope: 0 We only need the device name from this, so either one will work. --- osdep/ManagedRoute.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osdep/ManagedRoute.cpp b/osdep/ManagedRoute.cpp index 325f4c803..a8f996839 100644 --- a/osdep/ManagedRoute.cpp +++ b/osdep/ManagedRoute.cpp @@ -477,7 +477,7 @@ bool ManagedRoute::sync() if ((newSystemVia)&&(!newSystemDevice[0])) { rtes = _getRTEs(newSystemVia,true); for(std::vector<_RTE>::iterator r(rtes.begin());r!=rtes.end();++r) { - if ( (r->device[0]) && (strcmp(r->device,_device) != 0) ) { + if ( (r->device[0]) && (strcmp(r->device,_device) != 0) && r->target.netmaskBits() != 0) { Utils::scopy(newSystemDevice,sizeof(newSystemDevice),r->device); break; }