2016-08-02 16:34:45 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008-2012 Daisuke Aoyama <aoyama@peach.ne.jp>.
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
#include "spdk/string.h"
|
|
|
|
#include "iscsi/iscsi.h"
|
|
|
|
#include "iscsi/param.h"
|
|
|
|
#include "iscsi/conn.h"
|
|
|
|
#include "spdk/string.h"
|
|
|
|
|
2020-10-06 16:16:26 +00:00
|
|
|
#include "spdk/log.h"
|
2016-11-07 22:10:28 +00:00
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
#define MAX_TMPBUF 1024
|
|
|
|
|
|
|
|
/* whose value may be bigger than 255 */
|
|
|
|
static const char *non_simple_value_params[] = {
|
|
|
|
"CHAP_C",
|
|
|
|
"CHAP_R",
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_free(struct iscsi_param *params)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
struct iscsi_param *param, *next_param;
|
|
|
|
|
2017-12-07 23:23:48 +00:00
|
|
|
if (params == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
for (param = params; param != NULL; param = next_param) {
|
|
|
|
next_param = param->next;
|
2017-12-07 23:23:48 +00:00
|
|
|
if (param->list) {
|
2016-08-02 16:34:45 +00:00
|
|
|
free(param->list);
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
free(param->val);
|
|
|
|
free(param->key);
|
|
|
|
free(param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2019-03-27 21:53:37 +00:00
|
|
|
iscsi_find_key_in_array(const char *key, const char *array[])
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; array[i] != NULL; i++) {
|
2017-12-07 23:23:48 +00:00
|
|
|
if (strcasecmp(key, array[i]) == 0) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return 1;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct iscsi_param *
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_find(struct iscsi_param *params, const char *key)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
struct iscsi_param *param;
|
|
|
|
|
2017-12-07 23:23:48 +00:00
|
|
|
if (params == NULL || key == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return NULL;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
for (param = params; param != NULL; param = param->next) {
|
|
|
|
if (param->key != NULL && param->key[0] == key[0]
|
|
|
|
&& strcasecmp(param->key, key) == 0) {
|
|
|
|
return param;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_del(struct iscsi_param **params, const char *key)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
struct iscsi_param *param, *prev_param = NULL;
|
|
|
|
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "del %s\n", key);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (params == NULL || key == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return 0;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
for (param = *params; param != NULL; param = param->next) {
|
|
|
|
if (param->key != NULL && param->key[0] == key[0]
|
|
|
|
&& strcasecmp(param->key, key) == 0) {
|
|
|
|
if (prev_param != NULL) {
|
|
|
|
prev_param->next = param->next;
|
|
|
|
} else {
|
|
|
|
*params = param->next;
|
|
|
|
}
|
|
|
|
param->next = NULL;
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_free(param);
|
2016-08-02 16:34:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
prev_param = param;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_add(struct iscsi_param **params, const char *key,
|
|
|
|
const char *val, const char *list, int type)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
struct iscsi_param *param, *last_param;
|
|
|
|
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "add %s=%s, list=[%s], type=%d\n",
|
2016-08-02 16:34:45 +00:00
|
|
|
key, val, list, type);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (key == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return -1;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
param = iscsi_param_find(*params, key);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (param != NULL) {
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_del(params, key);
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2018-06-08 08:04:35 +00:00
|
|
|
param = calloc(1, sizeof(*param));
|
2016-08-02 16:34:45 +00:00
|
|
|
if (!param) {
|
2018-06-08 08:04:35 +00:00
|
|
|
SPDK_ERRLOG("calloc() failed for parameter\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
param->next = NULL;
|
|
|
|
param->key = xstrdup(key);
|
|
|
|
param->val = xstrdup(val);
|
|
|
|
param->list = xstrdup(list);
|
|
|
|
param->type = type;
|
|
|
|
|
|
|
|
last_param = *params;
|
|
|
|
if (last_param != NULL) {
|
|
|
|
while (last_param->next != NULL) {
|
|
|
|
last_param = last_param->next;
|
|
|
|
}
|
|
|
|
last_param->next = param;
|
|
|
|
} else {
|
|
|
|
*params = param;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_set(struct iscsi_param *params, const char *key,
|
|
|
|
const char *val)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
struct iscsi_param *param;
|
|
|
|
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set %s=%s\n", key, val);
|
2020-04-15 19:22:06 +00:00
|
|
|
param = iscsi_param_find(params, key);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (param == NULL) {
|
2016-11-17 06:33:54 +00:00
|
|
|
SPDK_ERRLOG("no key %s\n", key);
|
2016-08-02 16:34:45 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(param->val);
|
|
|
|
|
|
|
|
param->val = xstrdup(val);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_set_int(struct iscsi_param *params, const char *key, uint32_t val)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
char buf[MAX_TMPBUF];
|
|
|
|
struct iscsi_param *param;
|
|
|
|
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set %s=%d\n", key, val);
|
2020-04-15 19:22:06 +00:00
|
|
|
param = iscsi_param_find(params, key);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (param == NULL) {
|
2016-11-17 06:33:54 +00:00
|
|
|
SPDK_ERRLOG("no key %s\n", key);
|
2016-08-02 16:34:45 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(param->val);
|
|
|
|
snprintf(buf, sizeof buf, "%d", val);
|
|
|
|
|
|
|
|
param->val = strdup(buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a single KEY=VAL pair
|
|
|
|
*
|
|
|
|
* data = "KEY=VAL<NUL>"
|
|
|
|
*/
|
|
|
|
static int
|
2019-03-27 21:53:37 +00:00
|
|
|
iscsi_parse_param(struct iscsi_param **params, const uint8_t *data, uint32_t data_len)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
int rc;
|
2019-01-28 22:35:07 +00:00
|
|
|
uint8_t *key_copy, *val_copy;
|
|
|
|
const uint8_t *key_end;
|
2016-08-02 16:34:45 +00:00
|
|
|
int key_len, val_len;
|
|
|
|
int max_len;
|
|
|
|
|
2019-01-28 23:25:48 +00:00
|
|
|
data_len = strnlen(data, data_len);
|
|
|
|
/* No such thing as strnchr so use memchr instead. */
|
|
|
|
key_end = memchr(data, '=', data_len);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (!key_end) {
|
|
|
|
SPDK_ERRLOG("'=' not found\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
key_len = key_end - data;
|
|
|
|
if (key_len == 0) {
|
|
|
|
SPDK_ERRLOG("Empty key\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* RFC 7143 6.1
|
|
|
|
*/
|
|
|
|
if (key_len > ISCSI_TEXT_MAX_KEY_LEN) {
|
|
|
|
SPDK_ERRLOG("Key name length is bigger than 63\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
key_copy = malloc(key_len + 1);
|
|
|
|
if (!key_copy) {
|
2017-12-26 20:59:09 +00:00
|
|
|
SPDK_ERRLOG("malloc() failed for key_copy\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(key_copy, data, key_len);
|
|
|
|
key_copy[key_len] = '\0';
|
|
|
|
/* check whether this key is duplicated */
|
2020-04-15 19:22:06 +00:00
|
|
|
if (NULL != iscsi_param_find(*params, key_copy)) {
|
2016-08-02 16:34:45 +00:00
|
|
|
SPDK_ERRLOG("Duplicated Key %s\n", key_copy);
|
|
|
|
free(key_copy);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-01-28 22:35:07 +00:00
|
|
|
val_len = strnlen(key_end + 1, data_len - key_len - 1);
|
2016-08-02 16:34:45 +00:00
|
|
|
/*
|
|
|
|
* RFC 3720 5.1
|
|
|
|
* If not otherwise specified, the maximum length of a simple-value
|
|
|
|
* (not its encoded representation) is 255 bytes, not including the delimiter
|
|
|
|
* (comma or zero byte).
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* comma or zero is counted in, otherwise we need to iterate each parameter
|
|
|
|
* value
|
|
|
|
*/
|
2019-03-27 21:53:37 +00:00
|
|
|
max_len = iscsi_find_key_in_array(key_copy, non_simple_value_params) ?
|
2016-08-02 16:34:45 +00:00
|
|
|
ISCSI_TEXT_MAX_VAL_LEN : ISCSI_TEXT_MAX_SIMPLE_VAL_LEN;
|
|
|
|
if (val_len > max_len) {
|
|
|
|
SPDK_ERRLOG("Overflow Val %d\n", val_len);
|
|
|
|
free(key_copy);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-01-28 22:35:07 +00:00
|
|
|
val_copy = calloc(1, val_len + 1);
|
|
|
|
if (val_copy == NULL) {
|
|
|
|
SPDK_ERRLOG("Could not allocate value string\n");
|
|
|
|
free(key_copy);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(val_copy, key_end + 1, val_len);
|
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
rc = iscsi_param_add(params, key_copy, val_copy, NULL, 0);
|
2019-01-28 22:35:07 +00:00
|
|
|
free(val_copy);
|
2016-08-02 16:34:45 +00:00
|
|
|
free(key_copy);
|
|
|
|
if (rc < 0) {
|
|
|
|
SPDK_ERRLOG("iscsi_param_add() failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return number of bytes consumed
|
|
|
|
* +1 for '=' and +1 for NUL
|
|
|
|
*/
|
|
|
|
return key_len + 1 + val_len + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a sequence of KEY=VAL pairs.
|
|
|
|
*
|
|
|
|
* \param data "KEY=VAL<NUL>KEY=VAL<NUL>..."
|
|
|
|
* \param len length of data in bytes
|
2021-03-02 16:49:16 +00:00
|
|
|
*
|
|
|
|
* Data must point to a valid pointer if len > 0.
|
2016-08-02 16:34:45 +00:00
|
|
|
*/
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_parse_params(struct iscsi_param **params, const uint8_t *data,
|
|
|
|
int len, bool cbit_enabled, char **partial_parameter)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
int rc, offset = 0;
|
|
|
|
char *p;
|
|
|
|
int i;
|
|
|
|
|
2021-02-08 15:28:44 +00:00
|
|
|
/* Spec does not disallow TEXT PDUs with zero length, just return
|
|
|
|
* immediately in that case, since there is no param data to parse
|
|
|
|
* and any existing partial parameter would remain as-is.
|
|
|
|
*/
|
|
|
|
if (len == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(data != NULL);
|
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
/* strip the partial text parameters if previous PDU have C enabled */
|
|
|
|
if (partial_parameter && *partial_parameter) {
|
2018-06-13 03:18:48 +00:00
|
|
|
for (i = 0; i < len && data[i] != '\0'; i++) {
|
2016-08-02 16:34:45 +00:00
|
|
|
;
|
2018-06-13 03:18:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
p = spdk_sprintf_alloc("%s%s", *partial_parameter, (const char *)data);
|
|
|
|
if (!p) {
|
|
|
|
return -1;
|
|
|
|
}
|
2019-03-27 21:53:37 +00:00
|
|
|
rc = iscsi_parse_param(params, p, i + strlen(*partial_parameter));
|
2016-08-02 16:34:45 +00:00
|
|
|
free(p);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (rc < 0) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return -1;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
free(*partial_parameter);
|
|
|
|
*partial_parameter = NULL;
|
|
|
|
|
|
|
|
data = data + i + 1;
|
|
|
|
len = len - (i + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* strip the partial text parameters if C bit is enabled */
|
|
|
|
if (cbit_enabled) {
|
|
|
|
if (partial_parameter == NULL) {
|
|
|
|
SPDK_ERRLOG("C bit set but no partial parameters provided\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* reverse iterate the string from the tail not including '\0'
|
|
|
|
*/
|
2019-01-28 23:25:48 +00:00
|
|
|
for (i = len - 1; data[i] != '\0' && i > 0; i--) {
|
2016-08-02 16:34:45 +00:00
|
|
|
;
|
2018-06-13 03:18:48 +00:00
|
|
|
}
|
2019-01-28 23:25:48 +00:00
|
|
|
if (i != 0) {
|
|
|
|
/* We found a NULL character - don't copy it into the
|
|
|
|
* partial parameter.
|
|
|
|
*/
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*partial_parameter = calloc(1, len - i + 1);
|
|
|
|
if (*partial_parameter == NULL) {
|
|
|
|
SPDK_ERRLOG("could not allocate partial parameter\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
memcpy(*partial_parameter, &data[i], len - i);
|
|
|
|
if (i == 0) {
|
|
|
|
/* No full parameters to parse - so return now. */
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
len = i - 1;
|
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (offset < len && data[offset] != '\0') {
|
2019-03-27 21:53:37 +00:00
|
|
|
rc = iscsi_parse_param(params, data + offset, len - offset);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
offset += rc;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_get_val(struct iscsi_param *params, const char *key)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
struct iscsi_param *param;
|
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
param = iscsi_param_find(params, key);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (param == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return NULL;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
return param->val;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_eq_val(struct iscsi_param *params, const char *key,
|
|
|
|
const char *val)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
struct iscsi_param *param;
|
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
param = iscsi_param_find(params, key);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (param == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return 0;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
|
|
|
if (strcasecmp(param->val, val) == 0) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return 1;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct iscsi_param_table {
|
|
|
|
const char *key;
|
|
|
|
const char *val;
|
|
|
|
const char *list;
|
|
|
|
int type;
|
|
|
|
};
|
|
|
|
|
2016-08-09 23:29:25 +00:00
|
|
|
static const struct iscsi_param_table conn_param_table[] = {
|
2016-08-02 16:34:45 +00:00
|
|
|
{ "HeaderDigest", "None", "CRC32C,None", ISPT_LIST },
|
|
|
|
{ "DataDigest", "None", "CRC32C,None", ISPT_LIST },
|
|
|
|
{ "MaxRecvDataSegmentLength", "8192", "512,16777215", ISPT_NUMERICAL_DECLARATIVE },
|
|
|
|
{ "OFMarker", "No", "Yes,No", ISPT_BOOLEAN_AND },
|
|
|
|
{ "IFMarker", "No", "Yes,No", ISPT_BOOLEAN_AND },
|
|
|
|
{ "OFMarkInt", "1", "1,65535", ISPT_NUMERICAL_MIN },
|
|
|
|
{ "IFMarkInt", "1", "1,65535", ISPT_NUMERICAL_MIN },
|
|
|
|
{ "AuthMethod", "None", "CHAP,None", ISPT_LIST },
|
|
|
|
{ "CHAP_A", "5", "5", ISPT_LIST },
|
|
|
|
{ "CHAP_N", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ "CHAP_R", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ "CHAP_I", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ "CHAP_C", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ NULL, NULL, NULL, ISPT_INVALID },
|
|
|
|
};
|
|
|
|
|
2016-08-09 23:29:25 +00:00
|
|
|
static const struct iscsi_param_table sess_param_table[] = {
|
2016-08-02 16:34:45 +00:00
|
|
|
{ "MaxConnections", "1", "1,65535", ISPT_NUMERICAL_MIN },
|
|
|
|
#if 0
|
|
|
|
/* need special handling */
|
|
|
|
{ "SendTargets", "", "", ISPT_DECLARATIVE },
|
|
|
|
#endif
|
|
|
|
{ "TargetName", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ "InitiatorName", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ "TargetAlias", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ "InitiatorAlias", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ "TargetAddress", "", "", ISPT_DECLARATIVE },
|
|
|
|
{ "TargetPortalGroupTag", "1", "1,65535", ISPT_NUMERICAL_DECLARATIVE },
|
|
|
|
{ "InitialR2T", "Yes", "Yes,No", ISPT_BOOLEAN_OR },
|
|
|
|
{ "ImmediateData", "Yes", "Yes,No", ISPT_BOOLEAN_AND },
|
|
|
|
{ "MaxBurstLength", "262144", "512,16777215", ISPT_NUMERICAL_MIN },
|
|
|
|
{ "FirstBurstLength", "65536", "512,16777215", ISPT_NUMERICAL_MIN },
|
|
|
|
{ "DefaultTime2Wait", "2", "0,3600", ISPT_NUMERICAL_MAX },
|
|
|
|
{ "DefaultTime2Retain", "20", "0,3600", ISPT_NUMERICAL_MIN },
|
|
|
|
{ "MaxOutstandingR2T", "1", "1,65536", ISPT_NUMERICAL_MIN },
|
|
|
|
{ "DataPDUInOrder", "Yes", "Yes,No", ISPT_BOOLEAN_OR },
|
|
|
|
{ "DataSequenceInOrder", "Yes", "Yes,No", ISPT_BOOLEAN_OR },
|
|
|
|
{ "ErrorRecoveryLevel", "0", "0,2", ISPT_NUMERICAL_MIN },
|
|
|
|
{ "SessionType", "Normal", "Normal,Discovery", ISPT_DECLARATIVE },
|
|
|
|
{ NULL, NULL, NULL, ISPT_INVALID },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2019-03-27 21:53:37 +00:00
|
|
|
iscsi_params_init_internal(struct iscsi_param **params,
|
|
|
|
const struct iscsi_param_table *table)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
int i;
|
|
|
|
struct iscsi_param *param;
|
|
|
|
|
|
|
|
for (i = 0; table[i].key != NULL; i++) {
|
2020-04-15 19:22:06 +00:00
|
|
|
rc = iscsi_param_add(params, table[i].key, table[i].val,
|
|
|
|
table[i].list, table[i].type);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
SPDK_ERRLOG("iscsi_param_add() failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2020-04-15 19:22:06 +00:00
|
|
|
param = iscsi_param_find(*params, table[i].key);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (param != NULL) {
|
|
|
|
param->state_index = i;
|
|
|
|
} else {
|
2020-04-15 19:22:06 +00:00
|
|
|
SPDK_ERRLOG("iscsi_param_find() failed\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_conn_params_init(struct iscsi_param **params)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
2019-03-27 21:53:37 +00:00
|
|
|
return iscsi_params_init_internal(params, &conn_param_table[0]);
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_sess_params_init(struct iscsi_param **params)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
2019-03-27 21:53:37 +00:00
|
|
|
return iscsi_params_init_internal(params, &sess_param_table[0]);
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *chap_type[] = {
|
|
|
|
"CHAP_A",
|
|
|
|
"CHAP_N",
|
|
|
|
"CHAP_R",
|
|
|
|
"CHAP_I",
|
|
|
|
"CHAP_C",
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *discovery_ignored_param[] = {
|
|
|
|
"MaxConnections",
|
|
|
|
"InitialR2T",
|
|
|
|
"ImmediateData",
|
|
|
|
"MaxBurstLength",
|
|
|
|
"FirstBurstLength"
|
|
|
|
"MaxOutstandingR2T",
|
|
|
|
"DataPDUInOrder",
|
2020-06-10 16:11:37 +00:00
|
|
|
"DataSequenceInOrder",
|
2016-08-02 16:34:45 +00:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *multi_negot_conn_params[] = {
|
|
|
|
"MaxRecvDataSegmentLength",
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The following params should be declared by target */
|
|
|
|
static const char *target_declarative_params[] = {
|
|
|
|
"TargetAlias",
|
|
|
|
"TargetAddress",
|
|
|
|
"TargetPortalGroupTag",
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2018-08-24 09:09:27 +00:00
|
|
|
/* This function is used to construct the data from the special param (e.g.,
|
2016-08-02 16:34:45 +00:00
|
|
|
* MaxRecvDataSegmentLength)
|
|
|
|
* return:
|
|
|
|
* normal: the total len of the data
|
|
|
|
* error: -1
|
|
|
|
*/
|
|
|
|
static int
|
2019-03-27 21:53:37 +00:00
|
|
|
iscsi_special_param_construction(struct spdk_iscsi_conn *conn,
|
|
|
|
struct iscsi_param *param,
|
|
|
|
bool FirstBurstLength_flag, char *data,
|
|
|
|
int alloc_len, int total)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
struct iscsi_param *param_first;
|
|
|
|
struct iscsi_param *param_max;
|
|
|
|
uint32_t FirstBurstLength;
|
|
|
|
uint32_t MaxBurstLength;
|
|
|
|
char *val;
|
|
|
|
|
|
|
|
val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
|
|
|
if (!val) {
|
2017-12-26 20:59:09 +00:00
|
|
|
SPDK_ERRLOG("malloc() failed for temporary buffer\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcasecmp(param->key, "MaxRecvDataSegmentLength") == 0) {
|
|
|
|
/*
|
|
|
|
* MaxRecvDataSegmentLength is sent by both
|
|
|
|
* initiator and target, but is declarative - meaning
|
|
|
|
* each direction can have different values.
|
|
|
|
* So when MaxRecvDataSegmentLength is found in the
|
|
|
|
* the parameter set sent from the initiator, add SPDK
|
|
|
|
* iscsi target's MaxRecvDataSegmentLength value to
|
|
|
|
* the returned parameter list.
|
|
|
|
*/
|
|
|
|
if (alloc_len - total < 1) {
|
|
|
|
SPDK_ERRLOG("data space small %d\n", alloc_len);
|
|
|
|
free(val);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi,
|
2016-08-02 16:34:45 +00:00
|
|
|
"returning MaxRecvDataSegmentLength=%d\n",
|
2017-10-26 02:00:55 +00:00
|
|
|
SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
2016-08-02 16:34:45 +00:00
|
|
|
len = snprintf((char *)data + total, alloc_len - total,
|
|
|
|
"MaxRecvDataSegmentLength=%d",
|
2017-10-26 02:00:55 +00:00
|
|
|
SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
2016-08-02 16:34:45 +00:00
|
|
|
total += len + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcasecmp(param->key, "MaxBurstLength") == 0 &&
|
|
|
|
!FirstBurstLength_flag) {
|
|
|
|
if (alloc_len - total < 1) {
|
|
|
|
SPDK_ERRLOG("data space small %d\n", alloc_len);
|
|
|
|
free(val);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
param_first = iscsi_param_find(conn->sess->params,
|
|
|
|
"FirstBurstLength");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (param_first != NULL) {
|
|
|
|
FirstBurstLength = (uint32_t)strtol(param_first->val, NULL, 10);
|
|
|
|
} else {
|
|
|
|
FirstBurstLength = SPDK_ISCSI_FIRST_BURST_LENGTH;
|
|
|
|
}
|
2020-04-15 19:22:06 +00:00
|
|
|
param_max = iscsi_param_find(conn->sess->params,
|
|
|
|
"MaxBurstLength");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (param_max != NULL) {
|
|
|
|
MaxBurstLength = (uint32_t)strtol(param_max->val, NULL, 10);
|
|
|
|
} else {
|
|
|
|
MaxBurstLength = SPDK_ISCSI_MAX_BURST_LENGTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FirstBurstLength > MaxBurstLength) {
|
|
|
|
FirstBurstLength = MaxBurstLength;
|
|
|
|
if (param_first != NULL) {
|
|
|
|
free(param_first->val);
|
|
|
|
snprintf(val, ISCSI_TEXT_MAX_VAL_LEN, "%d",
|
|
|
|
FirstBurstLength);
|
|
|
|
param_first->val = xstrdup(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
len = snprintf((char *)data + total, alloc_len - total,
|
|
|
|
"FirstBurstLength=%d", FirstBurstLength);
|
|
|
|
total += len + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(val);
|
|
|
|
return total;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-03-27 21:53:37 +00:00
|
|
|
* iscsi_construct_data_from_param:
|
2017-04-24 18:14:41 +00:00
|
|
|
* To construct the data which will be returned to the initiator
|
2018-08-24 09:09:27 +00:00
|
|
|
* return: length of the negotiated data, -1 indicates error;
|
2017-04-24 18:14:41 +00:00
|
|
|
*/
|
2016-08-02 16:34:45 +00:00
|
|
|
static int
|
2019-03-27 21:53:37 +00:00
|
|
|
iscsi_construct_data_from_param(struct iscsi_param *param, char *new_val,
|
|
|
|
char *data, int alloc_len, int total)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (param->type != ISPT_DECLARATIVE &&
|
|
|
|
param->type != ISPT_NUMERICAL_DECLARATIVE) {
|
|
|
|
if (alloc_len - total < 1) {
|
|
|
|
SPDK_ERRLOG("data space small %d\n", alloc_len);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "negotiated %s=%s\n",
|
2016-08-02 16:34:45 +00:00
|
|
|
param->key, new_val);
|
|
|
|
len = snprintf((char *)data + total, alloc_len - total, "%s=%s",
|
|
|
|
param->key, new_val);
|
|
|
|
total += len + 1;
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-24 18:14:41 +00:00
|
|
|
* To negotiate param with
|
|
|
|
* type = ISPT_LIST
|
|
|
|
* return: the negotiated value of the key
|
|
|
|
*/
|
2019-03-27 21:53:37 +00:00
|
|
|
static char *
|
|
|
|
iscsi_negotiate_param_list(int *add_param_value,
|
|
|
|
struct iscsi_param *param,
|
|
|
|
char *valid_list, char *in_val,
|
|
|
|
char *cur_val)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
char *val_start, *val_end;
|
|
|
|
char *in_start, *in_end;
|
|
|
|
int flag = 0;
|
|
|
|
|
2017-12-07 23:23:48 +00:00
|
|
|
if (add_param_value == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return NULL;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
in_start = in_val;
|
|
|
|
do {
|
|
|
|
if ((in_end = strchr(in_start, (int)',')) != NULL) {
|
|
|
|
*in_end = '\0';
|
|
|
|
}
|
|
|
|
val_start = valid_list;
|
|
|
|
do {
|
|
|
|
if ((val_end = strchr(val_start, (int)',')) != NULL) {
|
|
|
|
*val_end = '\0';
|
|
|
|
}
|
|
|
|
if (strcasecmp(in_start, val_start) == 0) {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "match %s\n",
|
2016-08-02 16:34:45 +00:00
|
|
|
val_start);
|
|
|
|
flag = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (val_end) {
|
|
|
|
*val_end = ',';
|
|
|
|
val_start = val_end + 1;
|
|
|
|
}
|
|
|
|
} while (val_end);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (flag) {
|
2016-08-02 16:34:45 +00:00
|
|
|
break;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
if (in_end) {
|
|
|
|
*in_end = ',';
|
|
|
|
in_start = in_end + 1;
|
|
|
|
}
|
|
|
|
} while (in_end);
|
|
|
|
|
|
|
|
return flag ? val_start : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-24 18:14:41 +00:00
|
|
|
* To negotiate param with
|
|
|
|
* type = ISPT_NUMERICAL_MIN/MAX, ISPT_NUMERICAL_DECLARATIVE
|
|
|
|
* return: the negotiated value of the key
|
|
|
|
*/
|
2019-03-27 21:53:37 +00:00
|
|
|
static char *
|
|
|
|
iscsi_negotiate_param_numerical(int *add_param_value,
|
|
|
|
struct iscsi_param *param,
|
|
|
|
char *valid_list, char *in_val,
|
|
|
|
char *cur_val)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
char *valid_next;
|
|
|
|
char *new_val = NULL;
|
|
|
|
char *min_val, *max_val;
|
|
|
|
int val_i, cur_val_i;
|
|
|
|
int min_i, max_i;
|
|
|
|
|
2017-12-07 23:23:48 +00:00
|
|
|
if (add_param_value == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return NULL;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
val_i = (int)strtol(param->val, NULL, 10);
|
|
|
|
/* check whether the key is FirstBurstLength, if that we use in_val */
|
2017-12-07 23:23:48 +00:00
|
|
|
if (strcasecmp(param->key, "FirstBurstLength") == 0) {
|
2016-08-02 16:34:45 +00:00
|
|
|
val_i = (int)strtol(in_val, NULL, 10);
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
cur_val_i = (int)strtol(cur_val, NULL, 10);
|
|
|
|
valid_next = valid_list;
|
|
|
|
min_val = spdk_strsepq(&valid_next, ",");
|
|
|
|
max_val = spdk_strsepq(&valid_next, ",");
|
|
|
|
min_i = (min_val != NULL) ? (int)strtol(min_val, NULL, 10) : 0;
|
|
|
|
max_i = (max_val != NULL) ? (int)strtol(max_val, NULL, 10) : 0;
|
|
|
|
if (val_i < min_i || val_i > max_i) {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "key %.64s reject\n", param->key);
|
2016-08-02 16:34:45 +00:00
|
|
|
new_val = NULL;
|
|
|
|
} else {
|
|
|
|
switch (param->type) {
|
|
|
|
case ISPT_NUMERICAL_MIN:
|
|
|
|
if (val_i > cur_val_i) {
|
|
|
|
val_i = cur_val_i;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ISPT_NUMERICAL_MAX:
|
|
|
|
if (val_i < cur_val_i) {
|
|
|
|
val_i = cur_val_i;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN, "%d", val_i);
|
|
|
|
new_val = in_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-24 18:14:41 +00:00
|
|
|
* To negotiate param with
|
|
|
|
* type = ISPT_BOOLEAN_OR, ISPT_BOOLEAN_AND
|
|
|
|
* return: the negotiated value of the key
|
|
|
|
*/
|
2019-03-27 21:53:37 +00:00
|
|
|
static char *
|
|
|
|
iscsi_negotiate_param_boolean(int *add_param_value,
|
|
|
|
struct iscsi_param *param,
|
|
|
|
char *in_val, char *cur_val,
|
|
|
|
const char *value)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
char *new_val = NULL;
|
|
|
|
|
2017-12-07 23:23:48 +00:00
|
|
|
if (add_param_value == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return NULL;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
/* Make sure the val is Yes or No */
|
|
|
|
if (!((strcasecmp(in_val, "Yes") == 0) ||
|
|
|
|
(strcasecmp(in_val, "No") == 0))) {
|
|
|
|
/* unknown value */
|
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", "Reject");
|
|
|
|
new_val = in_val;
|
|
|
|
*add_param_value = 1;
|
|
|
|
return new_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcasecmp(cur_val, value) == 0) {
|
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", value);
|
|
|
|
new_val = in_val;
|
2017-12-07 23:23:48 +00:00
|
|
|
} else {
|
2016-08-02 16:34:45 +00:00
|
|
|
new_val = param->val;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
return new_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The entry function to handle each type of the param
|
|
|
|
* return value: the new negotiated value
|
2017-04-24 18:14:41 +00:00
|
|
|
*/
|
2016-08-02 16:34:45 +00:00
|
|
|
static char *
|
2019-03-27 21:53:37 +00:00
|
|
|
iscsi_negotiate_param_all(int *add_param_value, struct iscsi_param *param,
|
|
|
|
char *valid_list, char *in_val, char *cur_val)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
char *new_val;
|
|
|
|
switch (param->type) {
|
|
|
|
case ISPT_LIST:
|
2019-03-27 21:53:37 +00:00
|
|
|
new_val = iscsi_negotiate_param_list(add_param_value,
|
|
|
|
param,
|
|
|
|
valid_list,
|
|
|
|
in_val,
|
|
|
|
cur_val);
|
2016-08-02 16:34:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ISPT_NUMERICAL_MIN:
|
|
|
|
case ISPT_NUMERICAL_MAX:
|
|
|
|
case ISPT_NUMERICAL_DECLARATIVE:
|
2019-03-27 21:53:37 +00:00
|
|
|
new_val = iscsi_negotiate_param_numerical(add_param_value,
|
2016-08-02 16:34:45 +00:00
|
|
|
param,
|
|
|
|
valid_list,
|
|
|
|
in_val,
|
|
|
|
cur_val);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISPT_BOOLEAN_OR:
|
2019-03-27 21:53:37 +00:00
|
|
|
new_val = iscsi_negotiate_param_boolean(add_param_value,
|
|
|
|
param,
|
|
|
|
in_val,
|
|
|
|
cur_val,
|
|
|
|
"Yes");
|
2016-08-02 16:34:45 +00:00
|
|
|
break;
|
|
|
|
case ISPT_BOOLEAN_AND:
|
2019-03-27 21:53:37 +00:00
|
|
|
new_val = iscsi_negotiate_param_boolean(add_param_value,
|
|
|
|
param,
|
|
|
|
in_val,
|
|
|
|
cur_val,
|
|
|
|
"No");
|
2016-08-02 16:34:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", param->val);
|
|
|
|
new_val = in_val;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function is used to judge whether the param is in session's params or
|
|
|
|
* connection's params
|
2017-04-24 18:14:41 +00:00
|
|
|
*/
|
2016-08-02 16:34:45 +00:00
|
|
|
static int
|
2019-03-27 21:53:37 +00:00
|
|
|
iscsi_negotiate_param_init(struct spdk_iscsi_conn *conn,
|
|
|
|
struct iscsi_param **cur_param_p,
|
|
|
|
struct iscsi_param **params_dst_p,
|
|
|
|
struct iscsi_param *param)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
int index;
|
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
*cur_param_p = iscsi_param_find(*params_dst_p, param->key);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (*cur_param_p == NULL) {
|
|
|
|
*params_dst_p = conn->sess->params;
|
2020-04-15 19:22:06 +00:00
|
|
|
*cur_param_p = iscsi_param_find(*params_dst_p, param->key);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (*cur_param_p == NULL) {
|
|
|
|
if ((strncasecmp(param->key, "X-", 2) == 0) ||
|
|
|
|
(strncasecmp(param->key, "X#", 2) == 0)) {
|
|
|
|
/* Extension Key */
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi,
|
2016-08-02 16:34:45 +00:00
|
|
|
"extension key %.64s\n",
|
|
|
|
param->key);
|
|
|
|
} else {
|
|
|
|
SPDK_ERRLOG("unknown key %.64s\n", param->key);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
index = (*cur_param_p)->state_index;
|
|
|
|
if (conn->sess_param_state_negotiated[index] &&
|
2019-03-27 21:53:37 +00:00
|
|
|
!iscsi_find_key_in_array(param->key,
|
|
|
|
target_declarative_params)) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return SPDK_ISCSI_PARAMETER_EXCHANGE_NOT_ONCE;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->sess_param_state_negotiated[index] = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
index = (*cur_param_p)->state_index;
|
|
|
|
if (conn->conn_param_state_negotiated[index] &&
|
2019-03-27 21:53:37 +00:00
|
|
|
!iscsi_find_key_in_array(param->key,
|
|
|
|
multi_negot_conn_params)) {
|
2016-08-02 16:34:45 +00:00
|
|
|
return SPDK_ISCSI_PARAMETER_EXCHANGE_NOT_ONCE;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->conn_param_state_negotiated[index] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
|
|
|
|
struct iscsi_param **params, uint8_t *data, int alloc_len,
|
|
|
|
int data_len)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
struct iscsi_param *param;
|
|
|
|
struct iscsi_param *cur_param;
|
|
|
|
char *valid_list, *in_val;
|
|
|
|
char *cur_val;
|
|
|
|
char *new_val;
|
|
|
|
int discovery;
|
|
|
|
int total;
|
|
|
|
int rc;
|
|
|
|
uint32_t FirstBurstLength;
|
|
|
|
uint32_t MaxBurstLength;
|
|
|
|
bool FirstBurstLength_flag = false;
|
|
|
|
int type;
|
2017-12-18 04:29:37 +00:00
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
total = data_len;
|
2018-11-21 08:23:05 +00:00
|
|
|
if (data_len < 0) {
|
|
|
|
assert(false);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
if (alloc_len < 1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (total > alloc_len) {
|
|
|
|
total = alloc_len;
|
|
|
|
data[total - 1] = '\0';
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2017-06-05 04:06:52 +00:00
|
|
|
if (*params == NULL) {
|
2016-08-02 16:34:45 +00:00
|
|
|
/* no input */
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* discovery? */
|
|
|
|
discovery = 0;
|
2020-04-15 19:22:06 +00:00
|
|
|
cur_param = iscsi_param_find(*params, "SessionType");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (cur_param == NULL) {
|
2020-04-15 19:22:06 +00:00
|
|
|
cur_param = iscsi_param_find(conn->sess->params, "SessionType");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (cur_param == NULL) {
|
|
|
|
/* no session type */
|
|
|
|
} else {
|
|
|
|
if (strcasecmp(cur_param->val, "Discovery") == 0) {
|
|
|
|
discovery = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (strcasecmp(cur_param->val, "Discovery") == 0) {
|
|
|
|
discovery = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for temporary store */
|
|
|
|
valid_list = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
|
|
|
if (!valid_list) {
|
2017-12-26 20:59:09 +00:00
|
|
|
SPDK_ERRLOG("malloc() failed for valid_list\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
|
|
|
if (!in_val) {
|
2017-12-26 20:59:09 +00:00
|
|
|
SPDK_ERRLOG("malloc() failed for in_val\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
free(valid_list);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
cur_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
|
|
|
if (!cur_val) {
|
2017-12-26 20:59:09 +00:00
|
|
|
SPDK_ERRLOG("malloc() failed for cur_val\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
free(valid_list);
|
|
|
|
free(in_val);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* To adjust the location of FirstBurstLength location and put it to
|
2017-04-24 18:14:41 +00:00
|
|
|
* the end, then we can always firstly determine the MaxBurstLength
|
|
|
|
*/
|
2020-04-15 19:22:06 +00:00
|
|
|
param = iscsi_param_find(*params, "MaxBurstLength");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (param != NULL) {
|
2020-04-15 19:22:06 +00:00
|
|
|
param = iscsi_param_find(*params, "FirstBurstLength");
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2017-04-24 18:14:41 +00:00
|
|
|
/* check the existence of FirstBurstLength */
|
2016-08-02 16:34:45 +00:00
|
|
|
if (param != NULL) {
|
|
|
|
FirstBurstLength_flag = true;
|
|
|
|
if (param->next != NULL) {
|
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", param->val);
|
|
|
|
type = param->type;
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_add(params, "FirstBurstLength",
|
|
|
|
in_val, NULL, type);
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-05 04:06:52 +00:00
|
|
|
for (param = *params; param != NULL; param = param->next) {
|
2016-08-02 16:34:45 +00:00
|
|
|
struct iscsi_param *params_dst = conn->params;
|
|
|
|
int add_param_value = 0;
|
|
|
|
new_val = NULL;
|
|
|
|
param->type = ISPT_INVALID;
|
|
|
|
|
|
|
|
/* sendtargets is special */
|
|
|
|
if (strcasecmp(param->key, "SendTargets") == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* CHAP keys */
|
2019-03-27 21:53:37 +00:00
|
|
|
if (iscsi_find_key_in_array(param->key, chap_type)) {
|
2016-08-02 16:34:45 +00:00
|
|
|
continue;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
/* 12.2, 12.10, 12.11, 12.13, 12.14, 12.17, 12.18, 12.19 */
|
|
|
|
if (discovery &&
|
2019-03-27 21:53:37 +00:00
|
|
|
iscsi_find_key_in_array(param->key, discovery_ignored_param)) {
|
2016-08-02 16:34:45 +00:00
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", "Irrelevant");
|
|
|
|
new_val = in_val;
|
|
|
|
add_param_value = 1;
|
|
|
|
} else {
|
2019-03-27 21:53:37 +00:00
|
|
|
rc = iscsi_negotiate_param_init(conn,
|
|
|
|
&cur_param,
|
|
|
|
¶ms_dst,
|
|
|
|
param);
|
2016-08-02 16:34:45 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
free(valid_list);
|
|
|
|
free(in_val);
|
|
|
|
free(cur_val);
|
|
|
|
return rc;
|
|
|
|
} else if (rc > 0) {
|
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", "NotUnderstood");
|
|
|
|
new_val = in_val;
|
|
|
|
add_param_value = 1;
|
|
|
|
} else {
|
|
|
|
snprintf(valid_list, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", cur_param->list);
|
|
|
|
snprintf(cur_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", cur_param->val);
|
|
|
|
param->type = cur_param->type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param->type > 0) {
|
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", param->val);
|
|
|
|
|
|
|
|
/* "NotUnderstood" value shouldn't be assigned to "Understood" key */
|
|
|
|
if (strcasecmp(in_val, "NotUnderstood") == 0) {
|
|
|
|
free(in_val);
|
|
|
|
free(valid_list);
|
|
|
|
free(cur_val);
|
|
|
|
return SPDK_ISCSI_LOGIN_ERROR_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcasecmp(param->key, "FirstBurstLength") == 0) {
|
|
|
|
FirstBurstLength = (uint32_t)strtol(param->val, NULL,
|
|
|
|
10);
|
2020-04-15 19:22:06 +00:00
|
|
|
new_val = iscsi_param_get_val(conn->sess->params,
|
|
|
|
"MaxBurstLength");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (new_val != NULL) {
|
|
|
|
MaxBurstLength = (uint32_t) strtol(new_val, NULL,
|
|
|
|
10);
|
|
|
|
} else {
|
|
|
|
MaxBurstLength = SPDK_ISCSI_MAX_BURST_LENGTH;
|
|
|
|
}
|
2019-02-14 07:24:48 +00:00
|
|
|
if (FirstBurstLength < SPDK_ISCSI_MAX_FIRST_BURST_LENGTH &&
|
2016-08-02 16:34:45 +00:00
|
|
|
FirstBurstLength > MaxBurstLength) {
|
|
|
|
FirstBurstLength = MaxBurstLength;
|
|
|
|
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN, "%d",
|
|
|
|
FirstBurstLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* prevent target's declarative params from being changed by initiator */
|
2019-03-27 21:53:37 +00:00
|
|
|
if (iscsi_find_key_in_array(param->key, target_declarative_params)) {
|
2016-08-02 16:34:45 +00:00
|
|
|
add_param_value = 1;
|
|
|
|
}
|
|
|
|
|
2019-03-27 21:53:37 +00:00
|
|
|
new_val = iscsi_negotiate_param_all(&add_param_value,
|
|
|
|
param,
|
|
|
|
valid_list,
|
|
|
|
in_val,
|
|
|
|
cur_val);
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check the negotiated value of the key */
|
|
|
|
if (new_val != NULL) {
|
|
|
|
/* add_param_value = 0 means updating the value of
|
|
|
|
* existed key in the connection's parameters
|
|
|
|
*/
|
2018-06-13 03:18:48 +00:00
|
|
|
if (add_param_value == 0) {
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_param_set(params_dst, param->key, new_val);
|
2018-06-13 03:18:48 +00:00
|
|
|
}
|
2019-03-27 21:53:37 +00:00
|
|
|
total = iscsi_construct_data_from_param(param,
|
|
|
|
new_val,
|
|
|
|
data,
|
|
|
|
alloc_len,
|
|
|
|
total);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (total < 0) {
|
2016-08-02 16:34:45 +00:00
|
|
|
goto final_return;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2019-03-27 21:53:37 +00:00
|
|
|
total = iscsi_special_param_construction(conn,
|
2016-08-02 16:34:45 +00:00
|
|
|
param,
|
|
|
|
FirstBurstLength_flag,
|
|
|
|
data,
|
|
|
|
alloc_len,
|
|
|
|
total);
|
2017-12-07 23:23:48 +00:00
|
|
|
if (total < 0) {
|
2016-08-02 16:34:45 +00:00
|
|
|
goto final_return;
|
2017-12-07 23:23:48 +00:00
|
|
|
}
|
2016-08-02 16:34:45 +00:00
|
|
|
} else {
|
|
|
|
total = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
final_return:
|
|
|
|
free(valid_list);
|
|
|
|
free(in_val);
|
|
|
|
free(cur_val);
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-04-15 19:22:06 +00:00
|
|
|
iscsi_copy_param2var(struct spdk_iscsi_conn *conn)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
const char *val;
|
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->params, "MaxRecvDataSegmentLength");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval MaxRecvDataSegmentLength failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi,
|
2016-08-02 16:34:45 +00:00
|
|
|
"copy MaxRecvDataSegmentLength=%s\n", val);
|
|
|
|
conn->MaxRecvDataSegmentLength = (int)strtol(val, NULL, 10);
|
2019-02-18 22:57:30 +00:00
|
|
|
if (conn->MaxRecvDataSegmentLength > SPDK_BDEV_LARGE_BUF_MAX_SIZE) {
|
|
|
|
conn->MaxRecvDataSegmentLength = SPDK_BDEV_LARGE_BUF_MAX_SIZE;
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->params, "HeaderDigest");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval HeaderDigest failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (strcasecmp(val, "CRC32C") == 0) {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set HeaderDigest=1\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->header_digest = 1;
|
|
|
|
} else {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set HeaderDigest=0\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->header_digest = 0;
|
|
|
|
}
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->params, "DataDigest");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval DataDigest failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (strcasecmp(val, "CRC32C") == 0) {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set DataDigest=1\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->data_digest = 1;
|
|
|
|
} else {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set DataDigest=0\n");
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->data_digest = 0;
|
|
|
|
}
|
|
|
|
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->sess->params, "MaxConnections");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval MaxConnections failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "copy MaxConnections=%s\n", val);
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->sess->MaxConnections = (uint32_t) strtol(val, NULL, 10);
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->sess->params, "MaxOutstandingR2T");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval MaxOutstandingR2T failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "copy MaxOutstandingR2T=%s\n", val);
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->sess->MaxOutstandingR2T = (uint32_t) strtol(val, NULL, 10);
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->sess->params, "FirstBurstLength");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval FirstBurstLength failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "copy FirstBurstLength=%s\n", val);
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->sess->FirstBurstLength = (uint32_t) strtol(val, NULL, 10);
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->sess->params, "MaxBurstLength");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval MaxBurstLength failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "copy MaxBurstLength=%s\n", val);
|
2016-08-02 16:34:45 +00:00
|
|
|
conn->sess->MaxBurstLength = (uint32_t) strtol(val, NULL, 10);
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->sess->params, "InitialR2T");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval InitialR2T failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (strcasecmp(val, "Yes") == 0) {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set InitialR2T=1\n");
|
2018-03-12 09:38:53 +00:00
|
|
|
conn->sess->InitialR2T = true;
|
2016-08-02 16:34:45 +00:00
|
|
|
} else {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set InitialR2T=0\n");
|
2018-03-12 09:38:53 +00:00
|
|
|
conn->sess->InitialR2T = false;
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
2020-04-15 19:22:06 +00:00
|
|
|
val = iscsi_param_get_val(conn->sess->params, "ImmediateData");
|
2016-08-02 16:34:45 +00:00
|
|
|
if (val == NULL) {
|
|
|
|
SPDK_ERRLOG("Getval ImmediateData failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (strcasecmp(val, "Yes") == 0) {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set ImmediateData=1\n");
|
2018-03-12 09:38:53 +00:00
|
|
|
conn->sess->ImmediateData = true;
|
2016-08-02 16:34:45 +00:00
|
|
|
} else {
|
2020-09-04 11:27:29 +00:00
|
|
|
SPDK_DEBUGLOG(iscsi, "set ImmediateData=0\n");
|
2018-03-12 09:38:53 +00:00
|
|
|
conn->sess->ImmediateData = false;
|
2016-08-02 16:34:45 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|