]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - config/udev/network-hotplug-rename
udev: Fix renaming bridged interfaces
[people/pmueller/ipfire-2.x.git] / config / udev / network-hotplug-rename
index 71a25c317d64989e1728ffbb268ac5b5f5eec135..8807e0ab878319b12c0ce9329255218e4a8d3c81 100644 (file)
@@ -58,18 +58,25 @@ for zone in ${ZONES}; do
        address="${zone}_MACADDR"
        device="${zone}_DEV"
        mode="${zone}_MODE"
+       slaves="${zone}_SLAVES"
 
-       # Skip if address or device is unset
-       [ -n "${!address}" -a -n "${!device}" ] || continue
-
-       # Compare MAC addresses
-       [ "${ADDRESS}" = "${!address,,}" ] || continue
+       # Return DEV when the address matches
+       if [ "${!address,,}" = "${ADDRESS,,}" ]; then
+               echo "${!device}"
+               exit 0
+       fi
 
        # If a matching interface has been found we will
        # print the name to which udev will rename it.
        case "${!mode}" in
                bridge)
-                       echo "${!device%0}phys0"
+                       counter=0
+                       for slave in ${!slaves}; do
+                               if [ "${slave,,}" = "${ADDRESS,,}" ]; then
+                                       echo "${!device}p${counter}"
+                               fi
+                               (( counter += 1 ))
+                       done
                        ;;
 
                macvtap)
@@ -81,13 +88,7 @@ for zone in ${ZONES}; do
                                echo "${!device%0}phys0"
                        fi
                        ;;
-
-               *)
-                       echo "${!device}"
-                       ;;
        esac
-
-       exit 0
 done
 
 # If we get here we have not found a matching device,