Hello Open-iSCSI
(please CC as I'm not a regular on the list)
I've been working with iSCSI lately, and thought I could help with a few
patches.
Here's a description:
--> 0001-Enable-MaxOutstandingR2T-negotiation-support-in-iscs.patch
This patch enables MaxOutstandingR2T negotiation for sessions.
Currently, max_r2t negotiation is in a weird, half-broken state. The
kernel seems to support max_r2t > 1 just fine (at least it connects),
but iscsiadm is hard-coded to use "1", regardless of the setting that
the user sets in the config file, which is very confusing.
I spent more time than I'd like to admit on tracking this one down.. :)
There's even error handling in place for max_r2t > 1, but this is never
triggered since the value "1" is hard-coded, and the config file is
ignored. This is the worst of both worlds.
--> 0002-Removed-a-number-of-unused-variables.patch
Quick cleanup, to fix a number of compiler warnings.
--> 0003-Removed-unused-variable-and-computation.patch
Same as 0002.
--> 0004-Added-missing-pointer-dereferencing-memset-would-onl.patch
--> 0005-Added-missing-pointer-dereferencing-memset-would-onl.patch
In the duplicate(!) md5 function MD5Final(), there is a final
memset(ctx, 0, sizeof(ctx));
to clear the context of sensitive data after MD5 calculation - which is
fine.
Unfortunately, they both refer to sizeof(ctx), which is a pointer,
effectively nullifying (no pun intended) the effect of memset(). This is
changed to sizeof(*ctx).
--> 0006-Removed-unused-variable-one.patch
--> 0007-Removed-unused-variable-pdu_text.patch
--> 0008-Removed-dead-code.patch
Should be self-explanatory.
These are all more or less just compile-tested. Any comments?
--
De bedste hilsner / Best Regards,
Christian Iversen
System Engineer
Meebox ApS
Store Kongensgade 40H,
1264 København K
T: +45 3841 3841
--
You received this message because you are subscribed to the Google Groups
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.
>From 4a62742860cb87cfdbd2527077e27807cb1ef329 Mon Sep 17 00:00:00 2001
From: Christian Iversen <[email protected]>
Date: Mon, 29 Jun 2015 16:19:34 +0200
Subject: [PATCH 8/8] - Removed dead code
---
iscsiuio/src/uip/uip.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/iscsiuio/src/uip/uip.c b/iscsiuio/src/uip/uip.c
index 703cefc..8266b15 100644
--- a/iscsiuio/src/uip/uip.c
+++ b/iscsiuio/src/uip/uip.c
@@ -1023,7 +1023,6 @@ void uip_process(struct uip_stack *ustack, u8_t flag)
struct uip_tcp_ipv4_hdr *tcp_ipv4_hdr = NULL;
struct uip_tcp_hdr *tcp_hdr = NULL;
struct uip_icmpv4_hdr *icmpv4_hdr = NULL;
- struct uip_icmpv6_hdr *icmpv6_hdr = NULL;
struct uip_udp_hdr *udp_hdr = NULL;
/* Drop invalid packets */
@@ -1050,7 +1049,6 @@ void uip_process(struct uip_stack *ustack, u8_t flag)
buf = ustack->network_layer;
buf += sizeof(struct uip_ipv6_hdr);
- icmpv6_hdr = (struct uip_icmpv6_hdr *)buf;
} else {
uint8_t *buf;
--
2.1.4
>From 7a2a09620e44623d0663640cddb4fe5c34ac19aa Mon Sep 17 00:00:00 2001
From: Christian Iversen <[email protected]>
Date: Mon, 29 Jun 2015 16:19:17 +0200
Subject: [PATCH 7/8] - Removed unused variable "pdu_text"
---
usr/login.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/usr/login.c b/usr/login.c
index 8ff33a4..2c9be68 100644
--- a/usr/login.c
+++ b/usr/login.c
@@ -50,11 +50,9 @@ iscsi_add_text(struct iscsi_hdr *pdu, char *data, int max_data_length,
int pdu_length = ntoh24(pdu->dlength);
char *text = data;
char *end = data + max_data_length;
- char *pdu_text;
/* find the end of the current text */
text += pdu_length;
- pdu_text = text;
pdu_length += length;
if (text + length >= end) {
--
2.1.4
>From fe1f9b0fedc936279dd67a8f21737f1c83a3e427 Mon Sep 17 00:00:00 2001
From: Christian Iversen <[email protected]>
Date: Mon, 29 Jun 2015 16:17:55 +0200
Subject: [PATCH 6/8] - Removed unused variable "one"
---
usr/initiator_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
index b39a82c..d92152d 100644
--- a/usr/initiator_common.c
+++ b/usr/initiator_common.c
@@ -351,7 +351,7 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
{
struct iscsi_session *session = conn->session;
int i, rc;
- uint32_t one = 1, zero = 0;
+ uint32_t zero = 0;
struct connparam {
int param;
int type;
--
2.1.4
>From b91a2cf028d667c92508ac35b80d297604ceacc9 Mon Sep 17 00:00:00 2001
From: Christian Iversen <[email protected]>
Date: Mon, 29 Jun 2015 16:15:04 +0200
Subject: [PATCH 5/8] * Added missing pointer dereferencing: memset() would
only clear the first sizeof(voidptr) ctx bytes in MD5Final!
---
usr/md5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr/md5.c b/usr/md5.c
index 4ef1cb7..ba6c86d 100644
--- a/usr/md5.c
+++ b/usr/md5.c
@@ -127,7 +127,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
byteSwap(ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
--
2.1.4
>From 402f5f62c3422164d7af37a8be2bd5c668b13727 Mon Sep 17 00:00:00 2001
From: Christian Iversen <[email protected]>
Date: Mon, 29 Jun 2015 16:13:44 +0200
Subject: [PATCH 4/8] * Added missing pointer dereferencing: memset() would
only clear the first sizeof(voidptr) ctx bytes in MD5Final!
---
utils/md5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utils/md5.c b/utils/md5.c
index 53956c6..05c0043 100644
--- a/utils/md5.c
+++ b/utils/md5.c
@@ -133,7 +133,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
byteSwap(ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof (ctx)); /* In case it's sensitive */
+ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
--
2.1.4
>From 688b6d23037d5d0d8c1759374a01c51509eac1ff Mon Sep 17 00:00:00 2001
From: Christian Iversen <[email protected]>
Date: Mon, 29 Jun 2015 16:12:11 +0200
Subject: [PATCH 3/8] - Removed unused variable and computation
---
utils/open-isns/dd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/utils/open-isns/dd.c b/utils/open-isns/dd.c
index b392036..c2dcd10 100644
--- a/utils/open-isns/dd.c
+++ b/utils/open-isns/dd.c
@@ -599,10 +599,9 @@ isns_dd_insert(isns_dd_t *dd)
void
isns_dd_list_resize(isns_dd_list_t *list, unsigned int last_index)
{
- unsigned int new_size, cur_size;
+ unsigned int new_size;
isns_dd_t **new_data;
- cur_size = LIST_SIZE(list->ddl_count);
new_size = LIST_SIZE(last_index + 1);
if (new_size < list->ddl_count)
return;
--
2.1.4
>From d4e6d463c79a15f5df12bef59b55f7608e542fea Mon Sep 17 00:00:00 2001
From: Christian Iversen <[email protected]>
Date: Mon, 29 Jun 2015 16:11:58 +0200
Subject: [PATCH 2/8] - Removed a number of unused variables
---
utils/open-isns/bitvector.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/utils/open-isns/bitvector.c b/utils/open-isns/bitvector.c
index 3e23f26..dccc8fa 100644
--- a/utils/open-isns/bitvector.c
+++ b/utils/open-isns/bitvector.c
@@ -327,9 +327,10 @@ isns_bitvector_is_empty(const isns_bitvector_t *bv)
wp = bv->ib_words;
end = wp + bv->ib_count;
while (wp < end) {
- unsigned int base, rlen;
+ unsigned int rlen;
- base = *wp++;
+ // Skip base
+ wp++;
rlen = *wp++;
while (rlen--) {
@@ -462,11 +463,10 @@ isns_bitvector_foreach(const isns_bitvector_t *bv,
wp = bv->ib_words;
end = wp + bv->ib_count;
while (wp < end) {
- unsigned int base, rlen, bits;
+ unsigned int base, rlen;
base = wp[0];
rlen = wp[1];
- bits = rlen * 32;
wp += 2;
while (rlen--) {
@@ -492,11 +492,10 @@ isns_bitvector_dump(const isns_bitvector_t *bv, isns_print_fn_t *fn)
wp = bv->ib_words;
end = wp + bv->ib_count;
while (wp < end) {
- unsigned int base, rlen, bits;
+ unsigned int base, rlen;
base = wp[0];
rlen = wp[1];
- bits = rlen * 32;
wp += 2;
fn(" <%u:", base);
@@ -538,11 +537,10 @@ isns_bitvector_print(const isns_bitvector_t *bv,
wp = bv->ib_words;
end = wp + bv->ib_count;
while (wp < end) {
- unsigned int base, rlen, bits;
+ unsigned int base, rlen;
base = wp[0];
rlen = wp[1];
- bits = rlen * 32;
wp += 2;
while (rlen--) {
--
2.1.4
>From 10f008cce925153f484b8c2376c20f08f2833b0b Mon Sep 17 00:00:00 2001
From: Christian Iversen <[email protected]>
Date: Mon, 29 Jun 2015 16:07:44 +0200
Subject: [PATCH 1/8] + Enable MaxOutstandingR2T negotiation support in iscsi
login
---
usr/initiator.h | 1 +
usr/initiator_common.c | 2 +-
usr/login.c | 7 +------
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/usr/initiator.h b/usr/initiator.h
index 680640c..1f962b3 100644
--- a/usr/initiator.h
+++ b/usr/initiator.h
@@ -213,6 +213,7 @@ typedef struct iscsi_session {
int erl;
uint32_t imm_data_en;
uint32_t initial_r2t_en;
+ uint32_t max_r2t;
uint32_t fast_abort;
uint32_t first_burst;
uint32_t max_burst;
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
index e2e87a1..b39a82c 100644
--- a/usr/initiator_common.c
+++ b/usr/initiator_common.c
@@ -385,7 +385,7 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
.conn_only = 0,
}, {
.param = ISCSI_PARAM_MAX_R2T,
- .value = &one, /* FIXME: session->max_r2t */
+ .value = &session->max_r2t,
.type = ISCSI_INT,
.conn_only = 0,
}, {
diff --git a/usr/login.c b/usr/login.c
index db76c80..8ff33a4 100644
--- a/usr/login.c
+++ b/usr/login.c
@@ -527,12 +527,7 @@ get_op_params_text_keys(iscsi_session_t *session, int cid,
} else if (iscsi_find_key_value("MaxOutstandingR2T", text, end, &value,
&value_end)) {
if (session->type == ISCSI_SESSION_TYPE_NORMAL) {
- if (strcmp(value, "1")) {
- log_error("Login negotiation "
- "failed, can't accept Max"
- "OutstandingR2T %s", value);
- return LOGIN_NEGOTIATION_FAILED;
- }
+ session->max_r2t = strtoul(value, NULL, 0);
} else
session->irrelevant_keys_bitmap |=
IRRELEVANT_MAXOUTSTANDINGR2T;
--
2.1.4