netifd: dhcp proto convert release to norelease
authorKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Tue, 19 Nov 2019 15:12:42 +0000 (15:12 +0000)
committerKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Wed, 20 Nov 2019 10:52:57 +0000 (10:52 +0000)
Change dhcp no/release on shutdown to 'norelease' uci option to match
existing proto dhcpv6 usage.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Acked-by: Hans Dedecker <dedeckeh@gmail.com>
package/network/config/netifd/Makefile
package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release [new file with mode: 0644]
package/network/config/netifd/files/lib/netifd/proto/dhcp.sh

index 875628f66ad98ee2a734b02923cbe6f6a2b2d755..e24ebaba3056df8839ce86bfc3c7811cdc8b525c 100644 (file)
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=netifd
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=netifd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
diff --git a/package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release b/package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release
new file mode 100644 (file)
index 0000000..651c437
--- /dev/null
@@ -0,0 +1,23 @@
+. /lib/functions.sh
+
+migrate_release() {
+       local config="$1"
+       local proto
+       local release
+
+       config_get proto "$config" proto
+       config_get release "$config" release
+
+       [ "$proto" = "dhcp" ] && [ -n "$release" ] && {
+               norelease="$((!$release))"
+               uci_set network "$config" norelease "$norelease"
+               uci_remove network "$config" release
+       }
+
+}
+
+config_load network
+config_foreach migrate_release interface
+commit network
+
+exit 0
index 0d06eba06ef60214b9e1c5bd6e5e53ffeb009125..3034b2ba68ea7f69cae8bbca54e42c263e69cdd7 100755 (executable)
@@ -14,7 +14,7 @@ proto_dhcp_init_config() {
        proto_config_add_string clientid
        proto_config_add_string vendorid
        proto_config_add_boolean 'broadcast:bool'
        proto_config_add_string clientid
        proto_config_add_string vendorid
        proto_config_add_boolean 'broadcast:bool'
-       proto_config_add_boolean 'release:bool'
+       proto_config_add_boolean 'norelease:bool'
        proto_config_add_string 'reqopts:list(string)'
        proto_config_add_boolean 'defaultreqopts:bool'
        proto_config_add_string iface6rd
        proto_config_add_string 'reqopts:list(string)'
        proto_config_add_boolean 'defaultreqopts:bool'
        proto_config_add_string iface6rd
@@ -35,8 +35,8 @@ proto_dhcp_setup() {
        local config="$1"
        local iface="$2"
 
        local config="$1"
        local iface="$2"
 
-       local ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
-       json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute
+       local ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
+       json_get_vars ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute
 
        local opt dhcpopts
        for opt in $reqopts; do
 
        local opt dhcpopts
        for opt in $reqopts; do
@@ -50,7 +50,7 @@ proto_dhcp_setup() {
 
        [ "$defaultreqopts" = 0 ] && defaultreqopts="-o" || defaultreqopts=
        [ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
 
        [ "$defaultreqopts" = 0 ] && defaultreqopts="-o" || defaultreqopts=
        [ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
-       [ "$release" = 1 ] && release="-R" || release=
+       [ "$norelease" = 1 ] && norelease="" || norelease="-R"
        [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
        [ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd"
        [ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212"
        [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
        [ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd"
        [ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212"
@@ -70,7 +70,7 @@ proto_dhcp_setup() {
                ${ipaddr:+-r $ipaddr} \
                ${hostname:+-x "hostname:$hostname"} \
                ${vendorid:+-V "$vendorid"} \
                ${ipaddr:+-r $ipaddr} \
                ${hostname:+-x "hostname:$hostname"} \
                ${vendorid:+-V "$vendorid"} \
-               $clientid $defaultreqopts $broadcast $release $dhcpopts
+               $clientid $defaultreqopts $broadcast $norelease $dhcpopts
 }
 
 proto_dhcp_renew() {
 }
 
 proto_dhcp_renew() {