From: Lech Perczak Date: Wed, 3 May 2023 12:34:25 +0000 (+0200) Subject: umbim: allow forcing DHCP/DHCPv6 configuration X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1108f6cb8b115608c486552f1210fea5b955ea5f;p=openwrt%2Fstaging%2Frobimarko.git umbim: allow forcing DHCP/DHCPv6 configuration To support the widest variety of modems, allow restoring previous behaviour of configuring the link throug means of DHCP(v6) exclusively. Change the default value of "dhcp" and "dhcpv6" UCI options to "auto", while keeping the default behaviour of "prefer out-of-band configuration", intact. Setting "dhcp" or "dhcpv6" to boolean 1 will now force using DHCP and DHCPv6, respectively. Signed-off-by: Lech Perczak --- 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 bf07137fc4..50913e7fa0 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -20,8 +20,8 @@ proto_mbim_init_config() { proto_config_add_string username proto_config_add_string password [ -e /proc/sys/net/ipv6 ] && proto_config_add_string ipv6 - proto_config_add_boolean dhcp - proto_config_add_boolean dhcpv6 + proto_config_add_string dhcp + proto_config_add_string dhcpv6 proto_config_add_string pdptype proto_config_add_int mtu proto_config_add_defaults @@ -199,15 +199,15 @@ _proto_mbim_setup() { proto_init_update "$ifname" 1 proto_send_update "$interface" - [ -z "$dhcp" ] && dhcp=1 - [ -z "$dhcpv6" ] && dhcpv6=1 + [ -z "$dhcp" ] && dhcp="auto" + [ -z "$dhcpv6" ] && dhcpv6="auto" [ "$iptype" != "ipv6" ] && { json_init json_add_string name "${interface}_4" json_add_string ifname "@$interface" ipv4address=$(_proto_mbim_get_field ipv4address "$mbimconfig") - if [ -n "$ipv4address" ]; then + if [ -n "$ipv4address" -a "$dhcp" != 1 ]; then json_add_string proto "static" json_add_array ipaddr @@ -222,7 +222,7 @@ _proto_mbim_setup() { json_add_string proto "dhcp" fi - [ "$peerdns" = 0 ] || { + [ "$peerdns" = 0 -a "$dhcp" != 1 ] || { json_add_array dns for server in $(_proto_mbim_get_field ipv4dnsserver "$mbimconfig"); do json_add_string "" "$server" @@ -242,7 +242,7 @@ _proto_mbim_setup() { json_add_string name "${interface}_6" json_add_string ifname "@$interface" ipv6address=$(_proto_mbim_get_field ipv6address "$mbimconfig") - if [ -n "$ipv6address" ]; then + if [ -n "$ipv6address" -a "$dhcpv6" != 1 ]; then json_add_string proto "static" json_add_array ip6addr @@ -265,7 +265,7 @@ _proto_mbim_setup() { json_add_string extendprefix 1 fi - [ "$peerdns" = 0 ] || { + [ "$peerdns" = 0 -a "$dhcpv6" != 1 ] || { json_add_array dns for server in $(_proto_mbim_get_field ipv6dnsserver "$mbimconfig"); do json_add_string "" "$server"