[OpenWrt-Devel] [PATCH 2/2] Add support for 'metric' to QMI, NCM, MBIM and DirectIP

Bruno Randolf br1 at einfach.org
Wed Feb 17 13:21:27 EST 2016


Same as for other network interfaces, the option 'metric' should be respected.

(Unfortunately I could not test these changes, since I don't have these modems
and QMI is broken on trunk for me... But the same method is used in the
"HiLink" script I just added before.)

Signed-off-by: Bruno Randolf <br1 at einfach.org>
---
 package/network/utils/comgt/files/directip.sh              |  7 +++++--
 package/network/utils/comgt/files/ncm.sh                   |  7 +++++--
 package/network/utils/umbim/files/lib/netifd/proto/mbim.sh |  7 +++++--
 package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh   | 11 +++++++----
 4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/package/network/utils/comgt/files/directip.sh b/package/network/utils/comgt/files/directip.sh
index d828052..048b647 100644
--- a/package/network/utils/comgt/files/directip.sh
+++ b/package/network/utils/comgt/files/directip.sh
@@ -15,14 +15,15 @@ proto_directip_init_config() {
 	proto_config_add_string "auth"
 	proto_config_add_string "username"
 	proto_config_add_string "password"
+	proto_config_add_string "metric"
 }
 
 proto_directip_setup() {
 	local interface="$1"
 	local chat devpath devname
 
-	local device apn pincode ifname auth username password
-	json_get_vars device apn pincode auth username password
+	local device apn pincode ifname auth username password metric
+	json_get_vars device apn pincode auth username password metric
 
 	[ -n "$ctl_device" ] && device=$ctl_device
 
@@ -80,6 +81,7 @@ proto_directip_setup() {
 	json_add_string name "${interface}_4"
 	json_add_string ifname "@$interface"
 	json_add_string proto "dhcp"
+	json_add_int metric $metric
 	ubus call network add_dynamic "$(json_dump)"
 
 	json_init
@@ -87,6 +89,7 @@ proto_directip_setup() {
 	json_add_string ifname "@$interface"
 	json_add_string proto "dhcpv6"
 	json_add_string extendprefix 1
+	json_add_int metric $metric
 	ubus call network add_dynamic "$(json_dump)"
 
 	return 0
diff --git a/package/network/utils/comgt/files/ncm.sh b/package/network/utils/comgt/files/ncm.sh
index 571cfaa..39bdaaf 100644
--- a/package/network/utils/comgt/files/ncm.sh
+++ b/package/network/utils/comgt/files/ncm.sh
@@ -19,6 +19,7 @@ proto_ncm_init_config() {
 	proto_config_add_string mode
 	proto_config_add_string pdptype
 	proto_config_add_boolean ipv6
+	proto_config_add_string metric
 }
 
 proto_ncm_setup() {
@@ -26,8 +27,8 @@ proto_ncm_setup() {
 
 	local manufacturer initialize setmode connect ifname devname devpath
 
-	local device apn auth username password pincode delay mode pdptype ipv6
-	json_get_vars device apn auth username password pincode delay mode pdptype ipv6
+	local device apn auth username password pincode delay mode pdptype ipv6 metric
+	json_get_vars device apn auth username password pincode delay mode pdptype ipv6 metric
 	
 	if [ "$ipv6" = 0 ]; then
 		ipv6=""
@@ -141,6 +142,7 @@ proto_ncm_setup() {
 	json_add_string name "${interface}_4"
 	json_add_string ifname "@$interface"
 	json_add_string proto "dhcp"
+	json_add_int metric $metric
 	ubus call network add_dynamic "$(json_dump)"
 
 	[ -n "$ipv6" ] && {
@@ -149,6 +151,7 @@ proto_ncm_setup() {
 		json_add_string ifname "@$interface"
 		json_add_string proto "dhcpv6"
 		json_add_string extendprefix 1
+		json_add_int metric $metric
 		ubus call network add_dynamic "$(json_dump)"
 	}
 }
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 f8b2c06..ab62ed6 100755
--- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh
+++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh
@@ -17,6 +17,7 @@ proto_mbim_init_config() {
 	proto_config_add_string auth
 	proto_config_add_string username
 	proto_config_add_string password
+	proto_config_add_string metric
 }
 
 _proto_mbim_setup() {
@@ -24,8 +25,8 @@ _proto_mbim_setup() {
 	local tid=2
 	local ret
 
-	local device apn pincode delay
-	json_get_vars device apn pincode delay auth username password
+	local device apn pincode delay metric
+	json_get_vars device apn pincode delay auth username password metric
 
 	[ -n "$ctl_device" ] && device=$ctl_device
 
@@ -130,6 +131,7 @@ _proto_mbim_setup() {
 	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)"
 
@@ -138,6 +140,7 @@ _proto_mbim_setup() {
 	json_add_string ifname "@$interface"
 	json_add_string proto "dhcpv6"
 	json_add_string extendprefix 1
+	json_add_int metric $metric
 	ubus call network add_dynamic "$(json_dump)"
 }
 
diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index 48864be..b129a7c 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -19,15 +19,16 @@ proto_qmi_init_config() {
 	proto_config_add_string modes
 	proto_config_add_boolean ipv6
 	proto_config_add_boolean dhcp
+	proto_config_add_string metric
 }
 
 proto_qmi_setup() {
 	local interface="$1"
 
-	local device apn auth username password pincode delay modes ipv6 dhcp
+	local device apn auth username password pincode delay modes ipv6 dhcp metric
 	local cid_4 pdh_4 cid_6 pdh_6 ipv4
 	local ip subnet gateway dns1 dns2 ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
-	json_get_vars device apn auth username password pincode delay modes ipv6 dhcp
+	json_get_vars device apn auth username password pincode delay modes ipv6 dhcp metric
 
 	ipv4=1
 
@@ -152,7 +153,7 @@ proto_qmi_setup() {
 			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_ipv4_route "0.0.0.0" 0 "$gateway" "" "$metric"
 			proto_add_data
 			json_add_string "cid_4" "$cid_4"
 			json_add_string "pdh_4" "$pdh_4"
@@ -175,7 +176,7 @@ proto_qmi_setup() {
 			proto_add_ipv6_address "$ip_6" "128"
 			proto_add_ipv6_prefix "${ip_6}/${ip_prefix_length}"
 			proto_add_ipv6_route "$gateway_6" "128"
-			proto_add_ipv6_route "::0" 0 "$gateway_6" "" "" "${ip_6}/${ip_prefix_length}"
+			proto_add_ipv6_route "::0" 0 "$gateway_6" "$metric" "" "${ip_6}/${ip_prefix_length}"
 			proto_add_dns_server "$dns1_6"
 			proto_add_dns_server "$dns2_6"
 			proto_add_data
@@ -204,6 +205,7 @@ proto_qmi_setup() {
 			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)"
 		}
@@ -215,6 +217,7 @@ proto_qmi_setup() {
 			json_add_string proto "dhcpv6"
 			# RFC 7278: Extend an IPv6 /64 Prefix to LAN
 			json_add_string extendprefix 1
+			json_add_int metric $metric
 			json_close_object
 			ubus call network add_dynamic "$(json_dump)"
 		}
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list