udev: Fix renaming bridged interfaces

Since using random interface names is always trouble, we will order all
slave interfaces and number them in order as they appear in the SLAVES
variable.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Daniel Weismüller
2021-04-07 14:56:36 +00:00
committed by Michael Tremer
parent 341ad69f0e
commit 087a20011b

View File

@@ -58,18 +58,25 @@ for zone in ${ZONES}; do
address="${zone}_MACADDR" address="${zone}_MACADDR"
device="${zone}_DEV" device="${zone}_DEV"
mode="${zone}_MODE" mode="${zone}_MODE"
slaves="${zone}_SLAVES"
# Skip if address or device is unset # Return DEV when the address matches
[ -n "${!address}" -a -n "${!device}" ] || continue if [ "${!address,,}" = "${ADDRESS,,}" ]; then
echo "${!device}"
# Compare MAC addresses exit 0
[ "${ADDRESS}" = "${!address,,}" ] || continue fi
# If a matching interface has been found we will # If a matching interface has been found we will
# print the name to which udev will rename it. # print the name to which udev will rename it.
case "${!mode}" in case "${!mode}" in
bridge) 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) macvtap)
@@ -81,13 +88,7 @@ for zone in ${ZONES}; do
echo "${!device%0}phys0" echo "${!device%0}phys0"
fi fi
;; ;;
*)
echo "${!device}"
;;
esac esac
exit 0
done done
# If we get here we have not found a matching device, # If we get here we have not found a matching device,