CVS commit: src/external/bsd/iscsi/dist/src/lib

2023-12-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 19 02:16:07 UTC 2023

Modified Files:
src/external/bsd/iscsi/dist/src/lib: protocol.c

Log Message:
libiscsi: Fix types of Time2Wait and Time2Retain in logout decap.

According to https://www.rfc-editor.org/rfc/rfc7143#section-11.15,
these are both 2-byte quantities.  Loading 4-byte quantities and
passing them through ISCSI_NTOHS might have worked by accident on
x86, but it's not gonna fly on big-endian.  (Fortunately sparc64 is
not just big-endian but also strict-alignment so it caught this
problem!)

XXX Is there an upstream for this code?  doc/3RDPARTY doesn't cite
any easily-followed references.

PR port-sparc64/57784

XXX pullup-10
XXX pullup-9
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/iscsi/dist/src/lib/protocol.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/iscsi/dist/src/lib/protocol.c
diff -u src/external/bsd/iscsi/dist/src/lib/protocol.c:1.4 src/external/bsd/iscsi/dist/src/lib/protocol.c:1.5
--- src/external/bsd/iscsi/dist/src/lib/protocol.c:1.4	Sat Sep 29 07:18:21 2012
+++ src/external/bsd/iscsi/dist/src/lib/protocol.c	Tue Dec 19 02:16:07 2023
@@ -920,8 +920,8 @@ iscsi_logout_rsp_decap(uint8_t *header, 
 	rsp->StatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24)));	/* StatSN */
 	rsp->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 28)));	/* ExpCmdSN */
 	rsp->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 32)));	/* MaxCmdSN  */
-	rsp->Time2Wait = ISCSI_NTOHS(*((uint32_t *) (void *) (header + 40)));	/* Time2Wait */
-	rsp->Time2Retain = ISCSI_NTOHS(*((uint32_t *) (void *) (header + 42)));	/* Time2Retain */
+	rsp->Time2Wait = ISCSI_NTOHS(*((uint16_t *) (void *) (header + 40)));	/* Time2Wait */
+	rsp->Time2Retain = ISCSI_NTOHS(*((uint16_t *) (void *) (header + 42)));	/* Time2Retain */
 
 	errmsg = NULL;
 	(void) memset(zeros, 0x0, sizeof(zeros));



CVS commit: src/external/bsd/iscsi/dist/src/lib

2023-12-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 19 02:16:07 UTC 2023

Modified Files:
src/external/bsd/iscsi/dist/src/lib: protocol.c

Log Message:
libiscsi: Fix types of Time2Wait and Time2Retain in logout decap.

According to https://www.rfc-editor.org/rfc/rfc7143#section-11.15,
these are both 2-byte quantities.  Loading 4-byte quantities and
passing them through ISCSI_NTOHS might have worked by accident on
x86, but it's not gonna fly on big-endian.  (Fortunately sparc64 is
not just big-endian but also strict-alignment so it caught this
problem!)

XXX Is there an upstream for this code?  doc/3RDPARTY doesn't cite
any easily-followed references.

PR port-sparc64/57784

XXX pullup-10
XXX pullup-9
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/iscsi/dist/src/lib/protocol.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/iscsi/dist/src/lib

2023-08-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Aug  3 08:00:10 UTC 2023

Modified Files:
src/external/bsd/iscsi/dist/src/lib: util.c

Log Message:
log a pointer's value before calling free() on it.  avoids technical UB.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/iscsi/dist/src/lib/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/iscsi/dist/src/lib

2023-08-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Aug  3 08:00:10 UTC 2023

Modified Files:
src/external/bsd/iscsi/dist/src/lib: util.c

Log Message:
log a pointer's value before calling free() on it.  avoids technical UB.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/iscsi/dist/src/lib/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/iscsi/dist/src/lib/util.c
diff -u src/external/bsd/iscsi/dist/src/lib/util.c:1.4 src/external/bsd/iscsi/dist/src/lib/util.c:1.5
--- src/external/bsd/iscsi/dist/src/lib/util.c:1.4	Thu Oct 24 19:13:25 2013
+++ src/external/bsd/iscsi/dist/src/lib/util.c	Thu Aug  3 08:00:10 2023
@@ -134,15 +134,15 @@ iscsi_malloc(unsigned n)
 void 
 iscsi_free_atomic(void *ptr)
 {
-	(void) free(ptr);
 	iscsi_trace(TRACE_MEM, "iscsi_free_atomic(%p)\n", ptr);
+	(void) free(ptr);
 }
 
 void 
 iscsi_free(void *ptr)
 {
-	(void) free(ptr);
 	iscsi_trace(TRACE_MEM, "iscsi_free(%p)\n", ptr);
+	(void) free(ptr);
 }
 
 /* debugging levels */



CVS commit: src/external/bsd/iscsi/dist/src/lib

2019-10-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  8 20:02:45 UTC 2019

Modified Files:
src/external/bsd/iscsi/dist/src/lib: target.c

Log Message:
grow the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/iscsi/dist/src/lib/target.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/iscsi/dist/src/lib

2019-10-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  8 20:02:45 UTC 2019

Modified Files:
src/external/bsd/iscsi/dist/src/lib: target.c

Log Message:
grow the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/iscsi/dist/src/lib/target.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/iscsi/dist/src/lib/target.c
diff -u src/external/bsd/iscsi/dist/src/lib/target.c:1.9 src/external/bsd/iscsi/dist/src/lib/target.c:1.10
--- src/external/bsd/iscsi/dist/src/lib/target.c:1.9	Fri Nov 14 20:15:45 2014
+++ src/external/bsd/iscsi/dist/src/lib/target.c	Tue Oct  8 16:02:44 2019
@@ -2089,7 +2089,7 @@ iscsi_target_listen(iscsi_target_t *tgt)
 	target_session_t	*sess;
 	socklen_t		remoteAddrLen;
 	socklen_t		localAddrLen;
-	char			targetaddress[1024];
+	char			targetaddress[2 * 1024];
 	char			remote[1024];
 	char			local[1024];
 	char			*config;



CVS commit: src/external/bsd/iscsi/dist

2010-03-02 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Wed Mar  3 00:44:52 UTC 2010

Modified Files:
src/external/bsd/iscsi/dist/include: iscsiprotocol.h
src/external/bsd/iscsi/dist/src/lib: disk.c target.c

Log Message:
fix multi-thread problems wrt read/write buffer.  PR/42651.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/iscsi/dist/include/iscsiprotocol.h
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/iscsi/dist/src/lib/disk.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/iscsi/dist/src/lib/target.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/iscsi/dist/include/iscsiprotocol.h
diff -u src/external/bsd/iscsi/dist/include/iscsiprotocol.h:1.1 src/external/bsd/iscsi/dist/include/iscsiprotocol.h:1.2
--- src/external/bsd/iscsi/dist/include/iscsiprotocol.h:1.1	Thu Jun 25 13:47:09 2009
+++ src/external/bsd/iscsi/dist/include/iscsiprotocol.h	Wed Mar  3 00:44:51 2010
@@ -391,6 +391,7 @@
 	uint8_t  	*ahs;
 	uint8_t ahs_len;
 	uint8_t  	*send_data;
+	uint8_t		*send_buffer;	/* malloc'ed buffer for READ */
 	int32_t send_sg_len;
 	uint8_t  	*recv_data;
 	int32_t recv_sg_len;

Index: src/external/bsd/iscsi/dist/src/lib/disk.c
diff -u src/external/bsd/iscsi/dist/src/lib/disk.c:1.5 src/external/bsd/iscsi/dist/src/lib/disk.c:1.6
--- src/external/bsd/iscsi/dist/src/lib/disk.c:1.5	Wed Jan 20 10:33:08 2010
+++ src/external/bsd/iscsi/dist/src/lib/disk.c	Wed Mar  3 00:44:51 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: disk.c,v 1.5 2010/01/20 10:33:08 yamt Exp $ */
+/* $NetBSD: disk.c,v 1.6 2010/03/03 00:44:51 yamt Exp $ */
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -100,6 +100,8 @@
 #include netinet/in.h
 #endif
 
+#include assert.h
+
 #ifdef HAVE_ERRNO_H
 #include errno.h
 #endif
@@ -149,7 +151,6 @@
 typedef struct iscsi_disk_t {
 	int		 type;		/* type of disk - fs/mmap and fs */
 	char		 filename[MAXPATHLEN];	/* filename for the disk */
-	uint8_t		*buffer;	/* buffer for disk read/write ops */
 	uint64_t	 blockc;	/* # of blocks */
 	uint64_t	 blocklen;	/* block size */
 	uint64_t	 luns;		/* # of luns */
@@ -859,7 +860,6 @@
 	}
 	idisk-size = de_getsize(tp-de);
 	idisk-blockc = idisk-size / idisk-blocklen;
-	NEWARRAY(uint8_t, idisk-buffer, MB(1), buffer1, ;);
 	idisk-type = ISCSI_FS;
 	printf(DISK: % PRIu64  logical unit%s (% PRIu64  blocks, %
 			PRIu64  bytes/block), type %s\n,
@@ -1386,6 +1386,7 @@
 	uint64_tbyte_offset;
 	uint64_tbytec;
 	uint8_t*ptr;
+	int		result;
 
 	byte_offset = lba * disks.v[sess-d].blocklen;
 	bytec = len * disks.v[sess-d].blocklen;
@@ -1402,7 +1403,7 @@
 	}
 
 	/* Assign ptr for write data */
-	ptr = disks.v[sess-d].buffer;
+	ptr = malloc(MB(1));
 
 	/* Have target do data transfer */
 	sg.iov_base = ptr;
@@ -1410,7 +1411,8 @@
 	if (target_transfer_data(sess, args, sg, 1) != 0) {
 		iscsi_err(__FILE__, __LINE__,
 			target_transfer_data() failed\n);
-		return -1;
+		result = -1;
+		goto out;
 	}
 	/* Finish up write */
 	if (de_lseek(disks.v[sess-d].lunv-v[lun].de, (off_t)byte_offset,
@@ -1418,7 +1420,8 @@
 		iscsi_err(__FILE__, __LINE__,
 			lseek() to offset % PRIu64  failed\n,
 			byte_offset);
-		return -1;
+		result = -1;
+		goto out;
 	}
 	if (!target_writable(disks.v[sess-d].lunv-v[lun])) {
 		iscsi_err(__FILE__, __LINE__,
@@ -1426,7 +1429,8 @@
 			PRIu64 , size % PRIu64 [READONLY TARGET]\n,
 			bytec, byte_offset,
 			de_getsize(disks.v[sess-d].lunv-v[lun].de));
-		return -1;
+		result = -1;
+		goto out;
 	}
 	if ((uint64_t)de_write(disks.v[sess-d].lunv-v[lun].de, ptr,
 			(unsigned) bytec) != bytec) {
@@ -1435,11 +1439,15 @@
 			PRIu64 , size % PRIu64 \n,
 			bytec, byte_offset,
 			de_getsize(disks.v[sess-d].lunv-v[lun].de));
-		return -1;
+		result = -1;
+		goto out;
 	}
 	iscsi_trace(TRACE_SCSI_DATA, 
 		wrote % PRIu64  bytes to device OK\n, bytec);
-	return 0;
+	result = 0;
+out:
+	free(ptr);
+	return result;
 }
 
 static int 
@@ -1452,11 +1460,12 @@
 	uint8_t*ptr;
 	uint32_tn;
 	int rc;
+	int		result;
 
+	assert(args-send_buffer == NULL);
 	byte_offset = lba * disks.v[sess-d].blocklen;
 	bytec = len * disks.v[sess-d].blocklen;
 	extra = 0;
-	ptr = NULL;
 	if (len == 0) {
 		iscsi_err(__FILE__, __LINE__, Zero \len\\n);
 		NO_CLEANUP;
@@ -1475,20 +1484,22 @@
 		NO_CLEANUP;
 		return -1;
 	}
-	ptr = disks.v[sess-d].buffer;
+	ptr = malloc(MB(1));
 	n = 0;
 	do {
 		if (de_lseek(disks.v[sess-d].lunv-v[lun].de,
 (off_t)(n + byte_offset), SEEK_SET) == -1) {
 			iscsi_err(__FILE__, __LINE__, lseek failed\n);
-			return -1;
+			result = -1;
+			goto out;
 		}
 		rc = de_read(disks.v[sess-d].lunv-v[lun].de, ptr + n,
 (size_t)(bytec - n));
 		if (rc = 0) {
 			iscsi_err(__FILE__, __LINE__,
 read failed: rc %d errno %d\n, rc, errno);
-			return -1;
+			result = -1;
+			goto out;
 		}
 		n += rc;
 		if (n  bytec) {
@@ -1504,5 +1515,9 

CVS commit: src/external/bsd/iscsi/dist/src/lib

2010-01-20 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Wed Jan 20 10:33:08 UTC 2010

Modified Files:
src/external/bsd/iscsi/dist/src/lib: disk.c

Log Message:
implement REPORT LUNS for non-zero LUNs correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/iscsi/dist/src/lib/disk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/iscsi/dist/src/lib

2010-01-20 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Wed Jan 20 11:50:29 UTC 2010

Modified Files:
src/external/bsd/iscsi/dist/src/lib: target.c

Log Message:
- remove unnecessary and confusing initialization of sess-d.
- add an assertion.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/iscsi/dist/src/lib/target.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/iscsi/dist/src/lib

2010-01-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Wed Jan 20 00:58:49 UTC 2010

Modified Files:
src/external/bsd/iscsi/dist/src/lib: disk.c target.c

Log Message:
add missing trailing newline chars to some of iscsi_err messages.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/iscsi/dist/src/lib/disk.c \
src/external/bsd/iscsi/dist/src/lib/target.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.