diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..05204d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/1.18.0.tar.gz diff --git a/.libiscsi.metadata b/.libiscsi.metadata new file mode 100644 index 0000000..37db1cf --- /dev/null +++ b/.libiscsi.metadata @@ -0,0 +1 @@ +9f0d4732379a3203d1d559543dda043c5f8a49ab SOURCES/1.18.0.tar.gz diff --git a/SOURCES/container_of.patch b/SOURCES/container_of.patch new file mode 100644 index 0000000..145fa1e --- /dev/null +++ b/SOURCES/container_of.patch @@ -0,0 +1,25 @@ +Binary files libiscsi-1.18.0/.git/index and new/.git/index differ +diff -rup libiscsi-1.18.0/lib/iser.c new/lib/iser.c +--- libiscsi-1.18.0/lib/iser.c 2018-04-26 09:51:53.869133618 -0400 ++++ new/lib/iser.c 2018-04-26 10:03:45.163899456 -0400 +@@ -32,6 +32,20 @@ + #include + #include + ++ ++#ifndef container_of ++/** ++ * container_of - cast a member of a structure out to the containing structure ++ * @ptr: the pointer to the member. ++ * @type: the type of the container struct this is embedded in. ++ * @member: the name of the member within the struct. ++ * ++ */ ++#define container_of(ptr, type, member) \ ++ ((type *) ((uint8_t *)(ptr) - offsetof(type, member))) ++#endif ++ ++ + #ifdef __linux + + static int cq_handle(struct iser_conn *iser_conn); diff --git a/SOURCES/disable-ld_iscsi.patch b/SOURCES/disable-ld_iscsi.patch new file mode 100644 index 0000000..36a5485 --- /dev/null +++ b/SOURCES/disable-ld_iscsi.patch @@ -0,0 +1,13 @@ +diff --git a/configure.ac b/configure.ac +index e1d01c6..72a5019 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -118,7 +118,7 @@ + fi + AM_CONDITIONAL(ISCSITEST, [test "$ac_cv_have_cunit" = yes -a "$enable_shared" = "yes"]) + +-AM_CONDITIONAL(LD_ISCSI, [expr "(" "$host_os" : "linux" ")" "&" "$enable_shared" "=" "yes"]) ++AM_CONDITIONAL(LD_ISCSI, [false]) + + AC_CHECK_MEMBER([struct CU_SuiteInfo.pSetUpFunc], + [AC_DEFINE([HAVE_CU_SUITEINFO_PSETUPFUNC], 1, diff --git a/SOURCES/fix-32bit-build.patch b/SOURCES/fix-32bit-build.patch new file mode 100644 index 0000000..b49c650 --- /dev/null +++ b/SOURCES/fix-32bit-build.patch @@ -0,0 +1,117 @@ +From a239423a0f9250dad9998152fa4b4b46accdf641 Mon Sep 17 00:00:00 2001 +From: Michal Suchanek +Date: Mon, 14 Nov 2016 17:28:31 +0100 +Subject: [PATCH] Fix 32bit build. + +Signed-off-by: Michal Suchanek +--- + lib/iser.c | 7 ++++--- + test-tool/test_compareandwrite_invalid_dataout_size.c | 4 ++-- + test-tool/test_writesame10_invalid_dataout_size.c | 4 ++-- + test-tool/test_writesame16_invalid_dataout_size.c | 4 ++-- + 4 files changed, 10 insertions(+), 9 deletions(-) + +diff --git a/lib/iser.c b/lib/iser.c +index ad3adb3..17832c3 100644 +--- a/lib/iser.c ++++ b/lib/iser.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + #include "iscsi.h" + #include "iser-private.h" + #include "iscsi-private.h" +@@ -524,7 +525,7 @@ iser_prepare_read_cmd(struct iser_conn *iser_conn,struct iser_pdu *iser_pdu) + } + + tx_desc->data_dir = DATA_READ; +- hdr->read_va = htobe64((uint64_t)tx_desc->data_buff); ++ hdr->read_va = htobe64((intptr_t)tx_desc->data_buff); + hdr->read_stag = htobe32((uint32_t)tx_desc->data_mr->rkey); + hdr->flags |= ISER_RSV; + +@@ -565,7 +566,7 @@ iser_prepare_write_cmd(struct iser_conn *iser_conn, struct iser_pdu *iser_pdu) + + hdr->flags |= ISER_WSV; + hdr->write_stag = htobe32((uint32_t)(tx_desc->data_mr->rkey)); +- hdr->write_va = htobe64((uint64_t)(tx_desc->data_buff)); ++ hdr->write_va = htobe64((intptr_t)(tx_desc->data_buff)); + + return 0; + } +@@ -1146,7 +1147,7 @@ static int iser_handle_wc(struct ibv_wc *wc,struct iser_conn *iser_conn) + wc->wr_id, wc->status, wc->vendor_err); + return iscsi_service_reconnect_if_loggedin(iscsi); + } else { +- iscsi_set_error(iscsi, "flush error: wr id %lx\n", wc->wr_id); ++ iscsi_set_error(iscsi, "flush error: wr id %" PRIx64 "\n", wc->wr_id); + + return 0; + } +diff --git a/test-tool/test_compareandwrite_invalid_dataout_size.c b/test-tool/test_compareandwrite_invalid_dataout_size.c +index b27b4f8..76da1e0 100644 +--- a/test-tool/test_compareandwrite_invalid_dataout_size.c ++++ b/test-tool/test_compareandwrite_invalid_dataout_size.c +@@ -64,7 +64,7 @@ test_compareandwrite_invalid_dataout_size(void) + + + logging(LOG_VERBOSE, "Check too small DataOut"); +- logging(LOG_VERBOSE, "COMPAREANDWRITE with DataOut==%ld (4 blocks) " ++ logging(LOG_VERBOSE, "COMPAREANDWRITE with DataOut==%zd (4 blocks) " + "and TL == 1 ", 4 * block_size); + + new_tl = 1; +@@ -74,7 +74,7 @@ test_compareandwrite_invalid_dataout_size(void) + EXPECT_STATUS_GENERIC_BAD); + + logging(LOG_VERBOSE, "Check too large DataOut"); +- logging(LOG_VERBOSE, "COMPAREANDWRITE with DataOut==%ld (4 blocks) " ++ logging(LOG_VERBOSE, "COMPAREANDWRITE with DataOut==%zd (4 blocks) " + "and TL == 3 ", 4 * block_size); + + new_tl = 2; +diff --git a/test-tool/test_writesame10_invalid_dataout_size.c b/test-tool/test_writesame10_invalid_dataout_size.c +index f521908..119d786 100644 +--- a/test-tool/test_writesame10_invalid_dataout_size.c ++++ b/test-tool/test_writesame10_invalid_dataout_size.c +@@ -41,13 +41,13 @@ test_writesame10_invalid_dataout_size(void) + memset(scratch, 0xa6, block_size); + + logging(LOG_VERBOSE, "Check too small DataOut"); +- logging(LOG_VERBOSE, "Unmap with DataOut==%ld (block_size==%ld)", ++ logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", + block_size / 2, block_size); + WRITESAME10(sd, 0, block_size / 2, 1, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GENERIC_BAD); + + logging(LOG_VERBOSE, "Check too large DataOut"); +- logging(LOG_VERBOSE, "Unmap with DataOut==%ld (block_size==%ld)", ++ logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", + block_size * 2, block_size); + WRITESAME10(sd, 0, block_size * 2, 1, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GENERIC_BAD); +diff --git a/test-tool/test_writesame16_invalid_dataout_size.c b/test-tool/test_writesame16_invalid_dataout_size.c +index 128673f..a2e22bb 100644 +--- a/test-tool/test_writesame16_invalid_dataout_size.c ++++ b/test-tool/test_writesame16_invalid_dataout_size.c +@@ -41,13 +41,13 @@ test_writesame16_invalid_dataout_size(void) + memset(scratch, 0xa6, block_size); + + logging(LOG_VERBOSE, "Check too small DataOut"); +- logging(LOG_VERBOSE, "Unmap with DataOut==%ld (block_size==%ld)", ++ logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", + block_size / 2, block_size); + WRITESAME16(sd, 0, block_size / 2, 1, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GENERIC_BAD); + + logging(LOG_VERBOSE, "Check too large DataOut"); +- logging(LOG_VERBOSE, "Unmap with DataOut==%ld (block_size==%ld)", ++ logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", + block_size * 2, block_size); + WRITESAME16(sd, 0, block_size * 2, 1, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GENERIC_BAD); +-- +2.13.6 + diff --git a/SOURCES/fix-gcc7-warnings.patch b/SOURCES/fix-gcc7-warnings.patch new file mode 100644 index 0000000..cd7282f --- /dev/null +++ b/SOURCES/fix-gcc7-warnings.patch @@ -0,0 +1,35 @@ +upstream commits 854e37aab7d7d2093a0a6620a3257b8f2a1d405c +and fb45f0343e3de45f2bc7516591d36c7466c2184e + +diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c +index cbadf85..20993d4 100644 +--- a/test-tool/iscsi-support.c ++++ b/test-tool/iscsi-support.c +@@ -2931,16 +2931,17 @@ void populate_ident_tgt_desc(unsigned char *buf, struct scsi_device *dev) + + for (desig = inq_di->designators; desig; desig = desig->next) { + switch (desig->designator_type) { +- case SCSI_DESIGNATOR_TYPE_VENDOR_SPECIFIC: +- case SCSI_DESIGNATOR_TYPE_T10_VENDORT_ID: +- case SCSI_DESIGNATOR_TYPE_EUI_64: +- case SCSI_DESIGNATOR_TYPE_NAA: +- if (prev_type <= desig->designator_type) { +- tgt_desig = desig; +- prev_type = desig->designator_type; +- } +- default: +- continue; ++ case SCSI_DESIGNATOR_TYPE_VENDOR_SPECIFIC: ++ case SCSI_DESIGNATOR_TYPE_T10_VENDORT_ID: ++ case SCSI_DESIGNATOR_TYPE_EUI_64: ++ case SCSI_DESIGNATOR_TYPE_NAA: ++ if (prev_type <= desig->designator_type) { ++ tgt_desig = desig; ++ prev_type = desig->designator_type; ++ } ++ continue; ++ default: ++ continue; + } + } + if (tgt_desig == NULL) { diff --git a/SOURCES/libiscsi-avoid-fallthrough.patch b/SOURCES/libiscsi-avoid-fallthrough.patch new file mode 100644 index 0000000..9a3fb00 --- /dev/null +++ b/SOURCES/libiscsi-avoid-fallthrough.patch @@ -0,0 +1,38 @@ +From aa9406371751329a23fed8b8799046369c3e1686 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Tue, 9 Oct 2018 15:14:18 +0100 +Subject: [PATCH 5/6] avoid fallthrough + +RH-Author: Paolo Bonzini +Message-id: <20181009151419.20418-6-pbonzini@redhat.com> +Patchwork-id: 82502 +O-Subject: [RHEL8 libiscsi PATCH 5/6] avoid fallthrough +Bugzilla: 1634541 +RH-Acked-by: Thomas Huth +RH-Acked-by: Laszlo Ersek +RH-Acked-by: Miroslav Rezanina + +Avoid the new warning in GCC 8. + +Signed-off-by: Paolo Bonzini +(cherry picked from commit 679d0abe7c142df178a907397551c4d9695cc667) +Signed-off-by: Danilo C. L. de Paula +--- + lib/scsi-lowlevel.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c +index 9c98c62..83cff18 100644 +--- a/lib/scsi-lowlevel.c ++++ b/lib/scsi-lowlevel.c +@@ -1058,6 +1058,7 @@ scsi_maintenancein_datain_getfullsize(struct scsi_task *task) + (task_get_uint8(task, 1) & 0x80) ? 12 : 0 + + task_get_uint16(task, 2); + } ++ return -1; + default: + return -1; + } +-- +1.8.3.1 + diff --git a/SOURCES/libiscsi-avoid-truncation-when-logging-message-that-includes-.patch b/SOURCES/libiscsi-avoid-truncation-when-logging-message-that-includes-.patch new file mode 100644 index 0000000..400e274 --- /dev/null +++ b/SOURCES/libiscsi-avoid-truncation-when-logging-message-that-includes-.patch @@ -0,0 +1,43 @@ +From 871a0636a3f624d504e284da2336c75dd635d587 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Tue, 9 Oct 2018 15:14:19 +0100 +Subject: [PATCH 6/6] avoid truncation when logging message that includes + target name + +RH-Author: Paolo Bonzini +Message-id: <20181009151419.20418-7-pbonzini@redhat.com> +Patchwork-id: 82507 +O-Subject: [RHEL8 libiscsi PATCH 6/6] avoid truncation when logging message that includes target name +Bugzilla: 1634541 +RH-Acked-by: Thomas Huth +RH-Acked-by: Laszlo Ersek +RH-Acked-by: Miroslav Rezanina + +Avoid truncation warning from GCC 8. + +Signed-off-by: Paolo Bonzini +(cherry picked from commit bffafc1c3003c2ee05d28eaa345e5854bc36014d) +Signed-off-by: Danilo C. L. de Paula +--- + lib/logging.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/logging.c b/lib/logging.c +index bc31f24..727860b 100644 +--- a/lib/logging.c ++++ b/lib/logging.c +@@ -73,9 +73,9 @@ iscsi_log_message(struct iscsi_context *iscsi, int level, const char *format, .. + } + + if (iscsi->target_name[0]) { +- static char message2[1024]; ++ static char message2[1282]; + +- snprintf(message2, 1024, "%s [%s]", message, iscsi->target_name); ++ snprintf(message2, 1282, "%s [%s]", message, iscsi->target_name); + iscsi->log_fn(level, message2); + } + else +-- +1.8.3.1 + diff --git a/SOURCES/libiscsi-do-not-warn-for-strncpy.patch b/SOURCES/libiscsi-do-not-warn-for-strncpy.patch new file mode 100644 index 0000000..869c9bc --- /dev/null +++ b/SOURCES/libiscsi-do-not-warn-for-strncpy.patch @@ -0,0 +1,39 @@ +From 2d293bde99f4214d8adb1932579bfbb6e59cf0a5 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Tue, 9 Oct 2018 15:14:17 +0100 +Subject: [PATCH 4/6] do not warn for strncpy + +RH-Author: Paolo Bonzini +Message-id: <20181009151419.20418-5-pbonzini@redhat.com> +Patchwork-id: 82504 +O-Subject: [RHEL8 libiscsi PATCH 4/6] do not warn for strncpy +Bugzilla: 1634541 +RH-Acked-by: Thomas Huth +RH-Acked-by: Laszlo Ersek +RH-Acked-by: Miroslav Rezanina + +strncpy use in iscsi_reconnect is just fine. Do not warn for it, and +also do not warn if clang does not recognize the flag. + +Signed-off-by: Paolo Bonzini +(cherry picked from commit 4728d4eaa605a02cfc767dd40e5436c670e88b0f) +Signed-off-by: Danilo C. L. de Paula +--- + configure.ac | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/configure.ac b/configure.ac +index f0bbc00..1ccfc59 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -29,6 +29,7 @@ AC_ARG_ENABLE([werror], [AS_HELP_STRING([--disable-werror], + + if test "$ac_cv_prog_gcc" = yes; then + WARN_CFLAGS="-Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wno-strict-aliasing" ++ WARN_CFLAGS="$WARN_CFLAGS -Wno-unknown-warning-option -Wno-stringop-truncation" + if test "x$enable_werror" != "xno"; then + WARN_CFLAGS="$WARN_CFLAGS -Werror" + fi +-- +1.8.3.1 + diff --git a/SOURCES/libiscsi-fix-connection-to-LUN-with-IPv6-address.patch b/SOURCES/libiscsi-fix-connection-to-LUN-with-IPv6-address.patch new file mode 100644 index 0000000..5298f2c --- /dev/null +++ b/SOURCES/libiscsi-fix-connection-to-LUN-with-IPv6-address.patch @@ -0,0 +1,86 @@ +From 68f9e40e4daf0a758132c520ab81fe12c13f40a7 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Tue, 4 Dec 2018 17:38:39 +0000 +Subject: [PATCH] fix connection to LUN with IPv6 address +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Paolo Bonzini +Message-id: <20181204173839.18385-1-pbonzini@redhat.com> +Patchwork-id: 83252 +O-Subject: [RHEL-8.0 libiscsi PATCH] fix connection to LUN with IPv6 address +Bugzilla: 1597942 +RH-Acked-by: Stefan Hajnoczi +RH-Acked-by: Philippe Mathieu-Daudé +RH-Acked-by: Daniel P. Berrange + +From: Ronnie Sahlberg + +Bugzilla: 1597942 + +Brew build: 19370266 + +Signed-off-by: Ronnie Sahlberg +(cherry picked from commit 179f6b33d43f26cbca133ff03fa1bacc7e8a6120) + +The patch has no commit message upstream, but it is pretty simple. + +Signed-off-by: Danilo C. L. de Paula +--- + lib/socket.c | 18 ++++++++++++++++-- + 1 file changed, 16 insertions(+), 2 deletions(-) + +diff --git a/lib/socket.c b/lib/socket.c +index 036b4f4..a335f33 100644 +--- a/lib/socket.c ++++ b/lib/socket.c +@@ -188,6 +188,20 @@ static int iscsi_tcp_connect(struct iscsi_context *iscsi, union socket_address * + + int socksize; + ++ switch (ai_family) { ++ case AF_INET: ++ socksize = sizeof(struct sockaddr_in); ++ break; ++ case AF_INET6: ++ socksize = sizeof(struct sockaddr_in6); ++ break; ++ default: ++ iscsi_set_error(iscsi, "Unknown address family :%d. " ++ "Only IPv4/IPv6 supported so far.", ++ ai_family); ++ return -1; ++ } ++ + iscsi->fd = socket(ai_family, SOCK_STREAM, 0); + if (iscsi->fd == -1) { + iscsi_set_error(iscsi, "Failed to open iscsi socket. " +@@ -246,8 +260,6 @@ static int iscsi_tcp_connect(struct iscsi_context *iscsi, union socket_address * + ISCSI_LOG(iscsi,3,"TCP_NODELAY set to 1"); + } + +- socksize = sizeof(struct sockaddr_in); // Work-around for now, need to fix it +- + if (connect(iscsi->fd, &sa->sa, socksize) != 0 + && errno != EINPROGRESS) { + iscsi_set_error(iscsi, "Connect failed with errno : " +@@ -332,6 +344,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, + case AF_INET: + socksize = sizeof(struct sockaddr_in); + memcpy(&sa.sin, ai->ai_addr, socksize); ++ sa.sin.sin_family = AF_INET; + sa.sin.sin_port = htons(port); + #ifdef HAVE_SOCK_SIN_LEN + sa.sin.sin_len = socksize; +@@ -341,6 +354,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, + case AF_INET6: + socksize = sizeof(struct sockaddr_in6); + memcpy(&sa.sin6, ai->ai_addr, socksize); ++ sa.sin6.sin6_family = AF_INET6; + sa.sin6.sin6_port = htons(port); + #ifdef HAVE_SOCK_SIN_LEN + sa.sin6.sin6_len = socksize; +-- +1.8.3.1 + diff --git a/SOURCES/libiscsi-iser-fix-posting-of-receive-descriptors.patch b/SOURCES/libiscsi-iser-fix-posting-of-receive-descriptors.patch new file mode 100644 index 0000000..697b0e6 --- /dev/null +++ b/SOURCES/libiscsi-iser-fix-posting-of-receive-descriptors.patch @@ -0,0 +1,91 @@ +From 4c41675adc85891f6605bc94aaa1baf7f7dd67e7 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Wed, 10 Oct 2018 13:27:49 +0100 +Subject: [PATCH 2/6] iser: fix posting of receive descriptors + +RH-Author: Paolo Bonzini +Message-id: <20181010132749.7381-1-pbonzini@redhat.com> +Patchwork-id: 82566 +O-Subject: [RHEL8 libiscsi PATCH 2/6] iser: fix posting of receive descriptors +Bugzilla: 1634541 +RH-Acked-by: Laszlo Ersek +RH-Acked-by: Thomas Huth +RH-Acked-by: Miroslav Rezanina + +The old code is effectively always posting iser_conn->min_posted_rx +descriptors, since it is + + if (outstanding + iser_conn->min_posted_rx <= iser_conn->qp_max_recv_dtos) { + if(iser_conn->qp_max_recv_dtos - outstanding > iser_conn->min_posted_rx) + count = iser_conn->min_posted_rx; + else + count = iser_conn->qp_max_recv_dtos - outstanding; + +which is equivalent to + + if(iser_conn->qp_max_recv_dtos - outstanding >= iser_conn->min_posted_rx) + if(iser_conn->qp_max_recv_dtos - outstanding > iser_conn->min_posted_rx) + count = iser_conn->min_posted_rx; + else + count = iser_conn->min_posted_rx; + +So the "if" is redundant and the "min_posted_rx" is actually behaving more +like a _maximum_ number of posted descriptors in one iser_post_recvm. +Fix it with the (presumably) intended logic and remove a goto along +the way. + +Signed-off-by: Paolo Bonzini +(cherry picked from commit f0fcee72c477dea57f0a50887b7368ba6d4ec33b) +Signed-off-by: Danilo C. L. de Paula +--- + lib/iser.c | 24 +++++++++--------------- + 1 file changed, 9 insertions(+), 15 deletions(-) + +diff --git a/lib/iser.c b/lib/iser.c +index 4b314be..e5c8435 100644 +--- a/lib/iser.c ++++ b/lib/iser.c +@@ -1021,7 +1021,7 @@ iser_rcv_completion(struct iser_rx_desc *rx_desc, + struct iser_conn *iser_conn) + { + struct iscsi_in_pdu *in = NULL; +- int outstanding, count = 0, err; ++ int empty, err; + struct iscsi_context *iscsi = iser_conn->cma_id->context; + + in = iscsi_malloc(iscsi, sizeof(*in)); +@@ -1089,23 +1089,17 @@ nop_target: + * for the posted rx bufs refcount to become zero handles everything */ + iser_conn->post_recv_buf_count--; + +- if ((unsigned char *)rx_desc == iser_conn->login_resp_buf) +- goto receive; +- +- outstanding = iser_conn->post_recv_buf_count; +- if (outstanding + iser_conn->min_posted_rx <= iser_conn->qp_max_recv_dtos) { +- if(iser_conn->qp_max_recv_dtos - outstanding > iser_conn->min_posted_rx) +- count = iser_conn->min_posted_rx; +- else +- count = iser_conn->qp_max_recv_dtos - outstanding; +- err = iser_post_recvm(iser_conn, count); +- if (err) { +- err = -1; +- goto error; ++ if ((unsigned char *)rx_desc != iser_conn->login_resp_buf) { ++ empty = iser_conn->qp_max_recv_dtos - iser_conn->post_recv_buf_count; ++ if (empty >= iser_conn->min_posted_rx) { ++ err = iser_post_recvm(iser_conn, empty); ++ if (err) { ++ err = -1; ++ goto error; ++ } + } + } + +-receive: + err = iscsi_process_pdu(iscsi, in); + + error: +-- +1.8.3.1 + diff --git a/SOURCES/libiscsi-iser_rcv_completion-unify-error-handling.patch b/SOURCES/libiscsi-iser_rcv_completion-unify-error-handling.patch new file mode 100644 index 0000000..6f67598 --- /dev/null +++ b/SOURCES/libiscsi-iser_rcv_completion-unify-error-handling.patch @@ -0,0 +1,86 @@ +From b8cc526501b02438713e6cf88c709c4a12d11507 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Tue, 9 Oct 2018 15:14:14 +0100 +Subject: [PATCH 1/6] iser_rcv_completion: unify error handling + +RH-Author: Paolo Bonzini +Message-id: <20181009151419.20418-2-pbonzini@redhat.com> +Patchwork-id: 82505 +O-Subject: [RHEL8 libiscsi PATCH 1/6] iser_rcv_completion: unify error handling +Bugzilla: 1634541 +RH-Acked-by: Thomas Huth +RH-Acked-by: Laszlo Ersek +RH-Acked-by: Miroslav Rezanina + +Move the iscsi_set_error to iser_post_recv, and avoid leaking the +input buffer "in". + +Signed-off-by: Paolo Bonzini +(cherry picked from commit 346fb947cb46ee8afcf5b2205e40af4ce8d29a79) +Signed-off-by: Danilo C. L. de Paula +--- + lib/iser.c | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/lib/iser.c b/lib/iser.c +index aa7244c..4b314be 100644 +--- a/lib/iser.c ++++ b/lib/iser.c +@@ -957,7 +957,7 @@ iser_post_recvm(struct iser_conn *iser_conn, int count) + iser_conn->post_recv_buf_count += count; + ret = ibv_post_recv(iser_conn->qp, iser_conn->rx_wr, &rx_wr_failed); + if (ret) { +- iscsi_set_error(iscsi, "ib_post_recv failed ret=%d", ret); ++ iscsi_set_error(iscsi, "posting %d rx bufs, ib_post_recv failed ret=%d", count, ret); + iser_conn->post_recv_buf_count -= count; + } else + iser_conn->rx_desc_head = my_rx_head; +@@ -1030,12 +1030,13 @@ iser_rcv_completion(struct iser_rx_desc *rx_desc, + if (iscsi->session_type == ISCSI_SESSION_NORMAL) { + if(iser_alloc_rx_descriptors(iser_conn,255)) { + iscsi_set_error(iscsi, "iser_alloc_rx_descriptors Failed\n"); +- return -1; ++ err = -1; ++ goto error; + } + err = iser_post_recvm(iser_conn, ISER_MIN_POSTED_RX); + if (err) { +- iscsi_set_error(iscsi, "posting %d rx bufs err %d", count, err); +- return -1; ++ err = -1; ++ goto error; + } + } + in->hdr = (unsigned char*)rx_desc->iscsi_header; +@@ -1082,7 +1083,6 @@ iser_rcv_completion(struct iser_rx_desc *rx_desc, + ISCSI_LIST_ADD_END(&iser_conn->tx_desc, iser_pdu->desc); + + nop_target: +- + /* decrementing conn->post_recv_buf_count only --after-- freeing the * + * task eliminates the need to worry on tasks which are completed in * + * parallel to the execution of iser_conn_term. So the code that waits * +@@ -1100,16 +1100,16 @@ nop_target: + count = iser_conn->qp_max_recv_dtos - outstanding; + err = iser_post_recvm(iser_conn, count); + if (err) { +- iscsi_set_error(iscsi, "posting %d rx bufs err %d", count, err); +- return -1; ++ err = -1; ++ goto error; + } + } + + receive: +- + err = iscsi_process_pdu(iscsi, in); +- iscsi_free(iscsi, in); + ++error: ++ iscsi_free(iscsi, in); + return err; + } + +-- +1.8.3.1 + diff --git a/SOURCES/libiscsi-sync-remove-unnecessary-checks.patch b/SOURCES/libiscsi-sync-remove-unnecessary-checks.patch new file mode 100644 index 0000000..0721548 --- /dev/null +++ b/SOURCES/libiscsi-sync-remove-unnecessary-checks.patch @@ -0,0 +1,58 @@ +From cc34aab2a455546431da8e8abb0d854a70c71962 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Tue, 9 Oct 2018 15:14:16 +0100 +Subject: [PATCH 3/6] sync: remove unnecessary checks + +RH-Author: Paolo Bonzini +Message-id: <20181009151419.20418-4-pbonzini@redhat.com> +Patchwork-id: 82506 +O-Subject: [RHEL8 libiscsi PATCH 3/6] sync: remove unnecessary checks +Bugzilla: 1634541 +RH-Acked-by: Thomas Huth +RH-Acked-by: Laszlo Ersek +RH-Acked-by: Miroslav Rezanina + +state is always non-NULL in iscsi_sync_cb and iscsi_discovery_cb. + +Signed-off-by: Paolo Bonzini +(cherry picked from commit f507c94774bff0c851880813d95f5d0a8fbdace8) +Signed-off-by: Danilo C. L. de Paula +--- + lib/sync.c | 14 +++++--------- + 1 file changed, 5 insertions(+), 9 deletions(-) + +diff --git a/lib/sync.c b/lib/sync.c +index 9fb78e7..34ed64e 100644 +--- a/lib/sync.c ++++ b/lib/sync.c +@@ -85,10 +85,8 @@ iscsi_sync_cb(struct iscsi_context *iscsi _U_, int status, + { + struct iscsi_sync_state *state = private_data; + +- if (state != NULL) { +- state->status = status; +- state->finished = 1; +- } ++ state->status = status; ++ state->finished = 1; + } + + int +@@ -1818,11 +1816,9 @@ iscsi_discovery_cb(struct iscsi_context *iscsi _U_, int status, + } + } + +- if (state != NULL) { +- state->status = status; +- state->finished = 1; +- state->ptr = dahead; +- } ++ state->status = status; ++ state->finished = 1; ++ state->ptr = dahead; + } + + struct iscsi_discovery_address * +-- +1.8.3.1 + diff --git a/SPECS/libiscsi.spec b/SPECS/libiscsi.spec new file mode 100644 index 0000000..2c9b943 --- /dev/null +++ b/SPECS/libiscsi.spec @@ -0,0 +1,219 @@ +Name: libiscsi +Summary: iSCSI client library +Version: 1.18.0 +Release: 7%{?dist} +License: LGPLv2+ +URL: https://github.com/sahlberg/%{name} + +Source: https://github.com/sahlberg/%{name}/archive/%{version}.tar.gz +Patch1: disable-ld_iscsi.patch +Patch2: fix-gcc7-warnings.patch +Patch3: fix-32bit-build.patch +Patch4: container_of.patch +# For bz#1634541 - Fix important coverity issues (libiscsi) +Patch5: libiscsi-iser_rcv_completion-unify-error-handling.patch +# For bz#1634541 - Fix important coverity issues (libiscsi) +Patch6: libiscsi-iser-fix-posting-of-receive-descriptors.patch +# For bz#1634541 - Fix important coverity issues (libiscsi) +Patch7: libiscsi-sync-remove-unnecessary-checks.patch +# For bz#1634541 - Fix important coverity issues (libiscsi) +Patch8: libiscsi-do-not-warn-for-strncpy.patch +# For bz#1634541 - Fix important coverity issues (libiscsi) +Patch9: libiscsi-avoid-fallthrough.patch +# For bz#1634541 - Fix important coverity issues (libiscsi) +Patch10: libiscsi-avoid-truncation-when-logging-message-that-includes-.patch +# For bz#1597942 - Qemu-kvm fails to connect to iscsi LUN by IPV6 address +Patch11: libiscsi-fix-connection-to-LUN-with-IPv6-address.patch + +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool +BuildRequires: popt-devel +BuildRequires: CUnit-devel +BuildRequires: libgcrypt-devel +BuildRequires: rdma-core-devel + +%description +libiscsi is a library for attaching to iSCSI resources across +a network. + + +####################################################################### + +# Conflict with iscsi-initiator-utils. + +%global libiscsi_includedir %{_includedir}/iscsi +%global libiscsi_libdir %{_libdir}/iscsi + +%prep +%setup -q +%autopatch -p1 + +%build +sh autogen.sh +%configure --libdir=%{libiscsi_libdir} +make %{?_smp_mflags} + +%install +make DESTDIR=$RPM_BUILD_ROOT install pkgconfigdir=%{_libdir}/pkgconfig %{?_smp_mflags} +mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d +echo %{libiscsi_libdir} > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf +rm $RPM_BUILD_ROOT/%{libiscsi_libdir}/libiscsi.a +rm $RPM_BUILD_ROOT/%{libiscsi_libdir}/libiscsi.la + +# Remove "*.old" files +find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \; + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%license COPYING LICENCE-LGPL-2.1.txt +%doc README TODO +%dir %{libiscsi_libdir} +%{libiscsi_libdir}/libiscsi.so.* +%config /etc/ld.so.conf.d/* + +%package utils +Summary: iSCSI Client Utilities +License: GPLv2+ +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description utils +The libiscsi-utils package provides a set of assorted utilities to connect +to iSCSI servers without having to set up the Linux iSCSI initiator. + +%files utils +%license LICENCE-GPL-2.txt +%{_bindir}/iscsi-ls +%{_bindir}/iscsi-inq +%{_bindir}/iscsi-readcapacity16 +%{_bindir}/iscsi-swp +%{_bindir}/iscsi-perf +%{_bindir}/iscsi-test-cu +%{_mandir}/man1/iscsi-ls.1.gz +%{_mandir}/man1/iscsi-inq.1.gz +%{_mandir}/man1/iscsi-swp.1.gz +%{_mandir}/man1/iscsi-test-cu.1.gz + +%package devel +Summary: iSCSI client development libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +The libiscsi-devel package includes the header files for libiscsi. + +%files devel +%dir %{libiscsi_includedir} +%{libiscsi_includedir}/iscsi.h +%{libiscsi_includedir}/scsi-lowlevel.h +%{libiscsi_libdir}/libiscsi.so +%{_libdir}/pkgconfig/libiscsi.pc + +%changelog +* Thu Apr 11 2019 Danilo Cesar Lemes de Paula - 1.18.0-7.el8 +- libiscsi-redhat-Remove-disable-werror-from-spec-file.patch [bz#1581025] +- Resolves: bz#1581025 + (Remove --disable-werror from spec file) + +* Fri Dec 14 2018 Danilo Cesar Lemes de Paula - +- libiscsi-fix-connection-to-LUN-with-IPv6-address.patch [bz#1597942] +- Resolves: bz#1597942 + (Qemu-kvm fails to connect to iscsi LUN by IPV6 address) + +* Fri Oct 12 2018 Danilo Cesar Lemes de Paula - 1.18.0-5.el8 +- libiscsi-iser_rcv_completion-unify-error-handling.patch [bz#1634541] +- libiscsi-iser-fix-posting-of-receive-descriptors.patch [bz#1634541] +- libiscsi-sync-remove-unnecessary-checks.patch [bz#1634541] +- libiscsi-do-not-warn-for-strncpy.patch [bz#1634541] +- libiscsi-avoid-fallthrough.patch [bz#1634541] +- libiscsi-avoid-truncation-when-logging-message-that-includes-.patch [bz#1634541] +- Resolves: bz#1634541 + (Fix important coverity issues (libiscsi)) + + +* Mon May 21 2018 Danilo Cesar Lemes de Paula - 1.18.0-4.el8 +- Fixed a build issue with the latest rdma-core + +* Fri Mar 23 2018 Cole Robinson - 1.18.0-2 +- Fix rdma deps and don't restrict archs +- Add --disable-werror to fix gcc8 build (bz #1556044) +- Spec file cleanups (bz #1483290) + +* Wed Feb 07 2018 Fedora Release Engineering - 1.18.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Tue Oct 03 2017 Paolo Bonzini - 1.18.0-1 +- Rebased to version 1.18.0 +- Added patch to fix gcc7 warnings + +* Thu Aug 03 2017 Fedora Release Engineering - 1.15.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.15.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.15.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Feb 04 2016 Fedora Release Engineering - 1.15.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Fri Jun 26 2015 Neal Gompa - 1.15.0-1 +- Rebased to version 1.15.0 +- Removed patch 20 as it has been upstreamed +- Disabled patch 12 as need for revised one is in question +- Updated patch 13 to current tree +- New tool iscsi-perf + +* Wed Jun 17 2015 Fedora Release Engineering - 1.11.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sun Aug 17 2014 Fedora Release Engineering - 1.11.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Thu Jun 12 2014 Paolo Bonzini - 1.11.0-1 +- Rebased to version 1.11.0 +- Most patches removed +- New tool iscsi-swp + manpages + +* Sat Jun 07 2014 Fedora Release Engineering - 1.9.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Wed Apr 23 2014 Tomáš Mráz - 1.9.0-5 +- Rebuild for new libgcrypt + +* Mon Aug 26 2013 Paolo Bonzini - 1.9.0-4 +- Cleaned up patches 18/19 to match upstream more closely + +* Mon Aug 26 2013 Paolo Bonzini - 1.9.0-3 +- Improved patch 18 to cover write side too + +* Mon Aug 26 2013 Paolo Bonzini - 1.9.0-2 +- Add patch 18 to fix QEMU's scsi-generic mode + +* Fri Aug 2 2013 Paolo Bonzini - 1.9.0-1 +- Rebase to 1.9.0 +- Cherry-pick selected patches from upstream + +* Mon Jul 1 2013 Paolo Bonzini - 1.7.0-6 +- Add patch 5 to silence strict aliasing warnings + +* Wed Jun 26 2013 Andy Grover - 1.7.0-5 +- Add patch 4 to enable installing of iscsi-test binary + +* Fri May 3 2013 Paolo Bonzini - 1.7.0-4 +- Add patch 2 for FIPS mode +- Add patch 3 to avoid segmentation fault on iscsi-tools + +* Thu Mar 7 2013 Paolo Bonzini - 1.7.0-3 +- Correct license for libiscsi-utils, prefer %%global to %%define +- Add Requires +- Remove percent-clean section + +* Fri Feb 22 2013 Paolo Bonzini - 1.7.0-2 +- Use percent-config for ld.so.conf.d file. + +* Fri Feb 22 2013 Paolo Bonzini - 1.7.0-1 +- Initial version (bug 914752)