1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
diff --git a/src/config.rs b/src/config.rs
index 843bad5..df4117e 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -33,6 +33,7 @@ pub struct Config {
pub device_type: Type,
pub device_name: String,
pub device_path: Option<String>,
+ pub device_mtu: Option<usize>,
pub fix_rp_filter: bool,
pub ip: Option<String>,
@@ -69,6 +70,7 @@ impl Default for Config {
device_type: Type::Tun,
device_name: "vpncloud%d".to_string(),
device_path: None,
+ device_mtu: None,
fix_rp_filter: false,
ip: None,
ifup: None,
@@ -111,6 +113,9 @@ impl Config {
if let Some(val) = device.path {
self.device_path = Some(val);
}
+ if let Some(val) = device.mtu {
+ self.device_mtu = Some(val);
+ }
if let Some(val) = device.fix_rp_filter {
self.fix_rp_filter = val;
}
@@ -210,6 +215,9 @@ impl Config {
if let Some(val) = args.device_path {
self.device_path = Some(val);
}
+ if let Some(val) = args.device_mtu {
+ self.device_mtu = Some(val);
+ }
if args.fix_rp_filter {
self.fix_rp_filter = true;
}
@@ -316,6 +324,10 @@ pub struct Args {
#[structopt(long)]
pub device_path: Option<String>,
+ /// Set the interface mtu
+ #[structopt(long)]
+ pub device_mtu: Option<usize>,
+
/// Fix the rp_filter settings on the host
#[structopt(long)]
pub fix_rp_filter: bool,
@@ -468,7 +480,8 @@ pub struct ConfigFileDevice {
pub type_: Option<Type>,
pub name: Option<String>,
pub path: Option<String>,
- pub fix_rp_filter: Option<bool>
+ pub fix_rp_filter: Option<bool>,
+ pub mtu: Option<usize>
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Default)]
diff --git a/src/main.rs b/src/main.rs
index 868c8d1..0699bba 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -140,7 +140,7 @@ fn setup_device(config: &Config) -> TunTapDevice {
config.device_name
);
info!("Opened device {}", device.ifname());
- if let Err(err) = device.set_mtu(None) {
+ if let Err(err) = device.set_mtu(config.device_mtu) {
error!("Error setting optimal MTU on {}: {}", device.ifname(), err);
}
if let Some(ip) = &config.ip {
diff --git a/src/oldconfig.rs b/src/oldconfig.rs
index 0a717a0..c7b66a2 100644
--- a/src/oldconfig.rs
+++ b/src/oldconfig.rs
@@ -19,6 +19,8 @@ pub struct OldConfigFile {
pub device_name: Option<String>,
#[serde(alias = "device-path")]
pub device_path: Option<String>,
+ #[serde(alias = "device-mtu")]
+ pub device_mtu: Option<usize>,
pub ifup: Option<String>,
pub ifdown: Option<String>,
pub crypto: Option<OldCryptoMethod>,
@@ -98,7 +100,8 @@ impl OldConfigFile {
fix_rp_filter: None,
name: self.device_name,
path: self.device_path,
- type_: self.device_type
+ type_: self.device_type,
+ mtu: self.device_mtu
}),
group: self.group,
ifdown: self.ifdown,
@@ -120,4 +123,4 @@ impl OldConfigFile {
user: self.user
}
}
-}
\ No newline at end of file
+}
|