diff --git a/0005-fix-ipv6.patch b/0005-fix-ipv6.patch new file mode 100644 index 0000000..964f9f4 --- /dev/null +++ b/0005-fix-ipv6.patch @@ -0,0 +1,57 @@ +From 179f6b33d43f26cbca133ff03fa1bacc7e8a6120 Mon Sep 17 00:00:00 2001 +From: Ronnie Sahlberg +Date: Sun, 8 Jan 2017 12:57:12 -0800 +Subject: [PATCH] Fix IPV6 + +Signed-off-by: Ronnie Sahlberg + +diff --git a/lib/socket.c b/lib/socket.c +index 926e474..41b68c0 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; diff --git a/0006-fix-coverity-report.patch b/0006-fix-coverity-report.patch new file mode 100644 index 0000000..6feda02 --- /dev/null +++ b/0006-fix-coverity-report.patch @@ -0,0 +1,156 @@ +diff --git a/configure.ac b/configure.ac +index cf62b64..4001400 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 +diff --git a/lib/iser.c b/lib/iser.c +index 898d6b5..d140ad6 100644 +--- a/lib/iser.c ++++ b/lib/iser.c +@@ -964,7 +964,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; +@@ -1028,7 +1028,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)); +@@ -1037,12 +1037,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; +@@ -1089,34 +1090,27 @@ 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 * + * 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) { +- iscsi_set_error(iscsi, "posting %d rx bufs err %d", count, err); +- return -1; ++ 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); +- iscsi_free(iscsi, in); + ++error: ++ iscsi_free(iscsi, in); + return err; + } + +diff --git a/lib/logging.c b/lib/logging.c +index be518fc..61c7440 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 +diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c +index 5ddd709..747ce0c 100644 +--- a/lib/scsi-lowlevel.c ++++ b/lib/scsi-lowlevel.c +@@ -1086,6 +1086,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; + } +diff --git a/lib/sync.c b/lib/sync.c +index f8a139c..0ceb0cb 100644 +--- a/lib/sync.c ++++ b/lib/sync.c +@@ -88,10 +88,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 +@@ -1871,11 +1869,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 * diff --git a/libiscsi.spec b/libiscsi.spec index 2a692c0..f568bd3 100644 --- a/libiscsi.spec +++ b/libiscsi.spec @@ -15,6 +15,8 @@ Patch0003: 0003-Fix-32bit-build.patch # Fix build with latest rdma-core # Submitted upstream: https://github.com/sahlberg/libiscsi/pull/265 Patch0004: 0004-iser-Use-local-container_of-definition.patch +Patch0005: 0005-fix-ipv6.patch +Patch0006: 0006-fix-coverity-report.patch BuildRequires: autoconf BuildRequires: automake @@ -106,6 +108,10 @@ The libiscsi-devel package includes the header files for libiscsi. %{_libdir}/pkgconfig/libiscsi.pc %changelog +* Fri Nov 30 2018 Paolo Bonzini - 1.18.0-6 +- Backport upstream fix for IPv6 connections +- Backport upstream fix for issues reported by coverity + * Fri Jul 13 2018 Fedora Release Engineering - 1.18.0-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild