From: Ian Jackson Date: Mon, 26 Jul 2021 18:35:59 +0000 (+0100) Subject: config: check batch vs mtu sizes X-Git-Tag: hippotat/1.0.0~437 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=0e082f759fe1399c918d8bf0a3d89ec2ccbed2a0;p=hippotat.git config: check batch vs mtu sizes Signed-off-by: Ian Jackson --- diff --git a/src/config.rs b/src/config.rs index 5243e8b..cc754a5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -663,6 +663,18 @@ impl InstanceConfig { )?; } + let check_batch = { + let mtu = self.mtu; + move |max_batch, key| { + if max_batch/2 < mtu { + throw!(anyhow!("max batch {:?} ({}) must be >= 2 x mtu ({}) \ + (to allow for SLIP ESC-encoding)", + key, max_batch, mtu)) + } + Ok::<_,AE>(()) + } + }; + match end { LinkEnd::Client => { if &self.url == &default::() { @@ -681,12 +693,15 @@ impl InstanceConfig { }) .parse().unwrap() } + + check_batch(self.max_batch_up, "max_batch_up")?; }, LinkEnd::Server => { if self.addrs.is_empty() { throw!(anyhow!("missing 'addrs' setting")) } + check_batch(self.max_batch_down, "max_batch_down")?; }, }