aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLech Perczak <lech.perczak@gmail.com>2021-11-06 16:01:02 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2023-04-29 21:33:05 +0200
commite4db21b413e65bdfe0491a0ff5749d0bdfde04d4 (patch)
treedc6f047dbf926714f9aab73b27525848cd2db6f6
parent2bfbc2dbd8b0d9570a8df0d8d8db93c2a9fcec01 (diff)
downloadupstream-e4db21b413e65bdfe0491a0ff5749d0bdfde04d4.tar.gz
upstream-e4db21b413e65bdfe0491a0ff5749d0bdfde04d4.tar.bz2
upstream-e4db21b413e65bdfe0491a0ff5749d0bdfde04d4.zip
umbim: handle MTU configuration
Allow setting interface MTU through UCI. If this is not set, use MBIM-provided MTU, if provided through control channel. If separate MTUs are provided for IPv4 and IPv6, apply larger of them. This is very unlikely and possible only for IPv4v6 dual-stack configuration. Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
-rwxr-xr-xpackage/network/utils/umbim/files/lib/netifd/proto/mbim.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh
index eab5cf3de6..7ac3cb1c70 100755
--- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh
+++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh
@@ -23,6 +23,7 @@ proto_mbim_init_config() {
proto_config_add_boolean dhcp
proto_config_add_boolean dhcpv6
proto_config_add_string pdptype
+ proto_config_add_int mtu
proto_config_add_defaults
}
@@ -44,9 +45,9 @@ _proto_mbim_setup() {
local ret
local device apn pincode delay auth username password allow_roaming allow_partner
- local dhcp dhcpv6 pdptype ip4table ip6table $PROTO_DEFAULT_OPTIONS
+ local dhcp dhcpv6 pdptype ip4table ip6table mtu $PROTO_DEFAULT_OPTIONS
json_get_vars device apn pincode delay auth username password allow_roaming allow_partner
- json_get_vars dhcp dhcpv6 pdptype ip4table ip6table $PROTO_DEFAULT_OPTIONS
+ json_get_vars dhcp dhcpv6 pdptype ip4table ip6table mtu $PROTO_DEFAULT_OPTIONS
[ ! -e /proc/sys/net/ipv6 ] && ipv6=0 || json_get_var ipv6 ipv6
@@ -294,6 +295,19 @@ _proto_mbim_setup() {
fi
}
+ [ -z "$mtu" ] && {
+ local ipv4mtu=$(_proto_mbim_get_field ipv4mtu "$mbimconfig")
+ ipv4mtu="${ipv4mtu:-0}"
+ local ipv6mtu=$(_proto_mbim_get_field ipv6mtu "$mbimconfig")
+ ipv6mtu="${ipv6mtu:-0}"
+
+ mtu=$((ipv6mtu > ipv4mtu ? ipv6mtu : ipv4mtu))
+ }
+ [ -n "$mtu" -a "$mtu" != 0 ] && {
+ echo Setting MTU of $ifname to $mtu
+ /sbin/ip link set dev $ifname mtu $mtu
+ }
+
uci_set_state network $interface tid "$tid"
}