On 07/21/14 at 04:38pm, Vivek Goyal wrote:
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".
Right. Will add.
[..]
> +kdump_setup_ifname() {
Put few lines of comment before function mentioning why we need to
prefix kdump- when kernel assigned names are being used.
Will do.
> + 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?
I'm not supposed to do that. I'll use another variable, say _kdumpdev,
to denote the "kdump-" prefixed name.
> 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.
Will do.
> 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.
Yep, will use _kdumpdev.
Thanks for review!
WANG Chao