]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Another bunch of minor fixes on the network code.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 23 Jul 2009 18:54:57 +0000 (20:54 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 23 Jul 2009 18:54:57 +0000 (20:54 +0200)
src/network/lib/functions
src/network/lib/hooks/vlan
src/network/network

index a2d1c26ac1b2b954d8e0e42cc64f0fec195672bb..98cd98539a33f80024b6563c020853c265c4602f 100644 (file)
@@ -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
index 1a131cc1a72c6517b0174aa85c041790d7b53772..7c049dc50ab4d97dd53cb20b7babbeccd591cb45 100755 (executable)
@@ -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() {
index 6b89899c5f6ad56711e336ba3fe1d7680b83ac6b..a544ff65c25491c83228fe3de50fa7c928f9a789 100644 (file)
@@ -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() {