summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith M Wesolowski <wesolows@foobazco.org>2014-01-17 19:37:33 +0000
committerKeith M Wesolowski <wesolows@foobazco.org>2014-01-17 19:37:33 +0000
commitd343fac21c7ffcecd5868cd32172c30bbda884b7 (patch)
tree3820bece31c8bdffcb94216ad0b3e6a74c01e251
parent497e64114a7c88512fee6760a8cd305710765ce4 (diff)
parent59927d313a821b7f3822314ed16fc0a44c128431 (diff)
downloadillumos-joyent-d343fac21c7ffcecd5868cd32172c30bbda884b7.tar.gz
[illumos-gate merge]
commit 59927d313a821b7f3822314ed16fc0a44c128431 3105 Kernel inet_pton() implementation returns result in host byte order commit 71cb1b742ca23532b844b6538d8f0997a900c62e 3995 Memory leak of compressed buffers in l2arc_write_done commit 2f045fd6af922f819146b314d143b660b58b20b7 4297 ::help tab completion 4298 ::printf tab completion commit 483b029ba8436049005eb485fcc9b26f2484f7ea 4458 iscsit discovery reply should be more strict WRT TPGs commit 795f5a90106de513be157280283fe8dd0c976787 4178 lofiadm usage message for the -a option is bogus Conflicts: usr/src/cmd/mdb/common/mdb/mdb_print.c usr/src/cmd/mdb/common/mdb/mdb_cmds.c
-rw-r--r--usr/src/cmd/lofiadm/main.c13
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_cmds.c2
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_print.c38
-rw-r--r--usr/src/common/iscsit/iscsit_common.c11
-rw-r--r--usr/src/uts/common/fs/nfs/nfs4_srv_deleg.c20
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7c.c7
-rw-r--r--usr/src/uts/common/fs/zfs/arc.c17
-rw-r--r--usr/src/uts/common/inet/ip.h12
-rw-r--r--usr/src/uts/common/inet/ip/inet_ntop.c47
-rw-r--r--usr/src/uts/common/inet/ip6.h6
-rw-r--r--usr/src/uts/common/io/comstar/port/iscsit/iscsit.h6
-rw-r--r--usr/src/uts/common/io/comstar/port/iscsit/iscsit_login.c5
-rw-r--r--usr/src/uts/common/io/comstar/port/iscsit/iscsit_text.c125
-rw-r--r--usr/src/uts/common/io/scsi/adapters/iscsi/iscsi.h9
-rw-r--r--usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_doorclt.c18
15 files changed, 192 insertions, 144 deletions
diff --git a/usr/src/cmd/lofiadm/main.c b/usr/src/cmd/lofiadm/main.c
index 96d6764817..d93edd1ea9 100644
--- a/usr/src/cmd/lofiadm/main.c
+++ b/usr/src/cmd/lofiadm/main.c
@@ -66,9 +66,14 @@
#include <blowfish/blowfish_impl.h>
static const char USAGE[] =
- "Usage: %s [-r] -a file [ device ] "
- " [-c aes-128-cbc|aes-192-cbc|aes-256-cbc|des3-cbc|blowfish-cbc]"
- " [-e] [-k keyfile] [-T [token]:[manuf]:[serial]:key]\n"
+ "Usage: %s [-r] -a file [ device ]\n"
+ " %s [-r] -c crypto_algorithm -a file [device]\n"
+ " %s [-r] -c crypto_algorithm -k raw_key_file -a file [device]\n"
+ " %s [-r] -c crypto_algorithm -T [token]:[manuf]:[serial]:key "
+ "-a file [device]\n"
+ " %s [-r] -c crypto_algorithm -T [token]:[manuf]:[serial]:key "
+ "-k wrapped_key_file -a file [device]\n"
+ " %s [-r] -c crypto_algorithm -e -a file [device]\n"
" %s -d file | device\n"
" %s -C [gzip|gzip-6|gzip-9|lzma] [-s segment_size] file\n"
" %s -U file\n"
@@ -151,7 +156,7 @@ static void
usage(const char *pname)
{
(void) fprintf(stderr, gettext(USAGE), pname, pname, pname,
- pname, pname);
+ pname, pname, pname, pname, pname, pname, pname);
exit(E_USAGE);
}
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c
index 3a184555cc..0badc9acf8 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c
@@ -2959,7 +2959,7 @@ const mdb_dcmd_t mdb_dcmd_builtins[] = {
{ "print", "?[-aCdhiLptx] [-c lim] [-l lim] [type] [member|offset ...]",
"print the contents of a data structure", cmd_print, print_help,
cmd_print_tab },
- { "printf", "?[format] [type] [member ... ]", "print and format the "
+ { "printf", "?format type member ...", "print and format the "
"member(s) of a data structure", cmd_printf, printf_help,
cmd_printf_tab },
{ "regs", NULL, "print general purpose registers", cmd_notsup },
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_print.c b/usr/src/cmd/mdb/common/mdb/mdb_print.c
index 0e29016e45..f8d7c97d04 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_print.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_print.c
@@ -2239,6 +2239,41 @@ cmd_print_tab(mdb_tab_cookie_t *mcp, uint_t flags, int argc,
return (cmd_print_tab_common(mcp, flags, argc, argv));
}
+int
+cmd_print_tab(mdb_tab_cookie_t *mcp, uint_t flags, int argc,
+ const mdb_arg_t *argv)
+{
+ int i, dummy;
+
+ /*
+ * This getopts is only here to make the tab completion work better when
+ * including options in the ::print arguments. None of the values should
+ * be used. This should only be updated with additional arguments, if
+ * they are added to cmd_print.
+ */
+ i = mdb_getopts(argc, argv,
+ 'a', MDB_OPT_SETBITS, PA_SHOWADDR, &dummy,
+ 'C', MDB_OPT_SETBITS, TRUE, &dummy,
+ 'c', MDB_OPT_UINTPTR, &dummy,
+ 'd', MDB_OPT_SETBITS, PA_INTDEC, &dummy,
+ 'h', MDB_OPT_SETBITS, PA_SHOWHOLES, &dummy,
+ 'i', MDB_OPT_SETBITS, TRUE, &dummy,
+ 'L', MDB_OPT_SETBITS, TRUE, &dummy,
+ 'l', MDB_OPT_UINTPTR, &dummy,
+ 'n', MDB_OPT_SETBITS, PA_NOSYMBOLIC, &dummy,
+ 'p', MDB_OPT_SETBITS, TRUE, &dummy,
+ 's', MDB_OPT_UINTPTR, &dummy,
+ 'T', MDB_OPT_SETBITS, PA_SHOWTYPE | PA_SHOWBASETYPE, &dummy,
+ 't', MDB_OPT_SETBITS, PA_SHOWTYPE, &dummy,
+ 'x', MDB_OPT_SETBITS, PA_INTHEX, &dummy,
+ NULL);
+
+ argc -= i;
+ argv += i;
+
+ return (cmd_print_tab_common(mcp, flags, argc, argv));
+}
+
/*
* Recursively descend a print a given data structure. We create a struct of
* the relevant print arguments and then call mdb_ctf_type_visit() to do the
@@ -2855,6 +2890,8 @@ cmd_printf_tab(mdb_tab_cookie_t *mcp, uint_t flags, int argc,
ii = 0;
} else {
for (ii = 1; ii < argc; ii++) {
+ if (argv[ii].a_type != MDB_TYPE_STRING)
+ continue;
f = strchr(argv[ii].a_un.a_str, '"');
if (f != NULL)
break;
@@ -2868,7 +2905,6 @@ cmd_printf_tab(mdb_tab_cookie_t *mcp, uint_t flags, int argc,
argc -= ii;
argv += ii;
-
return (cmd_print_tab_common(mcp, flags, argc, argv));
}
diff --git a/usr/src/common/iscsit/iscsit_common.c b/usr/src/common/iscsit/iscsit_common.c
index 7b2b18e89a..35e1d5f9a3 100644
--- a/usr/src/common/iscsit/iscsit_common.c
+++ b/usr/src/common/iscsit/iscsit_common.c
@@ -18,8 +18,10 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/time.h>
@@ -29,6 +31,7 @@
#include <sys/types.h>
#include <sys/sunddi.h>
#include <sys/socket.h>
+#include <inet/ip.h>
#include <inet/tcp.h>
#else
#include <stdio.h>
@@ -161,14 +164,6 @@ it_common_convert_sa(char *arg, struct sockaddr_storage *buf,
(void *)&(sin->sin_addr.s_addr)) != 1) {
return (NULL);
}
- /*
- * intet_pton does not seem to convert to network
- * order in kernel. This is a workaround until the
- * inet_pton works or we have our own inet_pton function.
- */
-#ifdef _KERNEL
- sin->sin_addr.s_addr = ntohl((uint32_t)sin->sin_addr.s_addr);
-#endif
sin->sin_port = htons(tmp_port);
} else {
sin6 = (struct sockaddr_in6 *)sa;
diff --git a/usr/src/uts/common/fs/nfs/nfs4_srv_deleg.c b/usr/src/uts/common/fs/nfs/nfs4_srv_deleg.c
index 83d96b441e..445a6d2e3a 100644
--- a/usr/src/uts/common/fs/nfs/nfs4_srv_deleg.c
+++ b/usr/src/uts/common/fs/nfs/nfs4_srv_deleg.c
@@ -18,9 +18,11 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/systm.h>
@@ -117,23 +119,7 @@ uaddr2sockaddr(int af, char *ua, void *ap, in_port_t *pp)
}
port += c;
-
- /* reset to network order */
- if (af == AF_INET) {
- *(uint32_t *)ap =
- htonl(*(uint32_t *)ap);
- *pp = htons(port);
- } else {
- int ix;
- uint16_t *sap;
-
- for (sap = ap, ix = 0; ix <
- sizeof (struct in6_addr) /
- sizeof (uint16_t); ix++)
- sap[ix] = htons(sap[ix]);
-
- *pp = htons(port);
- }
+ *pp = htons(port);
ua[k] = '.';
return (0);
diff --git a/usr/src/uts/common/fs/sockfs/nl7c.c b/usr/src/uts/common/fs/sockfs/nl7c.c
index fe3619ab6c..51ca4f1116 100644
--- a/usr/src/uts/common/fs/sockfs/nl7c.c
+++ b/usr/src/uts/common/fs/sockfs/nl7c.c
@@ -18,9 +18,11 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -50,6 +52,7 @@
#include <sys/strsun.h>
#include <sys/strsubr.h>
#include <inet/common.h>
+#include <inet/ip.h>
#include <inet/led.h>
#include <inet/mi.h>
#include <netinet/in.h>
@@ -76,9 +79,6 @@ boolean_t nl7c_logd_cycle = B_TRUE;
/*
* Some externs:
*/
-
-extern int inet_pton(int, char *, void *);
-
extern void nl7c_uri_init(void);
extern boolean_t nl7c_logd_init(int, caddr_t *);
extern void nl7c_nca_init(void);
@@ -332,7 +332,6 @@ inet_atob(char *s, nl7c_addr_t *p)
p->family = AF_INET6;
} else {
p->family = AF_INET;
- p->addr.v4 = ntohl(p->addr.v4);
}
return (0);
}
diff --git a/usr/src/uts/common/fs/zfs/arc.c b/usr/src/uts/common/fs/zfs/arc.c
index d259ad8701..581b69791d 100644
--- a/usr/src/uts/common/fs/zfs/arc.c
+++ b/usr/src/uts/common/fs/zfs/arc.c
@@ -22,7 +22,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
- * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014 by Saso Kiselkov. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
*/
@@ -4256,6 +4256,13 @@ l2arc_write_done(zio_t *zio)
*/
for (ab = list_prev(buflist, head); ab; ab = ab_prev) {
ab_prev = list_prev(buflist, ab);
+ abl2 = ab->b_l2hdr;
+
+ /*
+ * Release the temporary compressed buffer as soon as possible.
+ */
+ if (abl2->b_compress != ZIO_COMPRESS_OFF)
+ l2arc_release_cdata_buf(ab);
hash_lock = HDR_LOCK(ab);
if (!mutex_tryenter(hash_lock)) {
@@ -4268,14 +4275,6 @@ l2arc_write_done(zio_t *zio)
continue;
}
- abl2 = ab->b_l2hdr;
-
- /*
- * Release the temporary compressed buffer as soon as possible.
- */
- if (abl2->b_compress != ZIO_COMPRESS_OFF)
- l2arc_release_cdata_buf(ab);
-
if (zio->io_error != 0) {
/*
* Error - drop L2ARC entry.
diff --git a/usr/src/uts/common/inet/ip.h b/usr/src/uts/common/inet/ip.h
index bd50364310..fcf70368c8 100644
--- a/usr/src/uts/common/inet/ip.h
+++ b/usr/src/uts/common/inet/ip.h
@@ -20,9 +20,10 @@
*/
/*
+ * Copyright (c) 1990 Mentat Inc.
* Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
- * Copyright (c) 1990 Mentat Inc.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _INET_IP_H
@@ -3710,6 +3711,15 @@ extern boolean_t ip_recv_attr_from_mblk(mblk_t *, ip_recv_attr_t *);
extern mblk_t *ip_recv_attr_free_mblk(mblk_t *);
extern boolean_t ip_recv_attr_is_mblk(mblk_t *);
+#ifdef __PRAGMA_REDEFINE_EXTNAME
+#pragma redefine_extname inet_pton _inet_pton
+#else /* __PRAGMA_REDEFINE_EXTNAME */
+#define inet_pton _inet_pton
+#endif /* __PRAGMA_REDEFINE_EXTNAME */
+
+extern char *inet_ntop(int, const void *, char *, int);
+extern int inet_pton(int, char *, void *);
+
/*
* Squeue tags. Tags only need to be unique when the callback function is the
* same to distinguish between different calls, but we use unique tags for
diff --git a/usr/src/uts/common/inet/ip/inet_ntop.c b/usr/src/uts/common/inet/ip/inet_ntop.c
index 3049b133aa..9cd9b5e837 100644
--- a/usr/src/uts/common/inet/ip/inet_ntop.c
+++ b/usr/src/uts/common/inet/ip/inet_ntop.c
@@ -19,13 +19,13 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/cmn_err.h>
#include <sys/systm.h>
@@ -259,12 +259,14 @@ str2inet_addr(char *cp, ipaddr_t *addrp)
* inet_pton: This function takes string format IPv4 or IPv6 address and
* converts it to binary form. The format of this function corresponds to
* inet_pton() in the socket library.
- * It returns 0 for invalid IPv4 and IPv6 address
- * 1 when successfully converts ascii to binary
- * -1 when af is not AF_INET or AF_INET6
+ *
+ * Return values:
+ * 0 invalid IPv4 or IPv6 address
+ * 1 successful conversion
+ * -1 af is not AF_INET or AF_INET6
*/
int
-inet_pton(int af, char *inp, void *outp)
+__inet_pton(int af, char *inp, void *outp, int compat)
{
int i;
long byte;
@@ -272,7 +274,13 @@ inet_pton(int af, char *inp, void *outp)
switch (af) {
case AF_INET:
- return (str2inet_addr(inp, (ipaddr_t *)outp));
+ if (str2inet_addr(inp, (ipaddr_t *)outp) != 0) {
+ if (!compat)
+ *(uint32_t *)outp = htonl(*(uint32_t *)outp);
+ return (1);
+ } else {
+ return (0);
+ }
case AF_INET6: {
union v6buf_u {
uint16_t v6words_u[8];
@@ -316,7 +324,11 @@ inet_pton(int af, char *inp, void *outp)
if (byte < 0 || byte > 0x0ffff) {
return (0);
}
- v6buf.v6words_u[i] = (uint16_t)byte;
+ if (compat) {
+ v6buf.v6words_u[i] = (uint16_t)byte;
+ } else {
+ v6buf.v6words_u[i] = htons((uint16_t)byte);
+ }
if (*end == NULL || i == 7) {
inp = end;
break;
@@ -388,3 +400,22 @@ inet_pton(int af, char *inp, void *outp)
} /* switch */
return (-1); /* return -1 for default case */
}
+
+/*
+ * Provide fixed inet_pton() implementation.
+ */
+int
+_inet_pton(int af, char *inp, void *outp)
+{
+ return (__inet_pton(af, inp, outp, 0));
+}
+
+/*
+ * Provide broken inet_pton() implementation by default for binary
+ * compatibility.
+ */
+int
+inet_pton(int af, char *inp, void *outp)
+{
+ return (__inet_pton(af, inp, outp, 1));
+}
diff --git a/usr/src/uts/common/inet/ip6.h b/usr/src/uts/common/inet/ip6.h
index 10c6c81ba2..b7954a9a4d 100644
--- a/usr/src/uts/common/inet/ip6.h
+++ b/usr/src/uts/common/inet/ip6.h
@@ -18,9 +18,11 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _INET_IP6_H
@@ -224,10 +226,6 @@ extern const in6_addr_t ipv6_unspecified_group;
/*
* FUNCTION PROTOTYPES
*/
-
-extern void convert2ascii(char *buf, const in6_addr_t *addr);
-extern char *inet_ntop(int, const void *, char *, int);
-extern int inet_pton(int, char *, void *);
extern void icmp_param_problem_nexthdr_v6(mblk_t *, boolean_t,
ip_recv_attr_t *);
extern void icmp_pkt2big_v6(mblk_t *, uint32_t, boolean_t,
diff --git a/usr/src/uts/common/io/comstar/port/iscsit/iscsit.h b/usr/src/uts/common/io/comstar/port/iscsit/iscsit.h
index f309fabb14..83b671c4cf 100644
--- a/usr/src/uts/common/io/comstar/port/iscsit/iscsit.h
+++ b/usr/src/uts/common/io/comstar/port/iscsit/iscsit.h
@@ -18,9 +18,12 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
+
#ifndef _ISCSIT_H_
#define _ISCSIT_H_
@@ -625,6 +628,9 @@ void
iscsit_login_sm_event_locked(iscsit_conn_t *ic, iscsit_login_event_t event,
idm_pdu_t *pdu);
+int
+iscsit_is_v4_mapped(struct sockaddr_storage *sa, struct sockaddr_storage *v4sa);
+
void
iscsit_send_async_event(iscsit_conn_t *ict, uint8_t async_event);
diff --git a/usr/src/uts/common/io/comstar/port/iscsit/iscsit_login.c b/usr/src/uts/common/io/comstar/port/iscsit/iscsit_login.c
index 4648defcd7..f1306c438c 100644
--- a/usr/src/uts/common/io/comstar/port/iscsit/iscsit_login.c
+++ b/usr/src/uts/common/io/comstar/port/iscsit/iscsit_login.c
@@ -18,9 +18,10 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/cpuvar.h>
@@ -1237,7 +1238,7 @@ initial_params_done:
* 0 - address not mapable
*/
-static int
+int
iscsit_is_v4_mapped(struct sockaddr_storage *sa, struct sockaddr_storage *v4sa)
{
struct sockaddr_in *sin;
diff --git a/usr/src/uts/common/io/comstar/port/iscsit/iscsit_text.c b/usr/src/uts/common/io/comstar/port/iscsit/iscsit_text.c
index e83f8c5b29..d2943a9f9d 100644
--- a/usr/src/uts/common/io/comstar/port/iscsit/iscsit_text.c
+++ b/usr/src/uts/common/io/comstar/port/iscsit/iscsit_text.c
@@ -18,11 +18,10 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Copyright 2011, Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/cpuvar.h>
@@ -60,7 +59,8 @@ iscsit_text_cmd_fini(iscsit_conn_t *ict);
* leading zeros which the win2k initiator interprets as octal.
*/
-static void iscsit_v4_ntop(struct in_addr *in, char a[], int size)
+static void
+iscsit_v4_ntop(struct in_addr *in, char a[], int size)
{
unsigned char *p = (unsigned char *) in;
@@ -125,43 +125,24 @@ iscsit_text_reject(idm_pdu_t *req_pdu, uint8_t reason_code)
* Add individual <TargetAddress=ipaddr> tuple to the nvlist
*/
static void
-iscsit_add_portal(struct sockaddr_storage *ss, int flip_v6, int tag,
- nvlist_t *nv_resp)
+iscsit_add_portal(struct sockaddr_storage *ss, int tag, nvlist_t *nv_resp)
{
char ipaddr[IPADDRSTRLEN]; /* ip address string */
char ta_value[PORTALSTRLEN]; /* target address value */
struct sockaddr_in *sin;
- struct in_addr *in;
struct sockaddr_in6 *sin6;
- struct in6_addr *in6, flip_in6;
switch (ss->ss_family) {
case AF_INET:
sin = (struct sockaddr_in *)ss;
- in = &sin->sin_addr;
- iscsit_v4_ntop(in, ipaddr, sizeof (ipaddr));
+ iscsit_v4_ntop(&sin->sin_addr, ipaddr, sizeof (ipaddr));
(void) snprintf(ta_value, sizeof (ta_value), "%s:%d,%d",
ipaddr, ntohs(sin->sin_port), tag);
break;
case AF_INET6:
sin6 = (struct sockaddr_in6 *)ss;
- in6 = &sin6->sin6_addr;
- if (flip_v6) {
- uint16_t *v6_field_i = (uint16_t *)in6;
- uint16_t *v6_field_o = (uint16_t *)&flip_in6;
- int i;
-
- /*
- * Ugh. The iSCSI config data is stored in host
- * order while the addresses retrieved from the
- * stack come back in network order. inet_ntop
- * expects network order.
- */
- for (i = 0; i < 8; i++)
- *v6_field_o++ = htons(*v6_field_i++);
- in6 = &flip_in6;
- }
- (void) inet_ntop(AF_INET6, in6, ipaddr, sizeof (ipaddr));
+ (void) inet_ntop(AF_INET6, &sin6->sin6_addr, ipaddr,
+ sizeof (ipaddr));
(void) snprintf(ta_value, sizeof (ta_value), "[%s]:%d,%d",
ipaddr, ntohs(sin6->sin6_port), tag);
break;
@@ -238,10 +219,9 @@ iscsit_add_default_portals(iscsit_conn_t *ict, idm_addr_list_t *ipaddr_p,
}
/*
* Add portal to the response list.
- * Do not byte swap v6 address.
* By convention, the default portal group tag == 1
*/
- iscsit_add_portal(&ss, 0, 1, nv_resp);
+ iscsit_add_portal(&ss, 1, nv_resp);
}
}
}
@@ -290,11 +270,8 @@ iscsit_add_portals(iscsit_conn_t *ict, iscsit_tpgt_t *tpg_list,
continue;
break;
}
- /*
- * Add portal to the response list.
- * Need to byte swap v6 address.
- */
- iscsit_add_portal(ss, 1, tpg_list->tpgt_tag, nv_resp);
+ /* Add portal to the response list */
+ iscsit_add_portal(ss, tpg_list->tpgt_tag, nv_resp);
}
}
}
@@ -469,7 +446,6 @@ iscsit_pdu_op_text_cmd(iscsit_conn_t *ict, idm_pdu_t *rx_pdu)
char *textbuf;
int textbuflen;
int validlen;
- iscsit_tgt_t *target, *next_target;
int rc;
flags = th_req->flags;
@@ -537,61 +513,78 @@ iscsit_pdu_op_text_cmd(iscsit_conn_t *ict, idm_pdu_t *rx_pdu)
if (textbuflen >= strlen(kv_pair) &&
strcmp(kv_pair, textbuf) == 0 &&
ict->ict_op.op_discovery_session == B_TRUE) {
- idm_addr_list_t *ipaddr_p;
- int ipsize;
-
/*
* Most common case of SendTargets=All during discovery.
*/
- /*
- * Create an nvlist for response.
- */
+ idm_addr_list_t *ipaddr_p;
+ iscsit_tgt_t *tgt, *ntgt;
+ int ipsize;
+
+
+ /* Create an nvlist for response */
if (nvlist_alloc(&nv_resp, 0, KM_SLEEP) != 0) {
iscsit_text_reject(rx_pdu,
ISCSI_REJECT_CMD_NOT_SUPPORTED);
return;
}
- /*
- * get the list of local interface addresses
- */
-
+ /* Get the list of local interface addresses */
ipsize = idm_get_ipaddr(&ipaddr_p);
- /*
- * Add all the targets to the response list.
- */
+ /* Add targets to the response list */
ISCSIT_GLOBAL_LOCK(RW_READER);
- for (target = avl_first(&iscsit_global.global_target_list);
- target != NULL;
- target = next_target) {
- char *key, *value;
+ for (tgt = avl_first(&iscsit_global.global_target_list);
+ tgt != NULL; tgt = ntgt) {
+ struct sockaddr_storage v4sa, *sa;
iscsit_tgt_state_t state;
+ iscsit_portal_t *portal;
+ iscsit_tpgt_t *tpgt;
- next_target = AVL_NEXT(
- &iscsit_global.global_target_list, target);
+ ntgt = AVL_NEXT(&iscsit_global.global_target_list, tgt);
- /* only report online and onlining targets */
- state = target->target_state;
+ /* Only report online and onlining targets */
+ state = tgt->target_state;
if (state != TS_ONLINING && state != TS_ONLINE &&
state != TS_STMF_ONLINE)
continue;
- key = "TargetName";
- value = target->target_name;
- if (nvlist_add_string(nv_resp, key, value) == 0) {
- /* add the portal groups bound to this target */
- iscsit_add_tpgs(ict, target, ipaddr_p, nv_resp);
+ /*
+ * Report target if:
+ * - it is bound to default TPG
+ * - one of the addresses of TPGs the target is bound
+ * to matches incoming connection dst address
+ */
+ sa = &ict->ict_ic->ic_laddr;
+ mutex_enter(&tgt->target_mutex);
+ tpgt = avl_first(&tgt->target_tpgt_list);
+ if (!(IS_DEFAULT_TPGT(tpgt))) {
+ portal = iscsit_tgt_lookup_portal(tgt, sa,
+ &tpgt);
+ if (portal == NULL &&
+ iscsit_is_v4_mapped(sa, &v4sa)) {
+ portal = iscsit_tgt_lookup_portal(tgt,
+ &v4sa, &tpgt);
+ }
+ if (portal == NULL) {
+ mutex_exit(&tgt->target_mutex);
+ continue;
+ }
+ iscsit_portal_rele(portal);
+ iscsit_tpgt_rele(tpgt);
+ }
+ mutex_exit(&tgt->target_mutex);
+
+ if (nvlist_add_string(nv_resp, "TargetName",
+ tgt->target_name) == 0) {
+ /* Add the portal groups bound to this target */
+ iscsit_add_tpgs(ict, tgt, ipaddr_p, nv_resp);
}
}
ISCSIT_GLOBAL_UNLOCK();
- if (ipsize > 0) {
+ if (ipsize > 0)
kmem_free(ipaddr_p, ipsize);
- }
- /*
- * Convert the response nvlist into an idm text buffer.
- */
+ /* Convert the response nvlist into an idm text buffer */
textbuf = 0;
textbuflen = 0;
validlen = 0;
diff --git a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi.h b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi.h
index f090f9a029..28c4c799b7 100644
--- a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi.h
+++ b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi.h
@@ -18,9 +18,11 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2000 by Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _ISCSI_H
@@ -54,6 +56,7 @@ extern "C" {
#include <sys/idm/idm.h>
#include <sys/idm/idm_conn_sm.h>
#include <nvfile.h>
+#include <inet/ip.h>
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
@@ -1403,12 +1406,6 @@ void iscsi_client_release_service(iscsi_hba_t *ihp);
extern void bcopy(const void *s1, void *s2, size_t n);
extern void bzero(void *s, size_t n);
-/*
- * Here we need a contract for inet_ntop() and inet_pton()
- * in uts/common/inet/ip/inet_ntop.c
- */
-extern char *inet_ntop(int af, const void *addr, char *buf, int addrlen);
-extern int inet_pton(int af, char *inp, void *outp);
#ifdef __cplusplus
}
diff --git a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_doorclt.c b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_doorclt.c
index fa85724c4f..fcdaa46dde 100644
--- a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_doorclt.c
+++ b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_doorclt.c
@@ -18,11 +18,15 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2000 by Cisco Systems, Inc. All rights reserved.
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- *
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
+
+/*
* iSCSI Software Initiator
*/
@@ -243,8 +247,6 @@ kgetipnodebyname(
getipnodebyname_req_t *req;
getipnodebyname_cnf_t *cnf;
struct hostent *hptr;
- int i;
- uint16_t *swap;
buffer_size = msg_size + hostent_size + sizeof (mybuffer_t);
@@ -312,17 +314,7 @@ kgetipnodebyname(
if (inet_pton(af, (char *)name, cnf) == 1) {
/*
* inet_pton converted the string successfully.
- * reset to network order. swaps based on nfs code
*/
- if (af == AF_INET) {
- *((uint32_t *)cnf) = htonl(*((uint32_t *)cnf));
- } else {
- for (swap = ((void *)cnf), i = 0;
- i < hptr->h_length / sizeof (uint16_t);
- i++) {
- swap[i] = htons(swap[i]);
- }
- }
hptr->h_addrtype = af;
hptr->h_addr_list = (char **)((char *)hptr +
sizeof (struct hostent));