|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# NFS root might have reached here before /tmp/net.ifaces was written
|
|
|
|
type is_persistent_ethernet_name >/dev/null 2>&1 || . /lib/net-lib.sh
|
|
|
|
|
|
|
|
udevadm settle --timeout=30
|
|
|
|
|
|
|
|
mkdir -m 0755 -p /tmp/ifcfg/
|
|
|
|
mkdir -m 0755 -p /tmp/ifcfg-leases/
|
|
|
|
|
|
|
|
get_config_line_by_subchannel()
|
|
|
|
{
|
|
|
|
local CHANNEL
|
|
|
|
local line
|
|
|
|
|
|
|
|
CHANNELS="$1"
|
|
|
|
while read line || [ -n "$line" ]; do
|
|
|
|
if strstr "$line" "$CHANNELS"; then
|
|
|
|
echo $line
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done < /etc/ccw.conf
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
print_s390() {
|
|
|
|
local _netif
|
|
|
|
local SUBCHANNELS
|
|
|
|
local OPTIONS
|
|
|
|
local NETTYPE
|
|
|
|
local CONFIG_LINE
|
|
|
|
local i
|
|
|
|
local channel
|
|
|
|
local OLD_IFS
|
|
|
|
|
|
|
|
_netif="$1"
|
|
|
|
# if we find ccw channel, then use those, instead of
|
|
|
|
# of the MAC
|
|
|
|
SUBCHANNELS=$({
|
|
|
|
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
|
|
|
|
[ -e $i ] || continue
|
|
|
|
channel=$(readlink -f $i)
|
|
|
|
printf '%s' "${channel##*/},"
|
|
|
|
done
|
|
|
|
})
|
|
|
|
[ -n "$SUBCHANNELS" ] || return 1
|
|
|
|
|
|
|
|
SUBCHANNELS=${SUBCHANNELS%,}
|
|
|
|
echo "SUBCHANNELS=\"${SUBCHANNELS}\""
|
|
|
|
|
|
|
|
CONFIG_LINE=$(get_config_line_by_subchannel $SUBCHANNELS)
|
|
|
|
[ $? -ne 0 -o -z "$CONFIG_LINE" ] && return 0
|
|
|
|
|
|
|
|
OLD_IFS=$IFS
|
|
|
|
IFS=","
|
|
|
|
set -- $CONFIG_LINE
|
|
|
|
IFS=$OLD_IFS
|
|
|
|
NETTYPE=$1
|
|
|
|
shift
|
|
|
|
SUBCHANNELS="$1"
|
|
|
|
OPTIONS=""
|
|
|
|
shift
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
*=*) OPTIONS="$OPTIONS $1";;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
OPTIONS=${OPTIONS## }
|
|
|
|
echo "NETTYPE=\"${NETTYPE}\""
|
|
|
|
echo "OPTIONS=\"${OPTIONS}\""
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
hw_bind() {
|
|
|
|
local _netif="$1"
|
|
|
|
local _macaddr="$2"
|
|
|
|
|
|
|
|
[ -n "$_macaddr" ] \
|
|
|
|
&& echo "MACADDR=\"$_macaddr\""
|
|
|
|
|
|
|
|
print_s390 "$_netif" \
|
|
|
|
&& return 0
|
|
|
|
|
|
|
|
[ -n "$_macaddr" ] && return 0
|
|
|
|
|
|
|
|
is_persistent_ethernet_name "$_netif" && return 0
|
|
|
|
|
|
|
|
[ -f "/sys/class/net/$_netif/addr_assign_type" ] \
|
|
|
|
&& [ "$(cat "/sys/class/net/$_netif/addr_assign_type")" != "0" ] \
|
|
|
|
&& return 1
|
|
|
|
|
|
|
|
[ -f "/sys/class/net/$_netif/address" ] \
|
|
|
|
|| return 1
|
|
|
|
|
|
|
|
echo "HWADDR=\"$(cat /sys/class/net/$_netif/address)\""
|
|
|
|
}
|
|
|
|
|
|
|
|
interface_bind() {
|
|
|
|
local _netif="$1"
|
|
|
|
local _macaddr="$2"
|
|
|
|
|
|
|
|
# see, if we can bind it to some hw parms
|
|
|
|
if hw_bind "$_netif" "$_macaddr"; then
|
|
|
|
# only print out DEVICE, if it's user assigned
|
|
|
|
is_kernel_ethernet_name "$_netif" && return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "DEVICE=\"$_netif\""
|
|
|
|
}
|
|
|
|
|
|
|
|
for netup in /tmp/net.*.did-setup ; do
|
|
|
|
[ -f $netup ] || continue
|
|
|
|
|
|
|
|
netif=${netup%%.did-setup}
|
|
|
|
netif=${netif##*/net.}
|
Specify strstr tightly, add strglob/strglobin.
By convention, strstr should be a literal string match. Previously, it
would match as a glob pattern. Some code used that, so add new
functions strglob and strglobin to do what that code expects, and
specify them tightly too. strglob tests whether the glob pattern
matches the entire string (the name strglob is also used in the yorick
language, and that's what it does there), while strglobin tests whether
the glob pattern matches anywhere in the string.
Also tightens str_starts, str_ends, and str_replace to deal with
literal strings only. In a quick grep I did not find code that depended
on these functions matching globs.
Changes the call sites where strstr was used with glob patterns to use
strglobin or strglob as the intention seemed to be (or, in one case,
strstr with the * removed as it did not affect the result anyway).
11 years ago
|
|
|
strglobin "$netif" ":*:*:*:*:" && continue
|
|
|
|
[ -e /tmp/ifcfg/ifcfg-$netif ] && continue
|
|
|
|
unset bridge
|
|
|
|
unset bond
|
|
|
|
unset bondslaves
|
|
|
|
unset bondname
|
|
|
|
unset bondoptions
|
|
|
|
unset bridgename
|
|
|
|
unset bridgeslaves
|
|
|
|
unset team
|
|
|
|
unset uuid
|
|
|
|
unset ip
|
|
|
|
unset gw
|
|
|
|
unset mtu
|
|
|
|
unset mask
|
|
|
|
unset macaddr
|
|
|
|
unset slave
|
|
|
|
unset ethname
|
|
|
|
unset vlan
|
|
|
|
unset vlanname
|
|
|
|
unset phydevice
|
|
|
|
|
|
|
|
[ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
|
|
|
|
[ -e /tmp/bridge.${netif}.info ] && . /tmp/bridge.${netif}.info
|
|
|
|
[ -e /tmp/team.${netif}.info ] && . /tmp/team.${netif}.info
|
|
|
|
|
|
|
|
uuid=$(cat /proc/sys/kernel/random/uuid)
|
|
|
|
if [ "$netif" = "$bridgename" ]; then
|
|
|
|
bridge=yes
|
|
|
|
elif [ "$netif" = "$teammaster" ]; then
|
|
|
|
team=yes
|
|
|
|
elif [ "$netif" = "$bondname" ]; then
|
|
|
|
# $netif can't be bridge and bond at the same time
|
|
|
|
bond=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in /tmp/vlan.${netif}.*; do
|
|
|
|
[ ! -e "$i" ] && continue
|
|
|
|
. "$i"
|
|
|
|
vlan=yes
|
|
|
|
break
|
|
|
|
done
|
|
|
|
|
|
|
|
# skip team interfaces for now, the host config must be in sync
|
|
|
|
[ "$netif" = "$teammaster" ] && continue
|
|
|
|
|
|
|
|
{
|
|
|
|
echo "# Generated by dracut initrd"
|
|
|
|
echo "NAME=\"$netif\""
|
|
|
|
[ -z "$vlan" ] && interface_bind "$netif" "$macaddr"
|
|
|
|
echo "ONBOOT=yes"
|
|
|
|
echo "NETBOOT=yes"
|
|
|
|
echo "UUID=\"$uuid\""
|
|
|
|
strstr "$(ip -6 addr show dev $netif)" 'inet6' && echo "IPV6INIT=yes"
|
|
|
|
if [ -f /tmp/dhclient.$netif.lease ]; then
|
|
|
|
[ -f /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
|
|
|
|
if [ -f /tmp/net.$netif.has_ibft_config ]; then
|
|
|
|
echo "BOOTPROTO=ibft"
|
|
|
|
else
|
|
|
|
echo "BOOTPROTO=dhcp"
|
|
|
|
fi
|
|
|
|
cp /tmp/dhclient.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
|
|
|
|
else
|
|
|
|
# If we've booted with static ip= lines, the override file is there
|
|
|
|
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
|
Specify strstr tightly, add strglob/strglobin.
By convention, strstr should be a literal string match. Previously, it
would match as a glob pattern. Some code used that, so add new
functions strglob and strglobin to do what that code expects, and
specify them tightly too. strglob tests whether the glob pattern
matches the entire string (the name strglob is also used in the yorick
language, and that's what it does there), while strglobin tests whether
the glob pattern matches anywhere in the string.
Also tightens str_starts, str_ends, and str_replace to deal with
literal strings only. In a quick grep I did not find code that depended
on these functions matching globs.
Changes the call sites where strstr was used with glob patterns to use
strglobin or strglob as the intention seemed to be (or, in one case,
strstr with the * removed as it did not affect the result anyway).
11 years ago
|
|
|
if strglobin "$ip" '*:*:*'; then
|
|
|
|
echo "IPV6INIT=yes"
|
|
|
|
echo "IPV6_AUTOCONF=no"
|
|
|
|
echo "IPV6ADDR=\"$ip/$mask\""
|
|
|
|
else
|
|
|
|
if [ -f /tmp/net.$netif.has_ibft_config ]; then
|
|
|
|
echo "BOOTPROTO=ibft"
|
|
|
|
else
|
|
|
|
echo "BOOTPROTO=none"
|
|
|
|
echo "IPADDR=\"$ip\""
|
|
|
|
if strstr "$mask" "."; then
|
|
|
|
echo "NETMASK=\"$mask\""
|
|
|
|
else
|
|
|
|
echo "PREFIX=\"$mask\""
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
Specify strstr tightly, add strglob/strglobin.
By convention, strstr should be a literal string match. Previously, it
would match as a glob pattern. Some code used that, so add new
functions strglob and strglobin to do what that code expects, and
specify them tightly too. strglob tests whether the glob pattern
matches the entire string (the name strglob is also used in the yorick
language, and that's what it does there), while strglobin tests whether
the glob pattern matches anywhere in the string.
Also tightens str_starts, str_ends, and str_replace to deal with
literal strings only. In a quick grep I did not find code that depended
on these functions matching globs.
Changes the call sites where strstr was used with glob patterns to use
strglobin or strglob as the intention seemed to be (or, in one case,
strstr with the * removed as it did not affect the result anyway).
11 years ago
|
|
|
if strglobin "$gw" '*:*:*'; then
|
|
|
|
echo "IPV6_DEFAULTGW=\"$gw\""
|
|
|
|
elif [ -n "$gw" ]; then
|
|
|
|
echo "GATEWAY=\"$gw\""
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
[ -n "$mtu" ] && echo "MTU=\"$mtu\""
|
|
|
|
} > /tmp/ifcfg/ifcfg-$netif
|
|
|
|
|
|
|
|
# bridge needs different things written to ifcfg
|
|
|
|
if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ] && [ -z "$team" ]; then
|
|
|
|
# standard interface
|
|
|
|
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$netif
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$vlan" ] ; then
|
|
|
|
{
|
|
|
|
echo "TYPE=Vlan"
|
|
|
|
echo "DEVICE=\"$netif\""
|
|
|
|
echo "VLAN=yes"
|
|
|
|
echo "PHYSDEV=\"$phydevice\""
|
|
|
|
} >> /tmp/ifcfg/ifcfg-$netif
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$bond" ] ; then
|
|
|
|
# bond interface
|
|
|
|
{
|
|
|
|
# This variable is an indicator of a bond interface for initscripts
|
|
|
|
echo "BONDING_OPTS=\"$bondoptions\""
|
|
|
|
echo "NAME=\"$netif\""
|
|
|
|
echo "TYPE=Bond"
|
|
|
|
} >> /tmp/ifcfg/ifcfg-$netif
|
|
|
|
|
|
|
|
for slave in $bondslaves ; do
|
|
|
|
# write separate ifcfg file for the raw eth interface
|
|
|
|
(
|
|
|
|
echo "# Generated by dracut initrd"
|
|
|
|
echo "NAME=\"$slave\""
|
|
|
|
echo "TYPE=Ethernet"
|
|
|
|
echo "ONBOOT=yes"
|
|
|
|
echo "NETBOOT=yes"
|
|
|
|
echo "SLAVE=yes"
|
|
|
|
echo "MASTER=\"$netif\""
|
|
|
|
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
|
|
|
|
unset macaddr
|
|
|
|
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
|
|
|
|
interface_bind "$slave" "$macaddr"
|
|
|
|
) >> /tmp/ifcfg/ifcfg-$slave
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$bridge" ] ; then
|
|
|
|
# bridge
|
|
|
|
{
|
|
|
|
echo "TYPE=Bridge"
|
|
|
|
echo "NAME=\"$netif\""
|
|
|
|
} >> /tmp/ifcfg/ifcfg-$netif
|
|
|
|
for slave in $bridgeslaves ; do
|
|
|
|
# write separate ifcfg file for the raw eth interface
|
|
|
|
(
|
|
|
|
echo "# Generated by dracut initrd"
|
|
|
|
echo "NAME=\"$slave\""
|
|
|
|
echo "TYPE=Ethernet"
|
|
|
|
echo "ONBOOT=yes"
|
|
|
|
echo "NETBOOT=yes"
|
|
|
|
echo "BRIDGE=\"$bridgename\""
|
|
|
|
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
|
|
|
|
unset macaddr
|
|
|
|
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
|
|
|
|
interface_bind "$slave" "$macaddr"
|
|
|
|
) >> /tmp/ifcfg/ifcfg-$slave
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
i=1
|
|
|
|
for ns in $(getargs nameserver); do
|
|
|
|
echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
|
|
|
|
i=$((i+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
[ -f /tmp/net.route6."$netif" ] && cp /tmp/net.route6."$netif" /tmp/ifcfg/route6-"$netif"
|
|
|
|
[ -f /tmp/net.route."$netif" ] && cp /tmp/net.route."$netif" /tmp/ifcfg/route-"$netif"
|
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.
16 years ago
|
|
|
done
|
|
|
|
|
|
|
|
# Pass network opts
|
|
|
|
mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
|
|
|
|
mkdir -m 0755 -p /run/initramfs/state/var/lib/dhclient
|
|
|
|
echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
|
|
|
|
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
|
|
|
|
{
|
|
|
|
cp /tmp/net.* /run/initramfs/
|
|
|
|
cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
|
|
|
|
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
|
|
|
|
cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
|
|
|
|
} > /dev/null 2>&1
|