[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#575766: initramfs-tools: configure_networking function fails if no DEVICE is specified



On Sun, 28 Mar 2010, Vagrant Cascadian wrote:

> the configure_networking function relies on DEVICE being set, and
> conf/initramfs.conf hard-codes this to eth0. though some scripts may call this
> from /scripts/local-top, and DEVICE may not be set. even when it is set, it
> hard-coding it to eth0 may be the wrong network interface.
> 
> the following patch should partially address this by checking for DEVICE when
> not defined, and using the first interface with an active link.

this looks very similar to #566295

did you have a look at the proposed patch of
http://bugs.debian.org/566295

thanks
 
> diff --git a/conf/initramfs.conf b/conf/initramfs.conf
> index 23dd249..471dfea 100644
> --- a/conf/initramfs.conf
> +++ b/conf/initramfs.conf
> @@ -55,7 +55,7 @@ BOOT=local
>  # Specify the network interface, like eth0
>  #
>  
> -DEVICE=eth0
> +#DEVICE=eth0
>  
>  #
>  # NFSROOT: [ auto | HOST:MOUNT ]
> diff --git a/scripts/functions b/scripts/functions
> index 0ecb1d6..5444c11 100644
> --- a/scripts/functions
> +++ b/scripts/functions
> @@ -294,6 +294,24 @@ configure_networking()
>  		done
>  	fi
>  
> +	if [ -z "${DEVICE}" ]; then
> +		# attempt to detect the first device with an established link.
> +		for net_device_path in /sys/class/net/* ; do
> +			net_device=${net_device_path##*/}
> +			case $net_device in
> +				lo) ;;
> +				*)
> +					if read carrier < "$net_device_path/carrier" ; then
> +						if [ "$carrier" = "1" ]; then
> +							DEVICE="$net_device"
> +							break
> +						fi
> +					fi
> +					;;
> +			esac
> +		done
> +	fi
> +
>  	# networking already configured thus bail out
>  	[ -n "${DEVICE}" ] && [ -e /tmp/net-"${DEVICE}".conf ] && return 0
>  
> 
> live well,
>   vagrant
> 
> 
-- 
maks



Reply to: