Repository: ceph/ceph-nvmeof (language: python)

Issue:
We cant have a listener for all available addresses
When we add a listener to the system we must use the specific address is listens on. SPDK wouldn't let us to use INADDR_ANY (that is, 0.0.0.0) as an address and allow connection for each and every interface. This can be solved by applying the following change to SPDK:

```
diff --git a/lib/nvme/nvme.c b/lib/nvme/nvme.c
index 5b08198b0..97b3997a0 100644
--- a/lib/nvme/nvme.c
+++ b/lib/nvme/nvme.c
@@ -1453,9 +1453,18 @@ spdk_nvme_transport_id_compare(const struct spdk_nvme_transport_id *trid1,
                return spdk_pci_addr_compare(&pci_addr1, &pci_addr2);
        }

-       cmp = strcasecmp(trid1->traddr, trid2->traddr);
-       if (cmp) {
-               return cmp;
+       if (trid1->trtype == SPDK_NVME_TRANSPORT_TCP &&
+               ((trid1->adrfam == SPDK_NVMF_ADRFAM_IPV4 && strcasecmp(trid1->traddr, "0.0.0.0") == 0) ||
+               (trid1->adrfam == SPDK_NVMF_ADRFAM_IPV6 && strcasecmp(trid1->traddr, "::") == 0))) {
+
+               /* If the listener uses INADDR_ANY allow all IP addresses */
+               cmp = 0;
+       }
+       else {
+               cmp = strcasecmp(trid1->traddr, trid2->traddr);
+               if (cmp) {
+                       return cmp;
+               }
        }

        cmp = cmp_int(trid1->adrfam, trid2->adrfam);
```


Discussion / hints:

Fix patch:
diff --git a/mk/demo.mk b/mk/demo.mk
index 2d9a3769..d18b07c7 100644
--- a/mk/demo.mk
+++ b/mk/demo.mk
@@ -1,12 +1,14 @@
 ## Demo:
 
 HOSTNQN=`cat /etc/nvme/hostnqn`
+NVMEOF_IO_PORT2=`expr $(NVMEOF_IO_PORT) + 1`
 # demo
 demo:
 	$(NVMEOF_CLI) subsystem add --subsystem $(NQN) --no-group-append
 	$(NVMEOF_CLI) namespace add --subsystem $(NQN) --rbd-pool $(RBD_POOL) --rbd-image $(RBD_IMAGE_NAME) --size $(RBD_IMAGE_SIZE) --rbd-create-image
 	$(NVMEOF_CLI) namespace add --subsystem $(NQN) --rbd-pool $(RBD_POOL) --rbd-image $(RBD_IMAGE_NAME)2 --size $(RBD_IMAGE_SIZE) --rbd-create-image --no-auto-visible
 	$(NVMEOF_CLI) listener add --subsystem $(NQN) --host-name `docker ps -q -f name=$(NVMEOF_CONTAINER_NAME)` --traddr $(NVMEOF_IP_ADDRESS) --trsvcid $(NVMEOF_IO_PORT)
+	$(NVMEOF_CLI) listener add --subsystem $(NQN) --host-name `docker ps -q -f name=$(NVMEOF_CONTAINER_NAME)` --traddr 0.0.0.0 --trsvcid $(NVMEOF_IO_PORT2)
 	$(NVMEOF_CLI_IPV6) listener add --subsystem $(NQN) --host-name `docker ps -q -f name=$(NVMEOF_CONTAINER_NAME)` --traddr $(NVMEOF_IPV6_ADDRESS) --trsvcid $(NVMEOF_IO_PORT) --adrfam IPV6
 	$(NVMEOF_CLI) host add --subsystem $(NQN) --host-nqn "*"
 	$(NVMEOF_CLI) namespace add_host --subsystem $(NQN) --nsid 2 --host-nqn $(HOSTNQN)
diff --git a/spdk b/spdk
index c2c28068..ef5d1aeb 160000
--- a/spdk
+++ b/spdk
@@ -1,1 +1,1 @@
-Subproject commit c2c2806866626f37faff8273cf656a0e05afc23a
+Subproject commit ef5d1aebfedc30965e5c416da00015d73ad3bf62


Test patch:
diff --git a/tests/ha/demo_test.sh b/tests/ha/demo_test.sh
index a656889e..208f185b 100755
--- a/tests/ha/demo_test.sh
+++ b/tests/ha/demo_test.sh
@@ -7,7 +7,7 @@ function cephnvmf_func()
 
 function demo_test_unsecured()
 {
-    make demo OPTS=-T
+    make demo OPTS=-T NVMEOF_IO_PORT2=${port2}
     return $?
 }
 
@@ -125,8 +125,39 @@ function demo_bdevperf_unsecured()
     [[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
     [[ `echo $conns | jq -r '.connections[1]'` == "null" ]]
 
-    echo "ℹ️  bdevperf detach controller"
+    echo "ℹ️  bdevperf tcp connect ip: $NVMEOF_IP_ADDRESS port: ${port2} nqn: $NQN, using any host listener"
+    localhostnqn=`cat /etc/nvme/hostnqn`
+    devs=`make exec -s SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme1 -t tcp -a $NVMEOF_IP_ADDRESS -s ${port2} -f ipv4 -n $NQN -q $localhostnqn -l -1 -o 10"`
+
+    echo "ℹ️  verify connection list"
+    conns=$(cephnvmf_func --output stdio --format json connection list --subsystem $NQN)
+    [[ `echo $conns | jq -r '.status'` == "0" ]]
+    [[ `echo $conns | jq -r '.subsystem_nqn'` == "${NQN}" ]]
+    [[ `echo $conns | jq -r '.connections[0].nqn'` == "${localhostnqn}" ]]
+    [[ `echo $conns | jq -r '.connections[0].trsvcid'` == "${NVMEOF_IO_PORT}" ]]
+    [[ `echo $conns | jq -r '.connections[0].traddr'` == "${NVMEOF_IP_ADDRESS}" ]]
+    [[ `echo $conns | jq -r '.connections[0].adrfam'` == "ipv4" ]]
+    [[ `echo $conns | jq -r '.connections[0].trtype'` == "TCP" ]]
+    [[ `echo $conns | jq -r '.connections[0].connected'` == "true" ]]
+    [[ `echo $conns | jq -r '.connections[0].qpairs_count'` == "1" ]]
+    [[ `echo $conns | jq -r '.connections[0].secure'` == "false" ]]
+    [[ `echo $conns | jq -r '.connections[0].use_psk'` == "false" ]]
+    [[ `echo $conns | jq -r '.connections[0].use_dhchap'` == "false" ]]
+    [[ `echo $conns | jq -r '.connections[1].nqn'` == "${localhostnqn}" ]]
+    [[ `echo $conns | jq -r '.connections[1].trsvcid'` == "${port2}" ]]
+    [[ `echo $conns | jq -r '.connections[1].traddr'` == "${NVMEOF_IP_ADDRESS}" ]]
+    [[ `echo $conns | jq -r '.connections[1].adrfam'` == "ipv4" ]]
+    [[ `echo $conns | jq -r '.connections[1].trtype'` == "TCP" ]]
+    [[ `echo $conns | jq -r '.connections[1].connected'` == "true" ]]
+    [[ `echo $conns | jq -r '.connections[1].qpairs_count'` == "1" ]]
+    [[ `echo $conns | jq -r '.connections[1].secure'` == "false" ]]
+    [[ `echo $conns | jq -r '.connections[1].use_psk'` == "false" ]]
+    [[ `echo $conns | jq -r '.connections[1].use_dhchap'` == "false" ]]
+    [[ `echo $conns | jq -r '.connections[2]'` == "null" ]]
+
+    echo "ℹ️  bdevperf detach controllers"
     make exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_detach_controller Nvme0"
+    make exec SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_detach_controller Nvme1"
 
     echo "ℹ️  bdevperf tcp connect ip: $NVMEOF_IPV6_ADDRESS port: $NVMEOF_IO_PORT nqn: $NQN, using IPv6"
     make exec -s SVC=bdevperf OPTS=-T CMD="$rpc -v -s $BDEVPERF_SOCKET bdev_nvme_attach_controller -b Nvme1 -t tcp -a $NVMEOF_IPV6_ADDRESS -s $NVMEOF_IO_PORT -f ipv6 -n $NQN -q $localhostnqn -l -1 -o 10"