]> git.ipfire.org Git - network.git/commitdiff
Remove a lot of 'devicify' calls to increase speed of code.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 May 2012 09:24:54 +0000 (09:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 May 2012 09:24:54 +0000 (09:24 +0000)
Makefile
functions.bonding
functions.cli
functions.device
functions.virtual
functions.zone

index 23c6a427ecaae03c96f9f091fecbdf62f5d55869..84286cbdee5d53bb75a19ae71a050c576feb983f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,7 @@ sbindir=$(prefix)/sbin
 libdir=$(prefix)/lib
 sysconfdir=/etc
 localstatedir=/var
+systemdunitdir=$(prefix)/lib/systemd/system
 
 # File to store the version number in.
 VERSION_FILE = $(DESTDIR)$(libdir)/network/version
@@ -22,6 +23,7 @@ install:
        -mkdir -pv $(DESTDIR)$(libdir)/{network,sysctl.d,udev}
        -mkdir -pv $(DESTDIR)$(localstatedir)/log/network
        -mkdir -pv $(DESTDIR)$(sbindir)
+       -mkdir -pv $(DESTDIR)$(systemdunitdir)
 
        install -m 755 -v network $(DESTDIR)$(sbindir)
 
@@ -29,13 +31,14 @@ install:
        cp -fv  sysctl.d/* $(DESTDIR)$(libdir)/sysctl.d/
        cp -rfv udev/* $(DESTDIR)$(libdir)/udev
        cp -rfv network-* $(DESTDIR)$(libdir)/network/
+       cp -vf  systemd/*.service $(DESTDIR)$(systemdunitdir)
 
        # Install bridge-stp. 
        install -m 755 bridge-stp $(DESTDIR)$(sbindir)/
 
        # Install dhclient script and helper.
-       install -m 755 dhclient-helper $(DESTDIR)/usr/lib/network/
-       install -m 755 dhclient-script $(DESTDIR)/sbin/
+       install -m 755 dhclient-helper $(DESTDIR)$(libdir)/network/
+       install -m 755 dhclient-script $(DESTDIR)$(sbindir)/
 
        install -m 755 -v ppp/ip-updown $(DESTDIR)$(sysconfdir)/ppp
        ln -svf ip-updown $(DESTDIR)$(sysconfdir)/ppp/ip-pre-up
index ff2841d4e19780163de484cd7f26b58b9413a271..9c80767cf83e5548bce8cb0439cc7ed3b6bb3ff4 100644 (file)
@@ -42,8 +42,7 @@ function bonding_create() {
 }
 
 function bonding_remove() {
-       local device=$(devicify ${1})
-
+       local device=${1}
        assert isset device
 
        log INFO "Remove bonding device '${device}'."
@@ -70,8 +69,8 @@ function bonding_get_mode() {
 }
 
 function bonding_enslave_device() {
-       local device=$(devicify ${1})
-       local slave=$(devicify ${2})
+       local device=${1}
+       local slave=${2}
        shift 2
 
        assert isset device
index e25996377e9733f42e72215c50986e28feb97ffc..ab2c091c3c47f918ff373dc844eb0d73a3d31249 100644 (file)
@@ -292,8 +292,10 @@ function cli_start() {
 
        local zone
        for zone in ${zones}; do
-               zone_up ${zone}
+               zone_start ${zone} &
        done
+
+       wait # until everything is settled
 }
 
 function cli_stop() {
@@ -306,8 +308,10 @@ function cli_stop() {
 
        local zone
        for zone in ${zones}; do
-               zone_down ${zone}
+               zone_stop ${zone} &
        done
+
+       wait # until everything is settled
 }
 
 function cli_restart() {
index 09ba33ed648fc6b11145c7324b44eb6580876db9..47187f58a3b663c935ff7053d3d9e00ea79021a9 100644 (file)
@@ -135,7 +135,8 @@ function device_is_ppp() {
 
 # Check if the device is a loopback device
 function device_is_loopback() {
-       local device=$(devicify ${1})
+       local device=${1}
+
        [ "${device}" = "lo" ]
 }
 
@@ -166,7 +167,7 @@ function device_is_real() {
 
 # Get the device type
 function device_get_type() {
-       local device=$(devicify ${1})
+       local device=${1}
 
        if device_is_virtual ${device}; then
                echo "vlan"
@@ -271,7 +272,9 @@ function devices_get_all() {
 
 # Check if a device has a cable plugged in
 function device_has_carrier() {
-       local device=$(devicify ${1})
+       local device=${1}
+       assert isset device
+
        [ "$(<${SYS_CLASS_NET}/${device}/carrier)" = "1" ]
 }
 
@@ -299,7 +302,7 @@ function device_is_free() {
 
 # Check if the device is used
 function device_is_used() {
-       local device=$(devicify ${1})
+       local device=${1}
 
        device_has_virtuals ${device} && \
                return ${EXIT_OK}
@@ -346,7 +349,7 @@ function device_set_name() {
 
 # Set device up
 function device_set_up() {
-       local device=$(devicify ${1})
+       local device=${1}
 
        # Silently fail if device was not found
        [ -z "${device}" ] && return ${EXIT_ERROR}
@@ -381,7 +384,8 @@ function device_set_parent_up() {
 
 # Set device down
 function device_set_down() {
-       local device=$(devicify ${1})
+       local device=${1}
+       assert isset device
 
        local ret=${EXIT_OK}
 
index b9d03354edaa055bbd530fca9559ee85c917c878..e0ae39c0f7715850df62a5316b2dd105fc85353a 100644 (file)
@@ -37,7 +37,7 @@ EOF
 init_register virtual_init
 
 function virtual_create() {
-       local port=$(devicify ${1})
+       local port=${1}
        local vid=${2}
        local mac=${3}
        local newport=${port}v${vid}
@@ -124,7 +124,7 @@ function virtual_create() {
 }
 
 function virtual_remove() {
-       local device=$(devicify ${1})
+       local device=${1}
 
        log INFO "Removing virtual device '${device}' with address '$(macify ${device})'."
 
index defed8dd0333f1a53b425a44cde0a92ce7b6f213..3cac124b83175c0e735394fafee768f2122c96d6 100644 (file)
@@ -74,6 +74,26 @@ function zone_get_hook() {
        config_get_hook $(zone_dir ${zone})/settings
 }
 
+function zone_start() {
+       # This function will bring up the zone
+       # 'asynchronously' with help of systemd.
+
+       local zone=${1}
+       assert zone_exists ${zone}
+
+       service_start "network@${zone}"
+}
+
+function zone_stop() {
+       # This function will bring down the zone
+       # 'asynchronously' with help of systemd.
+
+       local zone=${1}
+       assert zone_exists ${zone}
+
+       service_stop "network@${zone}"
+}
+
 function zone_create() {
        local zone=${1}
        local hook=${2}