Boaz Harrosh wrote: > 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. Use an > os_getsockname_ss, that is implemented diffrently for BSD > or Linux. > > Both getsockname and getnameinfo might fail check for > errors. > > Also added a couple of eprints in error cases. > > Signed-off-by: Boaz Harrosh <bharrosh@xxxxxxxxxxx> <snip> > diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c > index bfaec87..53b231f 100644 > --- a/usr/iscsi/iscsid.c > +++ b/usr/iscsi/iscsid.c > @@ -39,6 +39,7 @@ > #include "driver.h" > #include "scsi.h" > #include "crc32c.h" > +#include "os.h" > > #define MAX_QUEUE_CMD 128 > > @@ -743,6 +744,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 +762,31 @@ 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); TOMO if you are already experimenting, it might work if &slen is left untouched and is passed as returned from getsockname to getnameinfo. This might work on both Linux and BSD. But then we must make sure that all transports set &slen to something good. I will only be able to test this next week, on both platforms. > + if (ret) > + eprintf("getsockname Faild=>%d\n", ret); > + > if (ss.ss_family == AF_INET6) { > *p++ = '['; > blen--; > } > > - slen = sizeof(ss); > - getnameinfo((struct sockaddr *) &ss, slen, p, blen, > - NULL, 0, NI_NUMERICHOST); > + ret = os_getnameinfo_ss(&ss, p, blen, NULL, 0, > + NI_NUMERICHOST); > + if (ret) { > + eprintf("getnameinfo Faild=>%d: %s\n", > + ret, gai_strerror(ret)); > + continue; > + } > > 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); <snip> Thanks Boaz -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html