From: Michael Tremer Date: Fri, 25 May 2012 09:24:54 +0000 (+0000) Subject: Remove a lot of 'devicify' calls to increase speed of code. X-Git-Tag: 004~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5bb2429af132a2111e45ecfb8e148fb6c100f9ec;p=network.git Remove a lot of 'devicify' calls to increase speed of code. --- diff --git a/Makefile b/Makefile index 23c6a427..84286cbd 100644 --- 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 diff --git a/functions.bonding b/functions.bonding index ff2841d4..9c80767c 100644 --- a/functions.bonding +++ b/functions.bonding @@ -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 diff --git a/functions.cli b/functions.cli index e2599637..ab2c091c 100644 --- a/functions.cli +++ b/functions.cli @@ -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() { diff --git a/functions.device b/functions.device index 09ba33ed..47187f58 100644 --- a/functions.device +++ b/functions.device @@ -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} diff --git a/functions.virtual b/functions.virtual index b9d03354..e0ae39c0 100644 --- a/functions.virtual +++ b/functions.virtual @@ -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})'." diff --git a/functions.zone b/functions.zone index defed8dd..3cac124b 100644 --- a/functions.zone +++ b/functions.zone @@ -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}