[stgt] [PATCH 10/14] tgt: Fix call to getnameinfo() on None Linux systems
Boaz Harrosh
bharrosh at panasas.com
Mon Feb 23 19:05:48 CET 2009
Systems other then Linux are more picky with the addr length
passed to getnameinfo. They expect it to be set from the
returned length of the call to getsockname.
Also added a couple of dprints in error cases.
Signed-off-by: Boaz Harrosh <bharrosh at panasas.com>
---
usr/iscsi/iscsid.c | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index bfaec87..dca926e 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -743,6 +743,7 @@ static void text_scan_text(struct iscsi_connection *conn)
{
char *key, *value, *data;
int datasize;
+ int ret;
data = conn->req.data;
datasize = conn->req.datasize;
@@ -760,22 +761,37 @@ static void text_scan_text(struct iscsi_connection *conn)
blen = sizeof(buf);
slen = sizeof(ss);
- conn->tp->ep_getsockname(conn, (struct sockaddr *) &ss,
- &slen);
+ ret = conn->tp->ep_getsockname(conn,
+ (struct sockaddr *) &ss, &slen);
+ if (ret)
+ eprintf("getsockname Faild=>%d\n", ret);
+
if (ss.ss_family == AF_INET6) {
*p++ = '[';
blen--;
}
+#ifndef __MAKE_TGT_ON_BSD__
slen = sizeof(ss);
- getnameinfo((struct sockaddr *) &ss, slen, p, blen,
- NULL, 0, NI_NUMERICHOST);
+#else
+ slen = ((struct sockaddr *)&ss)->sa_len;
+#endif
+ ret = getnameinfo((struct sockaddr *) &ss, slen, p,
+ blen, NULL, 0, NI_NUMERICHOST);
+ if (ret) {
+ eprintf("getnameinfo Faild=>%d: %s\n",
+ ret, gai_strerror(ret));
+ /* Let failure show in target traces */
+ strcpy(p, "getnameinfo_Faild");
+ }
p = buf + strlen(buf);
if (ss.ss_family == AF_INET6)
*p++ = ']';
+ dprintf("getnameinfo => %s\n", buf);
+
sprintf(p, ":%d,1", ISCSI_LISTEN_PORT);
target_list_build(conn, buf,
strcmp(value, "All") ? value : NULL);
@@ -2071,8 +2087,10 @@ again:
case IOSTATE_TX_DATA:
ret = do_send(conn, ddigest ?
IOSTATE_TX_INIT_DDIGEST : IOSTATE_TX_END);
- if (ret < 0)
+ if (ret < 0) {
+ dprintf("do_send => %d\n", ret);
goto out;
+ }
if (conn->tx_iostate != IOSTATE_TX_INIT_DDIGEST)
break;
case IOSTATE_TX_INIT_DDIGEST:
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list