--- network.subr.orig 2018-07-13 22:13:28.281892380 +0100 +++ network.subr 2018-07-14 00:07:09.764421472 +0100 @@ -287,7 +287,7 @@ fi _if=$1 - _punct=".-/+" + _punct=".-/+:" ltr ${_if} "${_punct}" '_' _if _var=$2 _default=$3 @@ -1589,15 +1589,21 @@ } # ifnet_rename [ifname] -# Rename interfaces if ifconfig_IF_name is defined. +# Rename interfaces if ifconfig_IF_name or ifconfig_ether_IF_name is defined. # ifnet_rename() { - local _if _ifname + local _if _ifname _ifether # ifconfig_IF_name for _if in ${*:-$(${IFCONFIG_CMD} -l)}; do - _ifname=`get_if_var $_if ifconfig_IF_name` + _ifname=`get_if_var "$_if" ifconfig_IF_name` + _ifether=`get_etheraddr "$_if"` + + if [ ! -z "$_ifether" ]; then + _ifname=`get_if_var "$_ifether" ifconfig_ether_IF_name "$_ifname"` + fi + if [ ! -z "$_ifname" ]; then ${IFCONFIG_CMD} $_if name $_ifname fi @@ -1791,3 +1797,18 @@ return done } + +# get_etheraddr [ifname] +# Echo the hwaddr for the interface, if any. +# +get_etheraddr() +{ + local _if proto addr rest + _if=$1 + ${IFCONFIG_CMD} "$_if" 2>/dev/null | while read proto addr rest; do + case "$proto" in + ether) + echo $addr + esac + done +}