diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2018-08-05 05:36:43 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2018-08-05 05:36:43 +0200 |
commit | 05fb73ec16329981d5b3170e23fcbefaa89b71b6 (patch) | |
tree | 9f2d5c6dfcd4dc6f48f8a6f9ccaf5076f5ac58cc /ip/functions.sh | |
parent | 75e98276848f84166f3245f9e242f3f259f93081 (diff) | |
download | mlx-05fb73ec16329981d5b3170e23fcbefaa89b71b6.tar.gz mlx-05fb73ec16329981d5b3170e23fcbefaa89b71b6.tar.bz2 mlx-05fb73ec16329981d5b3170e23fcbefaa89b71b6.tar.xz mlx-05fb73ec16329981d5b3170e23fcbefaa89b71b6.zip |
Add helper functions
Diffstat (limited to 'ip/functions.sh')
-rw-r--r-- | ip/functions.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ip/functions.sh b/ip/functions.sh new file mode 100644 index 0000000..2941953 --- /dev/null +++ b/ip/functions.sh @@ -0,0 +1,29 @@ +function portset { + pci=$1 + mode=$2 + ./connectx_port_config -d "$pci" -c "$mode,$mode" &> /dev/null +} + +function mlxconf { + mode=$1 + + pci=$(./connectx_port_config -s | grep PCI | grep -Po "\d{4}:\d{2}:\d{2}\.\d") + for dev in $pci; do + echo "Configuring: $dev" + portset $dev $mode + done +} + +function ipset { + int="$1" + ip="$2" + + if [ -n "$ip" ]; then + ip link set "$int" up + ip addr flush "$int" + ip addr show dev "$int" | grep "$ip" || ip addr add "$ip/24" dev "$int" + else + ip addr flush "$int" + ip link set "$int" down + fi +} |