diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-09-12 20:55:51 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-09-23 12:45:22 +0200 |
| commit | 97418e0ab023d5ada1a5a432785ea7c2149ceee8 (patch) | |
| tree | ddbc83f824d851efb1720a27b6508d39616d0148 | |
| parent | 25310a15eff6109379c13c0ee903af4be4bf3108 (diff) | |
| download | mullvadvpn-97418e0ab023d5ada1a5a432785ea7c2149ceee8.tar.xz mullvadvpn-97418e0ab023d5ada1a5a432785ea7c2149ceee8.zip | |
Account for route priority in the route manager
| -rw-r--r-- | talpid-core/src/routing/linux.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/talpid-core/src/routing/linux.rs b/talpid-core/src/routing/linux.rs index e415f6b31b..e27b0ad849 100644 --- a/talpid-core/src/routing/linux.rs +++ b/talpid-core/src/routing/linux.rs @@ -181,7 +181,7 @@ impl RouteManagerImpl { async fn initialize_exclusions_routes(&mut self) -> Result<()> { let main_routes = self.get_routes().await?; for mut route in main_routes { - route.table_id = self.split_table_id as u8; + route.table_id = self.split_table_id; self.add_route_direct(route).await?; } Ok(()) @@ -400,7 +400,7 @@ impl RouteManagerImpl { || route.node.device != self.split_ignored_interface { let mut exclusions_route = route.clone(); - exclusions_route.table_id = self.split_table_id as u8; + exclusions_route.table_id = self.split_table_id; self.add_route_direct(exclusions_route).await?; } @@ -416,7 +416,7 @@ impl RouteManagerImpl { || route.node.device != self.split_ignored_interface { let mut exclusions_route = route.clone(); - exclusions_route.table_id = self.split_table_id as u8; + exclusions_route.table_id = self.split_table_id; if let Err(error) = self.delete_route(&exclusions_route).await { log::warn!( "{}", @@ -806,7 +806,7 @@ impl RouteManagerImpl { } async fn add_route_direct(&mut self, route: Route) -> Result<()> { - let add_message = match &route.prefix { + let mut add_message = match &route.prefix { IpNetwork::V4(v4_prefix) => { let mut add_message = self .handle @@ -862,6 +862,12 @@ impl RouteManagerImpl { add_message.nlas.push(RouteNla::Table(route.table_id)); } + // TODO: Request support for route priority in RouteAddIpv{4,6}Request + if let Some(metric) = route.metric { + use netlink_packet_route::nlas::route; + add_message.nlas.push(route::Nla::Priority(metric)); + } + // Need to modify the request in place to set the correct flags to be able to replace any // existing routes - self.handle.route().add_v4().execute() sets the NLM_F_EXCL flag which // will make the request fail if a route with the same destination already exists. |
