firewall: - defer firewall start until the first interface is brought up by hotplug...
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 17 May 2010 12:47:14 +0000 (12:47 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 17 May 2010 12:47:14 +0000 (12:47 +0000)
SVN-Revision: 21486

package/firewall/Makefile
package/firewall/files/firewall.hotplug
package/firewall/files/firewall.init
package/firewall/files/lib/core.sh

index 22d359939f2b7b910377d3d061f42904a806f9f8..3b37c873572f15e38b09ace391f7b3431e169c3b 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=firewall
 
 PKG_VERSION:=2
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 include $(INCLUDE_DIR)/package.mk
 
index e9d167b79df2c23499c4d4d7ade447208d4fb543..bc75e42d1d3fd1b36c10d0b6f63330c82e213545 100644 (file)
@@ -9,11 +9,20 @@
 
 . /lib/firewall/core.sh
 fw_init
-fw_is_loaded || exit 0
+
+# Wait for firewall if startup is in progress
+lock -w /var/lock/firewall.start
 
 case "$ACTION" in
        ifup)
-               fw_configure_interface "$INTERFACE" add "$DEVICE" ;;
+               fw_is_loaded && {
+                       fw_configure_interface "$INTERFACE" add "$DEVICE" &
+               } || {
+                       /etc/init.d/firewall enabled && fw_start &
+               }
+       ;;
        ifdown)
-               fw_configure_interface "$INTERFACE" del "$DEVICE" ;;
+               fw_is_loaded && fw_configure_interface "$INTERFACE" del "$DEVICE" &
+       ;;
 esac
+
index 54742488e800f52baa5d9b4678faff44f3d0a97f..d04804d756cfbc9a966791d0bc022188dd6ab335 100755 (executable)
@@ -10,6 +10,8 @@ fw() {
        fw_$1
 }
 
+boot() { :; }
+
 start() {
        fw start
 }
index 3fd98d1602ecac2aa986ea80979dc77022d43095..bf44231fb0e7a803f206705b09e50c44d0063775 100644 (file)
@@ -8,6 +8,8 @@ include /lib/network
 fw_start() {
        fw_init
 
+       lock /var/lock/firewall.start
+
        FW_DEFAULTS_APPLIED=
 
        fw_is_loaded && {
@@ -49,6 +51,8 @@ fw_start() {
        fw_callback post core
 
        uci_set_state firewall core loaded 1
+
+       lock -u /var/lock/firewall.start
 }
 
 fw_stop() {
@@ -75,9 +79,8 @@ fw_reload() {
 }
 
 fw_is_loaded() {
-       local bool
-       config_get_bool bool core loaded 0
-       return $((! $bool))
+       local bool=$(uci -q -P /var/state get firewall.core.loaded)
+       return $((! ${bool:-0}))
 }