On Mon, Jul 21, 2014 at 05:42:03PM +0800, WANG Chao wrote:
We met a problem that eth0 ends up being eth1 and eth1 being eth0
between 1st and 2nd kernel. Because we pass ifname=eth0:$mac to force
it's named eth0 and since "eth0"is already taken by the other NIC, udev
fails to bring up the NIC we want, thus kdump fails.
For ethX, we put a prefix "kdump-" before it, so in 2nd kernel, ethX
will name to "kdump-ethX". So that we can avoid the naming conflict.
We only need to change the ethernet card name, that means, for bridge,
vlan, bond, team devices' names , we never prefix them. Because these
names are assigned when they're created by userspace.
Signed-off-by: WANG Chao <chaowang(a)redhat.com>
Hi Chao,
It will help if we also mention that "kernel assigned network interface
names are not persistent. So if first kernel is using kernel assigned
interface names, then force it to use kdump- prefixed names in second
kernel".
Few comments inline.
Thanks
Vivek
---
dracut-module-setup.sh | 50 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 87ad072..2fcfd21 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -97,9 +97,21 @@ kdump_get_perm_addr() {
fi
}
+kdump_setup_ifname() {
Put few lines of comment before function mentioning why we need to
prefix kdump- when kernel assigned names are being used.
+ local _ifname
+
+ if [[ $1 =~ eth* ]]; then
+ _ifname="kdump-$1"
+ else
+ _ifname="$1"
+ fi
+
+ echo "$_ifname"
+}
+
kdump_setup_bridge() {
local _netdev=$1
- local _brif _dev
+ local _brif _dev _mac
for _dev in `ls /sys/class/net/$_netdev/brif/`; do
if kdump_is_bond "$_dev"; then
kdump_setup_bond "$_dev"
@@ -108,7 +120,9 @@ kdump_setup_bridge() {
elif kdump_is_vlan "$_dev"; then
kdump_setup_vlan "$_dev"
else
- echo -n " ifname=$_dev:$(kdump_get_mac_addr $_dev)" >>
${initdir}/etc/cmdline.d/41bridge.conf
+ _mac=$(kdump_get_mac_addr $_dev)
+ _dev=$(kdump_setup_ifname $_dev)
+ echo -n " ifname=$_dev:$_mac" >>
${initdir}/etc/cmdline.d/41bridge.conf
fi
_brif+="$_dev,"
done
@@ -117,11 +131,14 @@ kdump_setup_bridge() {
kdump_setup_bond() {
local _netdev=$1
- local _dev
+ local _dev _mac _slaves
for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do
- echo -n " ifname=$_dev:$(kdump_get_perm_addr $_dev)" >>
${initdir}/etc/cmdline.d/42bond.conf
+ _mac=$(kdump_get_perm_addr $_dev)
+ _dev=$(kdump_setup_ifname $_dev)
+ echo -n " ifname=$_dev:$_mac" >>
${initdir}/etc/cmdline.d/42bond.conf
+ _slaves+="$_dev,"
done
- echo -n " bond=$_netdev:$(sed -e 's/ /,/g'
/sys/class/net/$_netdev/bonding/slaves)" >>
${initdir}/etc/cmdline.d/42bond.conf
+ echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >>
${initdir}/etc/cmdline.d/42bond.conf
# Get bond options specified in ifcfg
. /etc/sysconfig/network-scripts/ifcfg-$_netdev
bondoptions="$(echo :$BONDING_OPTS | sed 's/\s\+/,/')"
@@ -130,10 +147,12 @@ kdump_setup_bond() {
kdump_setup_team() {
local _netdev=$1
- local slaves _dev
+ local _dev _mac _slaves
for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do
- echo -n " ifname=$_dev:$(kdump_get_perm_addr $_dev)" >>
${initdir}/etc/cmdline.d/44team.conf
- slaves+="$_dev,"
+ _mac=$(kdump_get_perm_addr $_dev)
+ _dev=$(kdump_setup_ifname $_dev)
+ echo -n " ifname=$_dev:$_mac" >>
${initdir}/etc/cmdline.d/44team.conf
+ _slaves+="$_dev,"
So one can modify _dev in for loop without impacting the loop?
done
echo " team=$_netdev:$(echo $slaves | sed -e 's/,$//')" >>
${initdir}/etc/cmdline.d/44team.conf
#Buggy version teamdctl outputs to stderr!
@@ -153,8 +172,7 @@ kdump_setup_vlan() {
local _netdev=$1
local _phydev="$(awk '/^Device:/{print $2}'
/proc/net/vlan/"$_netdev")"
local _netmac="$(kdump_get_mac_addr $_phydev)"
-
- echo " vlan=$_netdev:$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf
+ local _dev
#Just support vlan over bond, it is not easy
#to support all other complex setup
@@ -166,8 +184,10 @@ kdump_setup_vlan() {
exit 1
elif kdump_is_bond "$_phydev"; then
kdump_setup_bond "$_phydev"
+ echo " vlan=$_netdev:$_phydev" >
${initdir}/etc/cmdline.d/43vlan.conf
You moved this line from above to here, is it a fix? If yes, please keep
it in a separate patch.
else
- echo " vlan=$_netdev:$_phydev ifname=$_phydev:$_netmac" >
${initdir}/etc/cmdline.d/43vlan.conf
+ local _dev="$(kdump_setup_ifname $_phydev)"
You already declared _dev local. Secondly, how about calling it _kdumpdev.
+ echo " vlan=$_netdev:$_dev ifname=$_dev:$_netmac"
> ${initdir}/etc/cmdline.d/43vlan.conf
fi
}
@@ -200,7 +220,7 @@ kdump_setup_netdev() {
fi
_ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
- _ip_opts=" ip=${_static}$_netdev:${_proto}"
+ _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
# dracut doesn't allow duplicated configuration for same NIC, even they're
exactly the same.
# so we have to avoid adding duplicates
@@ -217,7 +237,7 @@ kdump_setup_netdev() {
elif kdump_is_vlan "$_netdev"; then
kdump_setup_vlan "$_netdev"
else
- _ifname_opts=" ifname=$_netdev:$(kdump_get_mac_addr $_netdev)"
+ _ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$(kdump_get_mac_addr
$_netdev)"
echo "$_ifname_opts" >> $_ip_conf
fi
@@ -262,8 +282,8 @@ kdump_install_net() {
# gateway.
if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
- echo "kdumpnic=${_netdev}" >
${initdir}/etc/cmdline.d/60kdumpnic.conf
- echo "bootdev=${_netdev}" >
${initdir}/etc/cmdline.d/70bootdev.conf
+ echo "kdumpnic=$(kdump_setup_ifname $_netdev)" >
${initdir}/etc/cmdline.d/60kdumpnic.conf
+ echo "bootdev=$(kdump_setup_ifname $_netdev)" >
${initdir}/etc/cmdline.d/70bootdev.conf
fi
}
--
1.9.3
_______________________________________________
kexec mailing list
kexec(a)lists.fedoraproject.org
https://lists.fedoraproject.org/mailman/listinfo/kexec