forked from Mellanox/mlnx-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mlnx_net_rules: Handle case when interface names are empty
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
1 parent
0f8bf94
commit a4d3462
Showing
1 changed file
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|