problems with iproute in lfs 6.0

Matthias B. msbREMOVE-THIS at winterdrache.de
Thu Jan 6 11:52:08 PST 2005


On Thu, 06 Jan 2005 08:25:45 -0700 "Kevin P. Fleming"
<kpfleming at linuxfromscratch.org> wrote:

> Nathan Coulson wrote:
> 
> > hmm, I'll see if I can simplify it some...  [not sure when the
> > networking part got congested]
> 
> In the spirit of education, rather than dumbing-down the scripts, maybe 
> it would better to just adds _lots_ of comments to them so users can 
> learn what they are doing and why? Seems to me that would solve both 
> problems.

No it wouldn't. The network scripts are just needlessly complicated. I
would reduce them to something like the following (untested, only relevant
parts shown):

One network config file with following syntax:

 # The host name of this machine.
HOSTNAME="lfs"

 # The network interfaces to be brought up and configured at boot time.
 # The first interface is NETWORK_INTERFACE_1, the 2nd is
 # NETWORK_INTERFACE_2, and so on.
NETWORK_INTERFACE_1=eth0
NETWORK_INTERFACE_1_IP=192.168.1.2/24
NETWORK_INTERFACE_1_BROADCAST=192.168.1.255
# NETWORK_INTERFACE_2=eth1
# NETWORK_INTERFACE_2_IP=192.168.1.2/24
# NETWORK_INTERFACE_2_BROADCAST=192.168.1.255

 # The IP address of the default router that should get all packages for 
 # which no other routing information exists. This is usually the address
 # of the machine/router connected to the Internet.
 # Leave this empty, if you don't have a gateway.
GATEWAY=192.168.1.8


One script called "interfaces" like this:

  start)
            
      for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ;
      do
        eval interface=\$NETWORK_INTERFACE_${i}
        eval ip=\$NETWORK_INTERFACE_${i}_IP
        eval broadcast_addr=\$NETWORK_INTERFACE_${i}_BROADCAST
        
        test -z "$interface" && break
        
        echo "Configuring network interface ${interface}..."
        ip link set "$interface" up &&
        ip addr add dev "$interface" \
                    local "$ip" \
                    broadcast "$broadcast_addr" \
                    label "$interface" 
        evaluate_retval
      done
      ;;

  stop)
     for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ;
      do
        eval interface=\$NETWORK_INTERFACE_${i}
        eval ip=\$NETWORK_INTERFACE_${i}_IP
        eval broadcast_addr=\$NETWORK_INTERFACE_${i}_BROADCAST
        
        test -z "$interface" && break
        
        echo "Bringing down network interface ${interface}..."
        ip addr del dev "$interface" \
                    local "$ip" \
                    broadcast "$broadcast_addr" \
                    label "$interface" # No &&  We always call ip ...
down.
        ip link set "$interface" down
        evaluate_retval
      done


One script called "hostname" with obvious contents.
One script called "routing" like this:

  start)
      if [ -z "$GATEWAY" ]; then
        echo "No gateway specified. Skipping default route..."
        print_status skipped
        exit 0
      fi
      
      echo "Setting default route through gateway..."
      ip route replace default via "$GATEWAY" 
      evaluate_retval
      ;;

  stop)
      echo "Removing default route through gateway..."
      ip route del default via "$GATEWAY"
      evaluate_retval
      ;;


Simple, easy to understand, easy to extend. This is KISS. This should be
in LFS. 
LFS is not a distro. LFS needs to show people how to write their own boot
scripts. It's NOT LFS's job to provide a FRAMEWORK for doing network
initialization.

MSB

-- 
I will continue to be an impossible person
as long as those who are now possible remain possible.




More information about the lfs-support mailing list