ifcfg/write-ifcfg.sh: bind bond and bridge interfaces to HW

either by s390 SUBCHANNELS or HWADDR, if the interface name is not
persistent.

Previously, this was bound unconditionally with HWADDR.
master
Harald Hoyer 2014-09-12 09:48:00 +02:00
parent 37383f7123
commit 80043e21c1
1 changed files with 26 additions and 21 deletions

View File

@ -80,6 +80,20 @@ print_s390() {
return 0 return 0
} }


interface_bind() {
local netif="$1"
local macaddr="$2"
if ! print_s390 $netif; then
if [ -z "$macaddr" ] && \
! is_persistent_ethernet_name "$netif" && \
[ -f /sys/class/net/$netif/addr_assign_type ] && \
[ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] && \
[ -f /sys/class/net/$netif/address ]; then
echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
fi
fi
}

for netup in /tmp/net.*.did-setup ; do for netup in /tmp/net.*.did-setup ; do
[ -f $netup ] || continue [ -f $netup ] || continue


@ -112,8 +126,7 @@ for netup in /tmp/net.*.did-setup ; do
if [ "$netif" = "$vlanname" ]; then if [ "$netif" = "$vlanname" ]; then
vlan=yes vlan=yes
fi fi
[ -e /sys/class/net/$netif/address ] && \
cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
{ {
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=\"$netif\"" echo "DEVICE=\"$netif\""
@ -163,15 +176,7 @@ for netup in /tmp/net.*.did-setup ; do
# standard interface # standard interface
{ {
[ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\"" [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
if ! print_s390 $netif; then interface_bind "$netif" "$macaddr"
if [ -z "$macaddr" ] && \
! is_persistent_ethernet_name "$netif" && \
[ -f /sys/class/net/$netif/addr_assign_type ] && \
[ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] && \
[ -f /sys/class/net/$netif/address ]; then
echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
fi
fi
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "NAME=\"$netif\"" echo "NAME=\"$netif\""
[ -n "$mtu" ] && echo "MTU=\"$mtu\"" [ -n "$mtu" ] && echo "MTU=\"$mtu\""
@ -198,22 +203,20 @@ for netup in /tmp/net.*.did-setup ; do


for slave in $bondslaves ; do for slave in $bondslaves ; do
# write separate ifcfg file for the raw eth interface # write separate ifcfg file for the raw eth interface
{ (
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=\"$slave\"" echo "DEVICE=\"$slave\""
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "ONBOOT=yes" echo "ONBOOT=yes"
echo "NETBOOT=yes" echo "NETBOOT=yes"
if [ -e /tmp/net.${netif}.${slave}.hwaddr ]; then
echo "HWADDR=\"$(cat /tmp/net.${netif}.${slave}.hwaddr)\""
else
echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
fi
echo "SLAVE=yes" echo "SLAVE=yes"
echo "MASTER=\"$netif\"" echo "MASTER=\"$netif\""
echo "NAME=\"$slave\"" echo "NAME=\"$slave\""
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\"" echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
} >> /tmp/ifcfg/ifcfg-$slave [ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
[ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
interface_bind "$slave" "$macaddr"
) >> /tmp/ifcfg/ifcfg-$slave
done done
fi fi


@ -225,17 +228,19 @@ for netup in /tmp/net.*.did-setup ; do
} >> /tmp/ifcfg/ifcfg-$netif } >> /tmp/ifcfg/ifcfg-$netif
for slave in $bridgeslaves ; do for slave in $bridgeslaves ; do
# write separate ifcfg file for the raw eth interface # write separate ifcfg file for the raw eth interface
{ (
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=\"$slave\"" echo "DEVICE=\"$slave\""
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "ONBOOT=yes" echo "ONBOOT=yes"
echo "NETBOOT=yes" echo "NETBOOT=yes"
echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
echo "BRIDGE=\"$bridgename\"" echo "BRIDGE=\"$bridgename\""
echo "NAME=\"$slave\"" echo "NAME=\"$slave\""
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\"" echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
} >> /tmp/ifcfg/ifcfg-$slave [ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
[ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
interface_bind "$slave" "$macaddr"
) >> /tmp/ifcfg/ifcfg-$slave
done done
fi fi
i=1 i=1