Skip to content

Commit

Permalink
mlnx_net_rules: Handle case when interface names are empty
Browse files Browse the repository at this point in the history
Added workaround for Ubuntu 18.04 on BlueField where the script receives empty interface names
when device in the "Separated" mode.

Signed-off-by: Vladimir Sokolovsky <[email protected]>
  • Loading branch information
vladsokolovsky committed Oct 7, 2019
1 parent 0f8bf94 commit a4d3462
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions kernel-boot/mlnx_net_rules
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
#!/bin/bash
#
# Copyright (c) 2019 Mellanox Technologies. All rights reserved.
#
# This Software is licensed under one of the following licenses:
#
# 1) under the terms of the "Common Public License 1.0" a copy of which is
# available from the Open Source Initiative, see
# http://www.opensource.org/licenses/cpl.php.
#
# 2) under the terms of the "The BSD License" a copy of which is
# available from the Open Source Initiative, see
# http://www.opensource.org/licenses/bsd-license.php.
#
# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
# copy of which is available from the Open Source Initiative, see
# http://www.opensource.org/licenses/gpl-license.php.
#
# Licensee has the right to choose one of the above licenses.
#
# Redistributions of source code must retain the above copyright
# notice and one of the license notices.
#
# Redistributions in binary form must reproduce both the above copyright
# notice, one of the license notices in the documentation
# and/or other materials provided with the distribution.
#
# Author: Vladimir Sokolovsky <[email protected]>
#

net_if=$1
shift
Expand All @@ -9,9 +37,32 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin

is_bf=`lspci -s 00:00.0 2> /dev/null | grep -wq "PCI bridge: Mellanox Technologies" && echo 1 || echo 0`

configure_if()
{
case "$net_if" in
lo)
return
;;
esac

logger -i "$APP: Bringing up interface $1"
/sbin/ip link set dev $1 up
if [ "$1" != "tmfifo_net0" ]; then
/sbin/ethtool -L $1 combined 4
fi
}

if [ $is_bf -eq 1 ]; then
logger -i "$APP: Bringing up interface $net_if"
/sbin/ip link set dev $net_if up
/sbin/ethtool -L $net_if combined 4
if [[ -z "$net_if" || ! -d /sys/class/net/$net_if ]]; then
# Interface was renamed or empty
cd /sys/class/net
for net_if in *
do
configure_if $net_if
done

exit 0
fi
configure_if $net_if
fi

0 comments on commit a4d3462

Please sign in to comment.