Browse Source

cleanup parsing of hostname.* files, and seperate bridge control into

bridgename.* files; all documented in new hostname.if(5) and
bridgename.if(5) man pages
OPENBSD_2_6
deraadt 25 years ago
parent
commit
9b7693b85f
1 changed files with 33 additions and 50 deletions
  1. +33
    -50
      src/etc/netstart

+ 33
- 50
src/etc/netstart View File

@ -1,6 +1,6 @@
#!/bin/sh -
#
# $OpenBSD: netstart,v 1.49 1999/08/09 21:49:04 angelos Exp $
# $OpenBSD: netstart,v 1.50 1999/09/01 05:07:50 deraadt Exp $
# Returns true if $1 contains only alphanumerics
isalphanumeric() {
@ -43,45 +43,7 @@ route -n add -host $hostname localhost
route -n add -net 127 127.0.0.1 -reject
# configure all of the non-loopback interfaces which we know about.
# do this by reading /etc/hostname.* files, where * is the name
# of a given interface.
#
# these files are formatted like the following, but with no # at the
# beginning of the line
#
# addr_family hostname netmask broadcast_addr options
# dest dest_addr
#
# OR
#
# dhcp
#
# OR
#
# bridge
# brconfig-arguments [ several lines if needed ]
#
# addr_family is the address family of the interface, generally inet
# hostname is the host name that belongs to the interface, in /etc/hosts.
# netmask is the network mask for the interface.
# broadcast_addr is the broadcast address for the interface
# options are misc. options to ifconfig for the interface.
#
# dest is simply the string "dest" (no quotes, though) if the interface
# has a "destination" (i.e. it's a point-to-point link, like SLIP).
# dest_addr is the hostname of the other end of the link, in /etc/hosts
#
# the only required contents of the file in this mode are the addr_family field
# and the hostname.
#
# dhcp is simply the string "dhcp" (no quotes, though) if the interface
# is to be configured using DHCP. See dhclient(8) and dhclient.conf(5)
# for details.
#
# bridge is the string "bridge" (still no quotes). Bridge interfaces
# are just configured "up" and then brconfig(8) is called for each
# line of arguments following this first line.
# refer to hostname.if(5) and bridgename.if(5)
for hn in /etc/hostname.*; do
# Strip off /etc/hostname. prefix
if=${hn#/etc/hostname.}
@ -91,9 +53,7 @@ for hn in /etc/hostname.*; do
if ! isalphanumeric "$if"; then
continue
fi
# If the interface does not exist, just skip processing the file
/sbin/ifconfig $if > /dev/null 2>&1
ifconfig $if > /dev/null 2>&1
if [ "$?" != "0" ]; then
continue
fi
@ -102,25 +62,25 @@ for hn in /etc/hostname.*; do
{
read af name mask bcaddr extras
# $af can be either "bridge", "dhcp", "up" or an address family.
# $af can be either "dhcp", "up" or an address family.
case "$af" in
"bridge")
ifconfig $if up
cmd=`sed "s/\(.*\)/brconfig $if \1;/"`
;;
cmd="echo ${hn}: bridges now supported via bridgename.* files"
;;
"dhcp")
ifconfig $if $extras down
cmd="/sbin/dhclient $if"
ifconfig $if $name $mask $bcaddr $extras down
cmd="dhclient $if"
;;
"up")
# The only one of these guaranteed to be set is $if
# the remaining ones exist so that media controls work
cmd="ifconfig $if $name $mask $bcaddr $extras up"
;;
*)
read dt dtaddr
if [ ! -n "$name" ]; then
echo "/etc/hostname.$if: invalid network configuration file"
exit
continue
fi
cmd="ifconfig $if $af $name "
@ -136,6 +96,29 @@ for hn in /etc/hostname.*; do
eval "$cmd"
} < /etc/hostname.$if
done
for bn in /etc/bridgename.*; do
# Strip off /etc/bridgename. prefix
if=${bn#/etc/bridgename.}
# Interface names must be alphanumeric only. We check to avoid
# configuring backup or temp files, and to catch the "*" case.
if ! isalphanumeric "$if"; then
continue
fi
brconfig $if > /dev/null 2>&1
if [ "$?" != "0" ]; then
continue
fi
# Now parse the bridgename.* file
{
# All lines are run as brconfig(8) commands.
while read line ; do
# XXX should support # comments and skip blank lines
brconfig $if $line
done
} < /etc/bridgename.$if
done
# /etc/mygate, if it exists, contains the name of my gateway host
# that name must be in /etc/hosts.


Loading…
Cancel
Save