diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-06-29 10:21:59 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-07-02 12:16:33 +0200 |
| commit | e950135d3976ec13c6c0554fdb74ac99e525f4d7 (patch) | |
| tree | a70d97478d48d25bf190784d3bd0e6539f16c973 | |
| parent | 6c8f497ee071a99c27a6906dcd5ffb40589bbc8e (diff) | |
| download | mullvadvpn-e950135d3976ec13c6c0554fdb74ac99e525f4d7.tar.xz mullvadvpn-e950135d3976ec13c6c0554fdb74ac99e525f4d7.zip | |
Improve errors by not directly leaking mnl errors
| -rw-r--r-- | talpid-core/src/firewall/linux/mod.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/talpid-core/src/firewall/linux/mod.rs b/talpid-core/src/firewall/linux/mod.rs index 8c4c39be08..fdfedb6cb5 100644 --- a/talpid-core/src/firewall/linux/mod.rs +++ b/talpid-core/src/firewall/linux/mod.rs @@ -14,7 +14,6 @@ use tunnel; use std::env; use std::ffi::CString; -use std::io; use std::net::{IpAddr, Ipv4Addr}; use std::path::Path; @@ -25,20 +24,19 @@ use self::dns::DnsSettings; error_chain! { errors { - /// Error when opening a netlink socket to netfilter - NetlinkOpenError { description("Unable to open netlink socket") } - /// Error when writing to netlink socket + /// Unable to open netlink socket to netfilter + NetlinkOpenError { description("Unable to open netlink socket to netfilter") } + /// Unable to send netlink command to netfilter NetlinkSendError { description("Unable to send netlink command to netfilter") } - /// Error when reading from netlink socket + /// Error while reading from netlink socket NetlinkRecvError { description("Error while reading from netlink socket") } + /// Error while processing an incoming netlink message + ProcessNetlinkError { description("Error while processing an incoming netlink message") } } links { DnsSettings(self::dns::Error, self::dns::ErrorKind) #[doc = "DNS error"]; Nftnl(nftnl::Error, nftnl::ErrorKind) #[doc = "Error in nftnl"]; } - foreign_links { - Netlink(io::Error) #[doc = "Error in mnl"]; - } } lazy_static! { @@ -124,7 +122,7 @@ impl Netfilter { while let Some(message) = Self::socket_recv(&socket, &mut buffer[..])? { - match mnl::cb_run(message, 2, portid)? { + match mnl::cb_run(message, 2, portid).chain_err(|| ErrorKind::ProcessNetlinkError)? { mnl::CbResult::Stop => { trace!("cb_run STOP"); break; |
