open-iscsi / target-isns

Target-isns is an iSNS client for the Linux LIO iSCSI target
GNU General Public License v2.0
16 stars 19 forks source link

Port is 0 on Windows Server 2008 R2 iSNS server and as read by wireshark #1

Closed dwalkes closed 10 years ago

dwalkes commented 10 years ago

Hi, Thanks for creating this project!

We've tested with a Windows 2008 R2 iSNS server and noticed that all targets were listed with port 0 as the port number instead of 3260. We captured a wireshark trace and compared to another iSNS target and noticed the port was little endian in our case and big endian in the working case. The following patch fixed the issue for us:

diff --git a/src/isns.c b/src/isns.c
index 0f9e0e8..0e898d8 100644
--- a/src/isns.c
+++ b/src/isns.c
@@ -354,7 +354,7 @@ int isns_target_register(char *name)
        uint16_t flags = 0, length = 0;
        struct isns_hdr *hdr = (struct isns_hdr *) buf;
        struct isns_tlv *tlv;
-       uint32_t port = 3260; /* FIXME: */
+       uint32_t port = htonl(3260); /* FIXME: */
        uint32_t node = htonl(ISNS_NODE_TARGET);
        uint32_t type = htonl(2);
        int err;

I'm a little confused because based on a quick glance at RFC 4171 section 6.3.2 (http://tools.ietf.org/html/rfc4171#section-6.3.2) I would have expected a shift to be required, however we confirmed that the implementation matches the working iSNS target when implemented as above and the value passed to htonl is the one displayed in the Windows iSNS server as the port number for each target.

Thanks again for creating the project.

cvubrugier commented 10 years ago

Hi dwalkes,

Sorry for the late reply. Could you please send a pull request? I want you to get proper attribution for your work.

dwalkes commented 10 years ago

Thanks, I believe I've just sent a pull request.