diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-02-28 18:21:19 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-06-02 10:05:01 +0200 |
| commit | ac016280138bfdfb0d9bc9acb43ea88612d425eb (patch) | |
| tree | f874bca0b92198af53715d20c50d734f23d80778 | |
| parent | fded606538075006e744db27bcf8cc5709988a0b (diff) | |
| download | mullvadvpn-ac016280138bfdfb0d9bc9acb43ea88612d425eb.tar.xz mullvadvpn-ac016280138bfdfb0d9bc9acb43ea88612d425eb.zip | |
Separate routing table creation from rule setup
| -rw-r--r-- | talpid-core/src/split.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/talpid-core/src/split.rs b/talpid-core/src/split.rs index 18b43a15b2..04a57c2034 100644 --- a/talpid-core/src/split.rs +++ b/talpid-core/src/split.rs @@ -47,8 +47,10 @@ pub enum Error { ListCGroupPids(#[error(source)] io::Error), } -fn route_marked_packets() -> Result<(), Error> { +/// Route PID-associated packets through the physical interface. +pub fn route_marked_packets() -> Result<(), Error> { // TODO: IPv6 + // FIXME: we have to check whether this already exists let mut cmd = Command::new("ip"); cmd.args(&[ "-4", @@ -63,6 +65,13 @@ fn route_marked_packets() -> Result<(), Error> { ]); log::trace!("running cmd - {:?}", &cmd); + cmd.output().map_err(Error::RoutingTableSetup)?; + + // Flush table + let mut cmd = Command::new("ip"); + cmd.args(&["-4", "route", "flush", "table", ROUTING_TABLE_NAME]); + + log::trace!("running cmd - {:?}", &cmd); cmd.output().map(|_| ()).map_err(Error::RoutingTableSetup) } @@ -98,7 +107,7 @@ pub fn initialize_routing_table() -> Result<(), Error> { unsafe { ROUTING_TABLE_ID = table_id }; } - return route_marked_packets(); + return Ok(()); } } } @@ -109,9 +118,7 @@ pub fn initialize_routing_table() -> Result<(), Error> { unsafe { ROUTING_TABLE_ID }, ROUTING_TABLE_NAME ) - .map_err(Error::RoutingTableSetup)?; - - route_marked_packets() + .map_err(Error::RoutingTableSetup) } /// Set up cgroup used to track PIDs for split tunneling. |
