Browse Source

Try a version of GitHub issue #385 (non-bifurcated default if not present) on Mac. This version adds the bifurcated routes always but also adds a device-specific non-bifurcated route. Will have to see if this still interferes with OSX route settings, since by definition device specific routes should not conflict with general routes.

Adam Ierymenko 9 years ago
parent
commit
ced8dfc639
1 changed files with 27 additions and 29 deletions
  1. 27 29
      osdep/ManagedRoute.cpp

+ 27 - 29
osdep/ManagedRoute.cpp

@@ -435,36 +435,34 @@ bool ManagedRoute::sync()
 		}
 	}
 
-	// if (_systemVia) {
-		if (!_applied.count(leftt)) {
-			_applied.insert(leftt);
-			_routeCmd("add",leftt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
-			_routeCmd("change",leftt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
-		}
-		if ((rightt)&&(!_applied.count(rightt))) {
-			_applied.insert(rightt);
-			_routeCmd("add",rightt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
-			_routeCmd("change",rightt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
-		}
-		/*if (_applied.count(_target)) {
-			_applied.erase(_target);
-			_routeCmd("delete",_target,_via,(const char *)0,(_via) ? (const char *)0 : _device);
-		}*/
-	/*} else {
-		if (_applied.count(leftt)) {
-			_applied.erase(leftt);
-			_routeCmd("delete",leftt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
-		}
-		if ((rightt)&&(_applied.count(rightt))) {
-			_applied.erase(rightt);
-			_routeCmd("delete",rightt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
-		}
-		if (!_applied.count(_target)) {
-			_applied.insert(_target);
-			_routeCmd("add",_target,_via,(const char *)0,(_via) ? (const char *)0 : _device);
-			_routeCmd("change",_target,_via,(const char *)0,(_via) ? (const char *)0 : _device);
+	if (!_applied.count(leftt)) {
+		_applied.insert(leftt);
+		_routeCmd("add",leftt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
+		_routeCmd("change",leftt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
+	}
+	if ((rightt)&&(!_applied.count(rightt))) {
+		_applied.insert(rightt);
+		_routeCmd("add",rightt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
+		_routeCmd("change",rightt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
+	}
+
+	// Create a device-bound default target if there is none in the system. This
+	// is to allow e.g. IPv6 default route to work even if there is no native
+	// IPv6 on your LAN.
+	if (_target.isDefaultRoute()) {
+		if (_systemVia) {
+			if (_applied.count(_target)) {
+				_applied.erase(_target);
+				_routeCmd("delete",_target,_via,_device,(_via) ? (const char *)0 : _device);
+			}
+		} else {
+			if (!_applied.count(_target)) {
+				_applied.insert(_target);
+				_routeCmd("add",_target,_via,_device,(_via) ? (const char *)0 : _device);
+				_routeCmd("change",_target,_via,_device,(_via) ? (const char *)0 : _device);
+			}
 		}
-	}*/
+	}
 
 #endif // __BSD__ ------------------------------------------------------------