Libiscsi: iSER implementation
This commit includes all iSER implementation in libscsi library and utilities. Also, adding iser option in url. Change-Id: I55ca8a9d4db802e72eb991061260dbb0bd0ef9ba Signed-off-by: Roy Shterman <roysh@mellanox.com>
This commit is contained in:
committed by
Ronnie Sahlberg
parent
0a1b96c383
commit
a628264ef0
@@ -10,6 +10,10 @@ if !HAVE_LIBGCRYPT
|
||||
libiscsi_la_SOURCES += md5.c
|
||||
endif
|
||||
|
||||
if HAVE_LINUX_ISER
|
||||
libiscsi_la_SOURCES += iser.c
|
||||
endif
|
||||
|
||||
SOCURRENT=7
|
||||
SOREVISON=2
|
||||
SOAGE=0
|
||||
@@ -17,11 +21,15 @@ libiscsi_la_LDFLAGS = \
|
||||
-version-info $(SOCURRENT):$(SOREVISON):$(SOAGE) -bindir $(bindir) \
|
||||
-no-undefined -export-symbols ${srcdir}/libiscsi.syms
|
||||
|
||||
if HAVE_LINUX_ISER
|
||||
libiscsi_la_LDFLAGS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
libiscsi_la_CPPFLAGS = -I${srcdir}/../include -I$(srcdir)/include \
|
||||
"-D_U_=__attribute__((unused))" \
|
||||
"-D_R_(A,B)=__attribute__((format(printf,A,B)))"
|
||||
|
||||
AM_CFLAGS=$(WARN_CFLAGS)
|
||||
AM_CFLAGS=$(WARN_CFLAGS) -I/usr/include
|
||||
|
||||
dist_noinst_DATA = libiscsi.syms libiscsi.def
|
||||
|
||||
|
||||
38
lib/init.c
38
lib/init.c
@@ -15,6 +15,10 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#if defined(WIN32)
|
||||
@@ -32,6 +36,9 @@
|
||||
#include <time.h>
|
||||
#include "iscsi.h"
|
||||
#include "iscsi-private.h"
|
||||
#ifdef HAVE_LINUX_ISER
|
||||
#include "iser-private.h"
|
||||
#endif
|
||||
#include "slist.h"
|
||||
|
||||
|
||||
@@ -42,6 +49,9 @@
|
||||
int iscsi_init_transport(struct iscsi_context *iscsi,
|
||||
enum iscsi_transport_type transport) {
|
||||
struct tcp_transport *tcp_transport;
|
||||
#ifdef HAVE_LINUX_ISER
|
||||
struct iser_transport *iser_transport;
|
||||
#endif
|
||||
|
||||
if (iscsi->t) {
|
||||
iscsi_free(iscsi, iscsi->t);
|
||||
@@ -59,6 +69,17 @@ int iscsi_init_transport(struct iscsi_context *iscsi,
|
||||
iscsi->t = &tcp_transport->t;
|
||||
iscsi_init_tcp_transport(iscsi);
|
||||
break;
|
||||
#ifdef HAVE_LINUX_ISER
|
||||
case ISER_TRANSPORT:
|
||||
iser_transport = iscsi_malloc(iscsi, sizeof(struct iser_transport));
|
||||
if (iser_transport == NULL) {
|
||||
iscsi_set_error(iscsi, "Couldn't allocate memory for transport\n");
|
||||
return -1;
|
||||
}
|
||||
iscsi->t = &iser_transport->t;
|
||||
iscsi_init_iser_transport(iscsi);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
iscsi_set_error(iscsi, "Unfamiliar transport type");
|
||||
return -1;
|
||||
@@ -514,6 +535,9 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
|
||||
char *lun;
|
||||
char *tmp;
|
||||
int l = 0;
|
||||
#ifdef HAVE_LINUX_ISER
|
||||
int is_iser = 0;
|
||||
#endif
|
||||
|
||||
if (strncmp(url, "iscsi://", 8)) {
|
||||
if (full) {
|
||||
@@ -554,6 +578,10 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
|
||||
target_user = value;
|
||||
} else if (!strcmp(key, "target_password")) {
|
||||
target_passwd = value;
|
||||
#ifdef HAVE_LINUX_ISER
|
||||
} else if (!strcmp(key, "iser")) {
|
||||
is_iser = 1;
|
||||
#endif
|
||||
}
|
||||
tmp = next;
|
||||
}
|
||||
@@ -647,6 +675,16 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LINUX_ISER
|
||||
if (iscsi) {
|
||||
if (is_iser) {
|
||||
if (iscsi_init_transport(iscsi, ISER_TRANSPORT))
|
||||
iscsi_set_error(iscsi, "Cannot set transport to iSER");
|
||||
}
|
||||
}
|
||||
iscsi_url->transport = is_iser;
|
||||
#endif
|
||||
|
||||
if (full) {
|
||||
strncpy(iscsi_url->target, target, MAX_STRING_SIZE);
|
||||
iscsi_url->lun = l;
|
||||
|
||||
1443
lib/iser.c
Normal file
1443
lib/iser.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -816,7 +816,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
iscsi_service_reconnect_if_loggedin(struct iscsi_context *iscsi)
|
||||
{
|
||||
if (iscsi->is_loggedin) {
|
||||
|
||||
Reference in New Issue
Block a user