From b7f049070d0bc04195f411f3bccebddc08aded82 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Tue, 10 Apr 2018 08:17:30 -0400 Subject: [PATCH] test/nvmf: update test scripts from ifconfig to iproute2 iproute2 tools are more up to date and offer broader capabilites, thus should be used whenever possible. This change was prompted by "ifconfig -s" cutting interface names, not allowing for ones that are longer than 8 letters. Change-Id: I38462f8498207aa0b0d24d1c0b1769c1ba59f0ea Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.gerrithub.io/407395 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- test/nvmf/common.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index 98596f8b0..d982b022b 100755 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -34,8 +34,7 @@ function detect_soft_roce_nics() if hash rxe_cfg; then rxe_cfg start rdma_nics=$(get_rdma_if_list) - all_nics=$(ifconfig -s | awk '{print $1}') - all_nics=("${all_nics[@]/"Iface"}") + all_nics=$(ip -o link | awk '{print $2}' | cut -d":" -f1) non_rdma_nics=$(echo -e "$rdma_nics\n$all_nics" | sort | uniq -u) for nic in $non_rdma_nics; do if [[ -d /sys/class/net/${nic}/bridge ]]; then @@ -80,7 +79,7 @@ function detect_mellanox_nics() fi # The mlx4 driver takes an extra few seconds to load after modprobe returns, - # otherwise ifconfig operations will do nothing. + # otherwise iproute2 operations will do nothing. sleep 5 } @@ -96,18 +95,19 @@ function allocate_nic_ips() for nic_name in $(get_rdma_if_list); do ip="$(get_ip_address $nic_name)" if [ -z $ip ]; then - ifconfig $nic_name $NVMF_IP_PREFIX.$count netmask 255.255.255.0 up + ip addr add $NVMF_IP_PREFIX.$count/24 dev $nic_name + ip link set $nic_name up let count=$count+1 fi # dump configuration for debug log - ifconfig $nic_name + ip addr show $nic_name done } function get_available_rdma_ips() { for nic_name in $(get_rdma_if_list); do - ifconfig $nic_name | grep "inet " | awk '{print $2}' + get_ip_address $nic_name done } @@ -123,7 +123,7 @@ function get_rdma_if_list() function get_ip_address() { interface=$1 - ifconfig $interface | grep "inet " | awk '{print $2}' | sed 's/[^0-9\.]//g' + ip -o -4 addr show $interface | awk '{print $4}' | cut -d"/" -f1 } function nvmfcleanup() @@ -142,7 +142,7 @@ function rdma_device_init() function revert_soft_roce() { if hash rxe_cfg; then - interfaces="$(ifconfig -s | awk '{print $1}')" + interfaces="$(ip -o link | awk '{print $2}' | cut -d":" -f1)" for interface in $interfaces; do rxe_cfg remove $interface || true done