tech-net archive

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

cloner interface handling in rc.d/network



I have been staring at this code in /etc/rc.d/network

	ifaces="$(/sbin/ifconfig -l)"
	if checkyesno auto_ifconfig; then
		tmp="$ifaces"
		for cloner in $(/sbin/ifconfig -C); do
			for int in /etc/ifconfig.${cloner}[0-9]*; do
				[ ! -f $int ] && break
				tmp="$tmp ${int##*.}"
			done
		done
	else
		tmp="$net_interfaces"
        fi

for a while trying to understand the "for cloner" loop.

1. rc.conf(5) doesn't document this. What the code is supposed to do (I think) 
   is, with auto_ifconfig=YES, to add all "cloner" interfaces (which, by 
   design, can't appear in ifconfig -l at boot) to the list of interfaces to 
   configure in case a corresponding /etc/ifconfig.* file exists.

2. When run later (e.g. after going single user and back multi user), I guess 
   the interfaces in question may be added to a list already containing them.

3. The "[ ! -f $int ] && break" line completely confuses me

3a [ ! ... ] should better be written ! [ ... ], no?

3b ! [ ... ] && foo could be written [ ... ] || foo

3c What is this trying to catch? Directories called /etc/ifconfig.tun0?

3d Why break and not continue (or && tmp=)? Why exit on the first non-file 
   entry?

4 I guess the ##*. (why ## and not #?) could better be spelled out as 
   "#/etc/ifconfig."


Home | Main Index | Thread Index | Old Index