IPv6 network portal creation had been failing in:
/sys/kernel/config/target/iscsi/$IQN/$TPGT/np/[ipv6]:port
because lio_target_call_addnptotpg() was not properly stripping off
the "[" and "]" for the IPv6 address. This patch allows IPv6 network
portals to be successfully created, as well as enabling SCTP IPv6 when
using the sctp flag:
echo 1 > /sys/kernel/config/target/iscsi/$IQN/$TPGT/np/[ipv6]:port/sctp
Signed-off-by: Nicholas A. Bellinger <n...@linux-iscsi.org>
---
drivers/lio-core/iscsi_target_configfs.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/lio-core/iscsi_target_configfs.c b/drivers/lio-core/iscsi_target_configfs.c
index 71e8d2a..0a9b902 100644
--- a/drivers/lio-core/iscsi_target_configfs.c
+++ b/drivers/lio-core/iscsi_target_configfs.c
@@ -273,11 +273,19 @@ static struct config_group *lio_target_call_addnptotpg (
" in IPv6 iSCSI network portal address\n");
return(ERR_PTR(-EINVAL));
}
- str2 += 1; /* Skip over the "]" */
+ str++; /* Skip over leading "[" */
*str2 = '\0'; /* Terminate the IPv6 address */
- str2 += 1; /* Set str2 to port */
- np_addr.np_port = simple_strtoul(str2, &end_ptr, 0);
- snprintf(np_addr.np_ipv6, IPV6_ADDRESS_SPACE, "%s\n", str);
+ str2 += 1; /* Skip over the "]" */
+ if (!(port_str = strstr(str2, ":"))) {
+ printk(KERN_ERR "Unable to locate \":port\""
+ " in IPv6 iSCSI network portal address\n");
+ return(ERR_PTR(-EINVAL));
+ }
+ *port_str = '\0'; /* Terminate string for IP */
+ port_str += 1; /* Skip over ":" */
+ np_addr.np_port = simple_strtoul(port_str, &end_ptr, 0);
+
+ snprintf(np_addr.np_ipv6, IPV6_ADDRESS_SPACE, "%s", str);
np_addr.np_flags |= NPF_NET_IPV6;
} else {
ip_str = &buf[0];
--
1.5.4.1