From: Michael Tremer Date: Thu, 23 Jul 2009 18:54:57 +0000 (+0200) Subject: Another bunch of minor fixes on the network code. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76210e7e121e5a52b5cdbc164f595e08a73c905d;p=ipfire-3.x.git Another bunch of minor fixes on the network code. --- diff --git a/src/network/lib/functions b/src/network/lib/functions index a2d1c26ac..98cd98539 100644 --- a/src/network/lib/functions +++ b/src/network/lib/functions @@ -108,6 +108,8 @@ function devicify() { local device=${1} local mac + [ -n "${device}" ] || return 1 + if is_mac ${device}; then mac=${device} device=$(get_device_by_mac ${device}) @@ -146,10 +148,9 @@ function device_rename() { local destination=$2 # Replace + by a valid number - if grep -q "+$" <<<${destination}; then - local number + if [[ ${destination} =~ +$ ]]; then + local number=0 destination=$(sed -e "s/+//" <<<$destination) - number=0 while [ "${number}" -le "100" ]; do if ! device_exists "${destination}${number}"; then destination="${destination}${number}" @@ -159,7 +160,7 @@ function device_rename() { done fi - # Check if devices exist + # Check if devices exists if ! device_exists ${source} || device_exists ${destination}; then return 4 fi diff --git a/src/network/lib/hooks/vlan b/src/network/lib/hooks/vlan index 1a131cc1a..7c049dc50 100755 --- a/src/network/lib/hooks/vlan +++ b/src/network/lib/hooks/vlan @@ -42,12 +42,16 @@ function do_down() { } function do_attach() { - device_rename $(get_device_by_mac_and_vid ${port} ${ID}) $(port_name) - zone_add_port ${zone} $(get_device ${port} ${ID}) + if ! zone_has_device_attached ${zone} $(port_name); then + device_rename $(get_device_by_mac_and_vid ${port} ${ID}) $(port_name) + zone_add_port ${zone} $(get_device ${port} ${ID}) + fi } function do_detach() { - zone_del_port ${zone} $(get_device_by_mac_and_vid ${port} ${ID}) + if zone_has_device_attached ${zone} $(port_name); then + zone_del_port ${zone} $(get_device_by_mac_and_vid ${port} ${ID}) + fi } function do_status() { diff --git a/src/network/network b/src/network/network index 6b89899c5..a544ff65c 100644 --- a/src/network/network +++ b/src/network/network @@ -274,7 +274,6 @@ function port_add() { RET=$? if [ "$RET" -eq "0" ]; then vecho "Successfully added port ${BOLD}${port}${NORMAL} (${hook} $@) to ${BOLD}${zone}${NORMAL}." - cmd /lib/network/port --port=${port} up else error "Hook ${BOLD}${hook}${NORMAL} exited with $RET." return $RET @@ -283,7 +282,6 @@ function port_add() { error "Hook ${BOLD}${hook}${NORMAL} does not exist or is not executeable." return 1 fi - cmd /lib/network/zone --zone=${zone} up } function port_del() { @@ -375,7 +373,6 @@ function zone_add() { mkdir -p ${CONFIG_ZONES}/${zone} vecho "Successfully added zone ${BOLD}${zone}${NORMAL}." - cmd /lib/network/zone --zone=${zone} up # Done by reload?? } function zone_del() {