nvme: add optional ipv6 test flavor
Sagi Grimberg
maintainerPATCH v2 1/1 nvme: add optional ipv6 test flavor
Allow Setting nvme_adrfam=[ipv4|ipv6] and running tests on either address family. Ignored for non IP transports.
Signed-off-by Sagi Grimberg <[email protected]>
---
Changes from v1:
- fix shellcheck
- prefer double brackets
- fix 80-char long line
common/multipath-over-rdma | 10 ++++++++++ tests/nvme/rc | 32 +++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-)
common/multipath-over-rdma +10 -0
@@ -74,6 +74,16 @@ get_ipv6_addr() { sed -n 's/.*[[:blank:]]inet6[[:blank:]]*\([^[:blank:]/]*\).*/\1/p' } +# grab only the link local address +get_ipv6_ll_addr() { + if [[ ! -e "/sys/class/net/$1" ]]; then + echo "get_ipv6_addr(): $1 is not a network interface" 1>&2 + fi + ll_addr=$(ip -6 -o addr show dev "$1" | grep "scope link" | + sed -n 's/.*[[:blank:]]inet6[[:blank:]]*\([^[:blank:]/]*\).*/\1/p') + echo "$ll_addr%$1" +} + # Whether or not $1 is a number. is_number() { [ "$1" -eq "0$1" ] 2>/dev/null
tests/nvme/rc +29 -3
@@ -38,6 +38,25 @@ _nvme_requires() { SKIP_REASON="unsupported nvme_trtype=${nvme_trtype}" return 1 esac + + if [[ -n ${nvme_adrfam} ]]; then + case ${nvme_adrfam} in + ipv6) + def_traddr="::1" + def_adrfam="ipv6" + ;; + ipv4) + ;; # was already set + *) + # ignore for non ip transports + if [[ "${nvme_trtype}" == "tcp" || + "${nvme_trtype}" == "rdma" ]]; then + SKIP_REASON="unsupported nvme_adrfam=${nvme_adrfam}" + return 1 + fi + esac + fi + return 0 }
@@ -148,9 +167,16 @@ _setup_nvmet() { start_soft_rdma for i in $(rdma_network_interfaces) do - ipv4_addr=$(get_ipv4_addr "$i") - if [ -n "${ipv4_addr}" ]; then - def_traddr=${ipv4_addr} + if [[ "${nvme_adrfam}" == "ipv6" ]]; then + ipv6_addr=$(get_ipv6_ll_addr "$i") + if [[ -n "${ipv6_addr}" ]]; then + def_traddr=${ipv6_addr} + fi + else + ipv4_addr=$(get_ipv4_addr "$i") + if [[ -n "${ipv4_addr}" ]]; then + def_traddr=${ipv4_addr} + fi fi done fi
Signature · 1 line
2.34.1
Quoted 5 lines · Sagi Grimberg
Allow Setting nvme_adrfam=[ipv4|ipv6] and running tests on either address family. Ignored for non IP transports.
Signed-off-by Sagi Grimberg <[email protected]>---
thanks for doing, this looks good.
Reviewed-by Chaitanya Kulkarni <[email protected]>
-ck
Quoted 4 lines · Sagi Grimberg
Allow Setting nvme_adrfam=[ipv4|ipv6] and running tests on either address family. Ignored for non IP transports.
Signed-off-by Sagi Grimberg <[email protected]>
Thanks for the v2 update. Applied.
Signature · 1 line
Shin'ichiro Kawasaki