[OpenWrt-Devel] [PATCH 2/2] QMI/NCM/MBIM/DirectIP: Support defaultroute, peerdns, metric
Bruno Randolf
br1 at einfach.org
Thu Feb 18 12:12:26 EST 2016
Add support for options 'defaultroute', 'peerdns' and 'metric' to QMI, NCM,
MBIM and DirectIP dynamic dhcp interfaces. Same as for other network
interfaces, these options should be respected.
This includes the changes from http://patchwork.ozlabs.org/patch/581065/
Signed-off-by: Jakub Janco <kubco2 at gmail.com>
Signed-off-by: Bruno Randolf <br1 at einfach.org>
---
package/network/utils/comgt/Makefile | 2 +-
package/network/utils/comgt/files/directip.sh | 13 ++++++++--
package/network/utils/comgt/files/ncm.sh | 13 ++++++++--
.../utils/umbim/files/lib/netifd/proto/mbim.sh | 13 ++++++++--
.../utils/uqmi/files/lib/netifd/proto/qmi.sh | 29 ++++++++++++++++------
5 files changed, 55 insertions(+), 15 deletions(-)
diff --git a/package/network/utils/comgt/Makefile b/package/network/utils/comgt/Makefile
index ac19aad..29bd62c 100644
--- a/package/network/utils/comgt/Makefile
+++ b/package/network/utils/comgt/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=comgt
PKG_VERSION:=0.32
-PKG_RELEASE:=27
+PKG_RELEASE:=28
PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
PKG_SOURCE_URL:=@SF/comgt
diff --git a/package/network/utils/comgt/files/directip.sh b/package/network/utils/comgt/files/directip.sh
index d828052..c94585c 100644
--- a/package/network/utils/comgt/files/directip.sh
+++ b/package/network/utils/comgt/files/directip.sh
@@ -15,14 +15,17 @@ proto_directip_init_config() {
proto_config_add_string "auth"
proto_config_add_string "username"
proto_config_add_string "password"
+ proto_config_add_boolean "defaultroute"
+ proto_config_add_boolean "peerdns"
+ proto_config_add_int "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 defaultroute peerdns metric
+ json_get_vars device apn pincode auth username password defaultroute peerdns metric
[ -n "$ctl_device" ] && device=$ctl_device
@@ -80,6 +83,9 @@ proto_directip_setup() {
json_add_string name "${interface}_4"
json_add_string ifname "@$interface"
json_add_string proto "dhcp"
+ [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
+ [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
+ [ -n "$metric" ] && json_add_int metric "$metric"
ubus call network add_dynamic "$(json_dump)"
json_init
@@ -87,6 +93,9 @@ proto_directip_setup() {
json_add_string ifname "@$interface"
json_add_string proto "dhcpv6"
json_add_string extendprefix 1
+ [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
+ [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
+ [ -n "$metric" ] && 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..5c5be0c 100644
--- a/package/network/utils/comgt/files/ncm.sh
+++ b/package/network/utils/comgt/files/ncm.sh
@@ -19,6 +19,9 @@ proto_ncm_init_config() {
proto_config_add_string mode
proto_config_add_string pdptype
proto_config_add_boolean ipv6
+ proto_config_add_boolean defaultroute
+ proto_config_add_boolean peerdns
+ proto_config_add_int metric
}
proto_ncm_setup() {
@@ -26,8 +29,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 defaultroute peerdns metric
+ json_get_vars device apn auth username password pincode delay mode pdptype ipv6 defaultroute peerdns metric
if [ "$ipv6" = 0 ]; then
ipv6=""
@@ -141,6 +144,9 @@ proto_ncm_setup() {
json_add_string name "${interface}_4"
json_add_string ifname "@$interface"
json_add_string proto "dhcp"
+ [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
+ [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
+ [ -n "$metric" ] && json_add_int metric "$metric"
ubus call network add_dynamic "$(json_dump)"
[ -n "$ipv6" ] && {
@@ -149,6 +155,9 @@ proto_ncm_setup() {
json_add_string ifname "@$interface"
json_add_string proto "dhcpv6"
json_add_string extendprefix 1
+ [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
+ [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
+ [ -n "$metric" ] && 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..907ce47 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,9 @@ proto_mbim_init_config() {
proto_config_add_string auth
proto_config_add_string username
proto_config_add_string password
+ proto_config_add_boolean defaultroute
+ proto_config_add_boolean peerdns
+ proto_config_add_int metric
}
_proto_mbim_setup() {
@@ -24,8 +27,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 defaultroute peerdns metric
+ json_get_vars device apn pincode delay auth username password defaultroute peerdns metric
[ -n "$ctl_device" ] && device=$ctl_device
@@ -130,6 +133,9 @@ _proto_mbim_setup() {
json_add_string name "${interface}_4"
json_add_string ifname "@$interface"
json_add_string proto "dhcp"
+ [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
+ [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
+ [ -n "$metric" ] && json_add_int metric "$metric"
json_close_object
ubus call network add_dynamic "$(json_dump)"
@@ -138,6 +144,9 @@ _proto_mbim_setup() {
json_add_string ifname "@$interface"
json_add_string proto "dhcpv6"
json_add_string extendprefix 1
+ [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
+ [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
+ [ -n "$metric" ] && 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..3d1e5f9 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,18 @@ proto_qmi_init_config() {
proto_config_add_string modes
proto_config_add_boolean ipv6
proto_config_add_boolean dhcp
+ proto_config_add_boolean defaultroute
+ proto_config_add_boolean peerdns
+ proto_config_add_int 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 defaultroute peerdns 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 defaultroute peerdns metric
ipv4=1
@@ -150,9 +153,11 @@ proto_qmi_setup() {
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"
+ [ "$peerdns" = 0 ] || {
+ proto_add_dns_server "$dns1"
+ proto_add_dns_server "$dns2"
+ }
+ [ "$defaultroute" = 0 ] || 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,9 +180,11 @@ 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_dns_server "$dns1_6"
- proto_add_dns_server "$dns2_6"
+ [ "$defaultroute" = 0 ] || proto_add_ipv6_route "::0" 0 "$gateway_6" "$metric" "" "${ip_6}/${ip_prefix_length}"
+ [ "$peerdns" = 0 ] || {
+ proto_add_dns_server "$dns1_6"
+ proto_add_dns_server "$dns2_6"
+ }
proto_add_data
json_add_string "cid_6" "$cid_6"
json_add_string "pdh_6" "$pdh_6"
@@ -204,6 +211,9 @@ proto_qmi_setup() {
json_add_string name "${interface}_4"
json_add_string ifname "@$interface"
json_add_string proto "dhcp"
+ [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
+ [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
+ [ -n "$metric" ] && json_add_int metric "$metric"
json_close_object
ubus call network add_dynamic "$(json_dump)"
}
@@ -215,6 +225,9 @@ proto_qmi_setup() {
json_add_string proto "dhcpv6"
# RFC 7278: Extend an IPv6 /64 Prefix to LAN
json_add_string extendprefix 1
+ [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
+ [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
+ [ -n "$metric" ] && 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