2009-06-16 21:14:51 +04:00
#!/bin/sh
#
# Format:
# ip=[dhcp|on|any]
#
# ip=<interface>:[dhcp|on|any]
#
# ip=<client-IP-number>:<server-id>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
#
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
# When supplying more than only ip= line, <interface> is mandatory and
# bootdev= must contain the name of the primary interface to use for
# routing,dns,dhcp-options,etc.
#
2009-06-16 21:14:51 +04:00
2010-02-04 18:05:19 +03:00
. /lib/dracut-lib.sh
2009-06-16 21:14:51 +04:00
2009-06-16 21:26:35 +04:00
# Check if ip= lines should be used
if getarg ip = >/dev/null ; then
if [ -z " $netroot " ] ; then
echo "Warning: No netboot configured, ignoring ip= lines"
return ;
fi
fi
2009-06-16 21:35:03 +04:00
# Don't mix BOOTIF=macaddr from pxelinux and ip= lines
getarg ip = >/dev/null && getarg BOOTIF = >/dev/null && \
die "Mixing BOOTIF and ip= lines is dangerous"
# No more parsing stuff, BOOTIF says everything
[ -n " $( getarg BOOTIF) " ] && return
2009-06-16 21:14:51 +04:00
if [ -n " $netroot " ] && [ -z " $( getarg ip = ) " ] ; then
2009-07-13 16:23:49 +04:00
# No ip= argument(s) for netroot provided, defaulting to DHCP
2009-06-16 21:14:51 +04:00
return ;
fi
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
# Count ip= lines to decide whether we need bootdev= or not
if [ -z " $NEEDBOOTDEV " ] ; then
local count = 0
2009-07-24 12:42:39 +04:00
for p in $( getargs ip = ) ; do
count = $(( $count + 1 ))
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
done
[ $count -gt 1 ] && NEEDBOOTDEV = 1
fi
# If needed, check if bootdev= contains anything usable
if [ -n " $NEEDBOOTDEV " ] ; then
BOOTDEV = $( getarg bootdev = ) || die "Please supply bootdev argument for multiple ip= lines"
[ -z " $BOOTDEV " ] && die "Bootdev argument is empty"
fi
2009-06-16 21:14:51 +04:00
# Check ip= lines
# XXX Would be nice if we could errorcheck ip addresses here as well
2009-07-24 12:42:39 +04:00
for p in $( getargs ip = ) ; do
ip_to_var $p
2009-06-16 21:14:51 +04:00
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
# We need to have an ip= line for the specified bootdev
[ -n " $NEEDBOOTDEV " ] && [ " $dev " = " $BOOTDEV " ] && BOOTDEVOK = 1
2009-06-16 21:14:51 +04:00
# Empty autoconf defaults to 'dhcp'
if [ -z " $autoconf " ] ; then
warn "Empty autoconf values default to dhcp"
autoconf = "dhcp"
fi
# Error checking for autoconf in combination with other values
case $autoconf in
2009-07-24 12:42:39 +04:00
error) die " Error parsing option 'ip= $p ' " ; ;
2009-06-16 21:14:51 +04:00
bootp| rarp| both) die " Sorry, ip= $autoconf is currenty unsupported " ; ;
none| off) \
[ -z " $ip " ] && \
2009-07-24 12:42:39 +04:00
die " For argument 'ip= $p '\nValue ' $autoconf ' without static configuration does not make sense "
2009-06-16 21:14:51 +04:00
[ -z " $mask " ] && \
die "Sorry, automatic calculation of netmask is not yet supported"
; ;
dhcp| on| any) \
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
[ -n " $NEEDBOOTDEV " ] && [ -z " $dev " ] && \
2009-07-24 12:42:39 +04:00
die " Sorry, 'ip= $p ' does not make sense for multiple interface configurations "
2009-06-16 21:14:51 +04:00
[ -n " $ip " ] && \
2009-07-24 12:42:39 +04:00
die " For argument 'ip= $p '\nSorry, setting client-ip does not make sense for ' $autoconf ' "
2009-06-16 21:14:51 +04:00
; ;
2009-07-24 12:42:39 +04:00
*) die " For argument 'ip= $p '\nSorry, unknown value ' $autoconf ' " ; ;
2009-06-16 21:14:51 +04:00
esac
if [ -n " $dev " ] ; then
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
# We don't like duplicate device configs
2009-06-16 21:14:51 +04:00
if [ -n " $IFACES " ] ; then
for i in $IFACES ; do
2009-07-24 12:42:39 +04:00
[ " $dev " = " $i " ] && die " For argument 'ip= $p '\nDuplication configurations for ' $dev ' "
2009-06-16 21:14:51 +04:00
done
fi
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
# IFACES list for later use
2009-06-16 21:14:51 +04:00
IFACES = " $IFACES $dev "
fi
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
# Small optimization for udev rules
[ -z " $NEEDBOOTDEV " ] && [ -n " $dev " ] && BOOTDEV = $dev
# Do we need to check for specific options?
if [ -n " $NEEDDHCP " ] || [ -n " $DHCPORSERVER " ] ; then
# Correct device? (Empty is ok as well)
[ " $dev " = " $BOOTDEV " ] || continue
# Server-ip is there?
[ -n " $DHCPORSERVER " ] && [ -n " $srv " ] && continue
# dhcp? (It's simpler to check for a set ip. Checks above ensure that if
# ip is there, we're static
[ -z " $ip " ] && continue
# Not good!
die "Server-ip or dhcp for netboot needed, but current arguments say otherwise"
2009-06-16 21:14:51 +04:00
fi
done
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
# This ensures that BOOTDEV is always first in IFACES
if [ -n " $BOOTDEV " ] && [ -n " $IFACES " ] ; then
IFACES = " ${ IFACES % $BOOTDEV * } ${ IFACES #* $BOOTDEV } "
IFACES = " $BOOTDEV $IFACES "
fi
# Store BOOTDEV and IFACES for later use
[ -n " $BOOTDEV " ] && echo $BOOTDEV > /tmp/net.bootdev
[ -n " $IFACES " ] && echo $IFACES > /tmp/net.ifaces
2009-06-16 21:14:51 +04:00
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
2009-06-16 22:50:31 +04:00
# We need a ip= line for the configured bootdev=
2009-07-13 16:23:49 +04:00
[ -n " $NEEDBOOTDEV " ] && [ -z " $BOOTDEVOK " ] && die " Bootdev Argument ' $BOOTDEV ' not found "