Skip to content

Commit d8191ec

Browse files
committed
fix(local-tun): Linux already has IFF_NO_PI, macOS already set route
1 parent 0e78262 commit d8191ec

File tree

1 file changed

+11
-8
lines changed
  • crates/shadowsocks-service/src/local/tun

1 file changed

+11
-8
lines changed

crates/shadowsocks-service/src/local/tun/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ impl TunBuilder {
108108
pub async fn build(mut self) -> io::Result<Tun> {
109109
self.tun_config.layer(Layer::L3).up();
110110

111-
#[cfg(target_os = "linux")]
112-
self.tun_config.platform_config(|tun_config| {
113-
// IFF_NO_PI preventing excessive buffer reallocating
114-
tun_config.packet_information(false);
115-
});
111+
// XXX: tun2 set IFF_NO_PI by default.
112+
//
113+
// #[cfg(target_os = "linux")]
114+
// self.tun_config.platform_config(|tun_config| {
115+
// // IFF_NO_PI preventing excessive buffer reallocating
116+
// tun_config.packet_information(false);
117+
// });
116118

117119
let device = match create_as_async(&self.tun_config) {
118120
Ok(d) => d,
@@ -203,9 +205,10 @@ impl Tun {
203205
);
204206

205207
// Set default route
206-
if let Err(err) = sys::set_route_configuration(self.device.as_mut()).await {
207-
warn!("[TUN] tun device set route failed, error: {}", err);
208-
}
208+
// XXX: tun2 already set it by default.
209+
// if let Err(err) = sys::set_route_configuration(self.device.as_mut()).await {
210+
// warn!("[TUN] tun device set route failed, error: {}", err);
211+
// }
209212

210213
let address_broadcast = address_net.broadcast();
211214

0 commit comments

Comments
 (0)