Commit
8f24ee638275 ("uqmi: Add proper IPv6 support") changed the code
to fetch the IPv4 address via QMI by default instead of using DHCP to
make it consistent with the IPv6 codepath.
This breaks on at least some Sierra Wireless cards, where data exchanges
fail to work until the host has fetched a DHCP lease.
Leave v6 as it is, but always use DHCP for v4.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
- if [ -z "$dhcp" -o "$dhcp" = 0 ]; then
- echo "Setting up $ifname"
- [ -n "$ipv4" ] && {
- json_load "$(uqmi -s -d $device --set-client-id wds,$cid_4 --get-current-settings)"
- json_select ipv4
- json_get_vars ip subnet gateway dns1 dns2
-
- proto_init_update "$ifname" 1
- proto_set_keep 1
- proto_add_ipv4_address "$ip" "$subnet"
- proto_add_dns_server "$dns1"
- proto_add_dns_server "$dns2"
- proto_add_ipv4_route "0.0.0.0" 0 "$gateway"
- proto_add_data
- json_add_string "cid_4" "$cid_4"
- json_add_string "pdh_4" "$pdh_4"
- proto_close_data
- proto_send_update "$interface"
- }
-
- [ -n "$ipv6" ] && {
+ echo "Setting up $ifname"
+ proto_init_update "$ifname" 1
+ proto_add_data
+ [ -n "$ipv4" ] && {
+ json_add_string "cid_4" "$cid_4"
+ json_add_string "pdh_4" "$pdh_4"
+ }
+ [ -n "$ipv6" ] && {
+ json_add_string "cid_6" "$cid_6"
+ json_add_string "pdh_6" "$pdh_6"
+ }
+
+ [ -n "$ipv6" ] && {
+ if [ -z "$dhcp" -o "$dhcp" = 0 ]; then
json_load "$(uqmi -s -d $device --set-client-id wds,$cid_6 --get-current-settings)"
json_select ipv6
json_get_var ip_6 ip
json_load "$(uqmi -s -d $device --set-client-id wds,$cid_6 --get-current-settings)"
json_select ipv6
json_get_var ip_6 ip
json_get_var dns2_6 dns2
json_get_var ip_prefix_length ip-prefix-length
json_get_var dns2_6 dns2
json_get_var ip_prefix_length ip-prefix-length
- proto_init_update "$ifname" 1
- proto_set_keep 1
# RFC 7278: Extend an IPv6 /64 Prefix to LAN
proto_add_ipv6_address "$ip_6" "128"
proto_add_ipv6_prefix "${ip_6}/${ip_prefix_length}"
# RFC 7278: Extend an IPv6 /64 Prefix to LAN
proto_add_ipv6_address "$ip_6" "128"
proto_add_ipv6_prefix "${ip_6}/${ip_prefix_length}"
proto_add_data
json_add_string "cid_6" "$cid_6"
json_add_string "pdh_6" "$pdh_6"
proto_add_data
json_add_string "cid_6" "$cid_6"
json_add_string "pdh_6" "$pdh_6"
- proto_close_data
- proto_send_update "$interface"
- }
- else
- echo "Starting DHCP on $ifname"
- proto_init_update "$ifname" 1
- proto_add_data
- [ -n "$ipv4" ] && {
- json_add_string "cid_4" "$cid_4"
- json_add_string "pdh_4" "$pdh_4"
- }
- [ -n "$ipv6" ] && {
- json_add_string "cid_6" "$cid_6"
- json_add_string "pdh_6" "$pdh_6"
- }
- proto_close_data
- proto_send_update "$interface"
-
- [ -n "$ipv4" ] && {
- json_init
- json_add_string name "${interface}_4"
- json_add_string ifname "@$interface"
- json_add_string proto "dhcp"
- json_add_int metric "$metric"
- json_close_object
- ubus call network add_dynamic "$(json_dump)"
- }
-
- [ -n "$ipv6" ] && {
json_init
json_add_string name "${interface}_6"
json_add_string ifname "@$interface"
json_init
json_add_string name "${interface}_6"
json_add_string ifname "@$interface"
json_add_string extendprefix 1
json_close_object
ubus call network add_dynamic "$(json_dump)"
json_add_string extendprefix 1
json_close_object
ubus call network add_dynamic "$(json_dump)"
+ fi
+ }
+
+ proto_close_data
+ proto_send_update "$interface"
+
+ [ -n "$ipv4" ] && {
+ json_init
+ json_add_string name "${interface}_4"
+ json_add_string ifname "@$interface"
+ json_add_string proto "dhcp"
+ json_add_int metric "$metric"
+ json_close_object
+ ubus call network add_dynamic "$(json_dump)"
+ }