From: Jonatan Schlag Date: Wed, 7 Jun 2017 06:24:34 +0000 (+0200) Subject: util: add function mtu_is_valid X-Git-Tag: 009~216 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48a64768662a855fdc509127a7edb6c1a9e88def;p=network.git util: add function mtu_is_valid This function checks if an mtu is valid for a given IP protocol. Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.util b/src/functions/functions.util index 4b6f9566..b7e35c91 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -321,6 +321,24 @@ isipaddress() { ip_is_valid ${addr} } +mtu_is_valid() { + local proto=${1} + local mtu=${2} + + case ${proto} in + ipv4) + [ ${mtu} -ge 576 ] && [ ${mtu} -le 9000 ] + ;; + ipv6) + [ ${mtu} -ge 1280 ] && [ ${mtu} -le 9000 ] + ;; + *) + error "${proto} is not a valid proto" + return ${EXIT_ERROR} + ;; + esac +} + backtrace() { local start=1