Module Name: src
Committed By: mlelstv
Date: Sun Apr 21 11:26:46 UTC 2019
Modified Files:
src/sys/dev/iscsi: iscsi_globals.h iscsi_main.c iscsi_text.c
Log Message:
Replace build option to enable hex encoded bignum parameters with a sysctl.
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/iscsi/iscsi_globals.h
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/iscsi/iscsi_main.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/iscsi/iscsi_text.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/iscsi/iscsi_globals.h
diff -u src/sys/dev/iscsi/iscsi_globals.h:1.23 src/sys/dev/iscsi/iscsi_globals.h:1.24
--- src/sys/dev/iscsi/iscsi_globals.h:1.23 Sun Dec 3 19:07:10 2017
+++ src/sys/dev/iscsi/iscsi_globals.h Sun Apr 21 11:26:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_globals.h,v 1.23 2017/12/03 19:07:10 christos Exp $ */
+/* $NetBSD: iscsi_globals.h,v 1.24 2019/04/21 11:26:46 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -532,6 +532,7 @@ extern login_isid_t iscsi_InitiatorISID;
#ifdef ISCSI_DEBUG
extern int iscsi_debug_level; /* How much debug info to display */
+extern bool iscsi_hex_bignums; /* Wether to encode parameters in hex or base64 */
#define DEBOUT(x) printf x
#define DEB(lev,x) { if (iscsi_debug_level >= lev) printf x ;}
Index: src/sys/dev/iscsi/iscsi_main.c
diff -u src/sys/dev/iscsi/iscsi_main.c:1.28 src/sys/dev/iscsi/iscsi_main.c:1.29
--- src/sys/dev/iscsi/iscsi_main.c:1.28 Thu Apr 11 11:40:58 2019
+++ src/sys/dev/iscsi/iscsi_main.c Sun Apr 21 11:26:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_main.c,v 1.28 2019/04/11 11:40:58 kamil Exp $ */
+/* $NetBSD: iscsi_main.c,v 1.29 2019/04/21 11:26:46 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -47,6 +47,7 @@ extern struct cfdriver iscsi_cd;
#if defined(ISCSI_DEBUG)
int iscsi_debug_level = ISCSI_DEBUG;
#endif
+bool iscsi_hex_bignums = false;
bool iscsi_detaching;
@@ -383,7 +384,7 @@ map_session(session_t *sess, device_t de
chan->chan_channel = 0;
chan->chan_flags = SCSIPI_CHAN_NOSETTLE | SCSIPI_CHAN_CANGROW;
chan->chan_ntargets = 1;
- chan->chan_nluns = 16; /* ToDo: ??? */
+ chan->chan_nluns = 16;
chan->chan_id = sess->s_id;
sess->s_child_dev = config_found(dev, chan, scsiprint);
@@ -618,6 +619,12 @@ SYSCTL_SETUP(sysctl_iscsi_setup, "ISCSI
SYSCTL_DESCR("iscsi controls"),
NULL, 0, NULL, 0,
CTL_HW, CTL_CREATE, CTL_EOL);
+ sysctl_createv(clog, 0, &node, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_BOOL, "hexbignums",
+ SYSCTL_DESCR("encode parameters in hex"),
+ NULL, 0, &iscsi_hex_bignums, 0,
+ CTL_CREATE, CTL_EOL);
#ifdef ISCSI_DEBUG
sysctl_createv(clog, 0, &node, NULL,
Index: src/sys/dev/iscsi/iscsi_text.c
diff -u src/sys/dev/iscsi/iscsi_text.c:1.11 src/sys/dev/iscsi/iscsi_text.c:1.12
--- src/sys/dev/iscsi/iscsi_text.c:1.11 Sun Dec 3 19:07:10 2017
+++ src/sys/dev/iscsi/iscsi_text.c Sun Apr 21 11:26:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_text.c,v 1.11 2017/12/03 19:07:10 christos Exp $ */
+/* $NetBSD: iscsi_text.c,v 1.12 2019/04/21 11:26:46 mlelstv Exp $ */
/*-
* Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@@ -34,9 +34,6 @@
#include <sys/md5.h>
#include <sys/cprng.h>
-/* define to send T_BIGNUM in hex format instead of base64 */
-/* #define ISCSI_HEXBIGNUMS */
-
#define isdigit(x) ((x) >= '0' && (x) <= '9')
#define toupper(x) ((x) & ~0x20)
@@ -175,6 +172,7 @@ typedef struct
{
text_key_t key; /* the key */
int list_num; /* number of elements in list, doubles as */
+ bool hex_bignums; /* wether to encode in hex or base64 */
/* data size for large numeric values */
union
{
@@ -633,22 +631,21 @@ my_strcpy(uint8_t *dest, const uint8_t *
STATIC unsigned
put_bignumval(negotiation_parameter_t *par, uint8_t *buf)
{
-#ifdef ISCSI_HEXBIGNUMS
int k, c;
- my_strcpy(buf, "0x");
- for (k=0; k<par->list_num; ++k) {
- c = par->val.sval[k] >> 4;
- buf[2+2*k] = c < 10 ? '0' + c : 'a' + (c-10);
- c = par->val.sval[k] & 0xf;
- buf[2+2*k+1] = c < 10 ? '0' + c : 'a' + (c-10);
- }
- buf[2+2*k] = '\0';
+ if (par->hex_bignums) {
+ my_strcpy(buf, "0x");
+ for (k=0; k<par->list_num; ++k) {
+ c = par->val.sval[k] >> 4;
+ buf[2+2*k] = c < 10 ? '0' + c : 'a' + (c-10);
+ c = par->val.sval[k] & 0xf;
+ buf[2+2*k+1] = c < 10 ? '0' + c : 'a' + (c-10);
+ }
+ buf[2+2*k] = '\0';
- return 2+2*par->list_num;
-#else
+ return 2+2*par->list_num;
+ }
return base64_encode(par->val.sval, par->list_num, buf);
-#endif
}
/*
@@ -829,11 +826,10 @@ parameter_size(negotiation_parameter_t *
case T_BIGNUM:
/* list_num holds value size */
-#ifdef ISCSI_HEXBIGNUMS
- size += 2 + 2*par->list_num;
-#else
- size += base64_enclen(par->list_num);
-#endif
+ if (par->hex_bignums)
+ size += 2 + 2*par->list_num;
+ else
+ size += base64_enclen(par->list_num);
i = par->list_num;
break;
@@ -1002,6 +998,7 @@ set_key_s(negotiation_state_t *state, te
par->key = key;
par->list_num = 1;
par->val.sval = val;
+ par->hex_bignums = iscsi_hex_bignums;
state->num_pars++;
state->kflags[key] |= NS_SENT;