View | Details | Raw Unified | Return to bug 118111 | Differences between
and this patch

Collapse All | Expand All

(-)network.subr (-1 / +37 lines)
Lines 585-602 Link Here
585
	return $_ret
585
	return $_ret
586
}
586
}
587
587
588
get_if_mac()
589
{
590
	ifconfig $1 2>/dev/null | while read proto addr rest; do
591
		case ${proto} in
592
		ether)
593
			echo $addr
594
		esac
595
	done
596
}
597
588
# ifnet_rename
598
# ifnet_rename
589
#	Rename all requested interfaces.
599
#	Rename all requested interfaces.
590
#
600
#
591
ifnet_rename()
601
ifnet_rename()
592
{
602
{
593
594
	_ifn_list="`ifconfig -l`"
603
	_ifn_list="`ifconfig -l`"
595
	[ -z "$_ifn_list" ] && return 0
604
	[ -z "$_ifn_list" ] && return 0
596
	for _if in ${_ifn_list} ; do
605
	for _if in ${_ifn_list} ; do
597
		_ifname=`get_if_var $_if ifconfig_IF_name`
606
		_ifname=`get_if_var $_if ifconfig_IF_name`
598
		if [ ! -z "$_ifname" ]; then
607
		if [ ! -z "$_ifname" ]; then
599
			ifconfig $_if name $_ifname
608
			ifconfig $_if name $_ifname
609
			# ifconfig returns EX_OK even if it fails
610
			_if=$_ifname
611
		fi
612
613
		if [ ! -z "$ifconfig_mac_names" ]; then
614
			mac=`get_if_mac $_if | sed -e 's/[^a-f0-9]//g'`
615
			if [ ! -z "$mac" ]; then
616
				eval _ifmac_${mac}_name=$_if
617
			fi
618
		fi
619
	done
620
621
	[ -z "$ifconfig_mac_names" ] && return 0
622
	for _ifname in ${ifconfig_mac_names} ; do
623
		_ifmac=`get_if_var $_ifname ifconfig_mac_IF`
624
		if [ ! -z "$_ifmac" ] ; then
625
			_mac="`echo $_ifmac |tr '[:upper:]' '[:lower:]' |sed -e 's/[^a-f0-9]//g'`"
626
			_if=`eval echo \\${_ifmac_${_mac}_name}`
627
			if [ ! -z $_if ] ; then
628
				if [ ! $_if = $_ifname ]; then
629
					ifconfig $_if name $_ifname
630
				fi
631
			else
632
				warn "Unable to locate interface with MAC $_ifmac for $_ifname"
633
			fi
634
		else
635
			warn "MAC not configured for $_ifname, please set ifconfig_mac_${_ifname}"
600
		fi
636
		fi
601
	done
637
	done
602
	return 0
638
	return 0

Return to bug 118111