netifd: use procd_add_reload_trigger
[openwrt.git] / package / network / config / netifd / files / etc / init.d / network
index 848336f..8a7427b 100755 (executable)
@@ -18,6 +18,7 @@ start_service() {
        procd_open_instance
        procd_set_param command /sbin/netifd
        procd_set_param respawn
+       procd_set_param watch network.interface
        [ -e /proc/sys/kernel/core_pattern ] && {
                procd_set_param limits core="unlimited"
                echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
@@ -36,7 +37,7 @@ stop_service() {
 }
 
 service_running() {
-       sleep 5
+       ubus -t 30 wait_for network.interface
        /sbin/wifi reload_legacy
 }
 
@@ -57,12 +58,12 @@ validate_route_section()
 {
        uci_validate_section network route "${1}" \
                'interface:string' \
-               'target:ip4addr' \
-               'netmask:ip4prefix' \
+               'target:cidr4' \
+               'netmask:netmask4' \
                'gateway:ip4addr' \
                'metric:uinteger' \
                'mtu:uinteger' \
-               'table:range(0,65535)'
+               'table:or(range(0,65535),string)'
 
        return $?
 }
@@ -71,11 +72,11 @@ validate_route6_section()
 {
        uci_validate_section network route6 "${1}" \
                'interface:string' \
-               'target:ip6addr' \
+               'target:cidr6' \
                'gateway:ip6addr' \
                'metric:uinteger' \
                'mtu:uinteger' \
-               'table:range(0,65535)'
+               'table:or(range(0,65535),string)'
 
        return $?
 }
@@ -85,12 +86,12 @@ validate_rule_section()
        uci_validate_section network rule "${1}" \
                'in:string' \
                'out:string' \
-               'src:ip4prefix' \
-               'dest:ip4prefix' \
-               'tos:rage(0.31)' \
-               'string:mark' \
+               'src:cidr4' \
+               'dest:cidr4' \
+               'tos:range(0,31)' \
+               'mark:string' \
                'invert:bool' \
-               'lookup:range(0,65535)' \
+               'lookup:or(range(0,65535),string)' \
                'goto:range(0,65535)' \
                'action:or("prohibit", "unreachable", "blackhole", "throw")'
 
@@ -102,12 +103,12 @@ validate_rule6_section()
        uci_validate_section network rule6 "${1}" \
                'in:string' \
                'out:string' \
-               'src:ip4prefix' \
-               'dest:ip4prefix' \
-               'tos:rage(0.31)' \
-               'string:mark' \
+               'src:cidr6' \
+               'dest:cidr6' \
+               'tos:range(0,31)' \
+               'mark:string' \
                'invert:bool' \
-               'lookup:range(0,65535)' \ 
+               'lookup:or(range(0,65535),string)' \
                'goto:range(0,65535)' \
                'action:or("prohibit", "unreachable", "blackhole", "throw")'
 
@@ -137,10 +138,7 @@ validate_switch_vlan()
 
 service_triggers()
 {
-       procd_open_trigger
-       procd_add_config_trigger "config.change" "network" /etc/init.d/network reload
-       procd_add_config_trigger "config.change" "wireless" /etc/init.d/network reload
-       procd_close_trigger
+       procd_add_reload_trigger network wireless
 
        procd_open_validate
        validate_atm_bridge_section