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 <lech.perczak@gmail.com>
This commit is contained in:
Lech Perczak 2023-05-03 14:34:25 +02:00 committed by Hauke Mehrtens
parent 12b96757e5
commit 1108f6cb8b
1 changed files with 8 additions and 8 deletions

View File

@ -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"