diff options
author | trasz <trasz@FreeBSD.org> | 2013-09-18 21:15:21 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2013-09-18 21:15:21 +0000 |
commit | 84d8bf623b06793e23ac562d7c7ddd94eb56c6f6 (patch) | |
tree | 80b2823e06e6e5379eb2b274b2a1846107b02d4e /sys/dev | |
parent | 667d7255be08a70cf5f13ef687602bb02959d087 (diff) | |
download | FreeBSD-src-84d8bf623b06793e23ac562d7c7ddd94eb56c6f6.zip FreeBSD-src-84d8bf623b06793e23ac562d7c7ddd94eb56c6f6.tar.gz |
Fix several problems in the new iSCSI stack; this includes interoperability
fix for LIO (Linux target), removing possibility for the target to avoid mutual
CHAP by choosing to skip authentication altogether, and fixing truncated error
messages in iscsictl(8) output. This also fixes several of the problems found
with Coverity.
Note that this change requires world rebuild.
Coverity CID: 1088038, 1087998, 1087990, 1088004, 1088044, 1088041, 1088040
Approved by: re (blanket)
Sponsored by: FreeBSD Foundation
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/iscsi/iscsi.c | 36 | ||||
-rw-r--r-- | sys/dev/iscsi/iscsi_ioctl.h | 2 |
2 files changed, 27 insertions, 11 deletions
diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 0a956e8..0b3d565 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -1513,8 +1513,13 @@ iscsi_ioctl_session_add(struct iscsi_softc *sc, struct iscsi_session_add *isa) memcpy(&is->is_conf, &isa->isa_conf, sizeof(is->is_conf)); if (is->is_conf.isc_initiator[0] == '\0' || - is->is_conf.isc_target == '\0' || - is->is_conf.isc_target_addr == '\0') { + is->is_conf.isc_target_addr[0] == '\0') { + free(is, M_ISCSI); + return (EINVAL); + } + + if ((is->is_conf.isc_discovery != 0 && is->is_conf.isc_target[0] != 0) || + (is->is_conf.isc_discovery == 0 && is->is_conf.isc_target[0] == 0)) { free(is, M_ISCSI); return (EINVAL); } @@ -1525,11 +1530,22 @@ iscsi_ioctl_session_add(struct iscsi_softc *sc, struct iscsi_session_add *isa) * Prevent duplicates. */ TAILQ_FOREACH(is2, &sc->sc_sessions, is_next) { - if (strcmp(is2->is_conf.isc_target, - is->is_conf.isc_target) == 0) { - sx_xunlock(&sc->sc_lock); - return (EBUSY); - } + if (!!is->is_conf.isc_discovery != + !!is2->is_conf.isc_discovery) + continue; + + if (strcmp(is->is_conf.isc_target_addr, + is2->is_conf.isc_target_addr) != 0) + continue; + + if (is->is_conf.isc_discovery == 0 && + strcmp(is->is_conf.isc_target, + is2->is_conf.isc_target) != 0) + continue; + + sx_xunlock(&sc->sc_lock); + free(is, M_ISCSI); + return (EBUSY); } is->is_conn = icl_conn_new(); @@ -1936,9 +1952,9 @@ iscsi_action(struct cam_sim *sim, union ccb *ccb) cpi->max_lun = 255; //cpi->initiator_id = 0; /* XXX */ cpi->initiator_id = 64; /* XXX */ - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "iSCSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "iSCSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; /* XXX */ diff --git a/sys/dev/iscsi/iscsi_ioctl.h b/sys/dev/iscsi/iscsi_ioctl.h index 9e27844..61c48cc 100644 --- a/sys/dev/iscsi/iscsi_ioctl.h +++ b/sys/dev/iscsi/iscsi_ioctl.h @@ -43,7 +43,7 @@ #define ISCSI_ADDR_LEN 47 /* INET6_ADDRSTRLEN + '\0' */ #define ISCSI_ALIAS_LEN 256 /* XXX: Where did it come from? */ #define ISCSI_SECRET_LEN 17 /* 16 + '\0' */ -#define ISCSI_REASON_LEN 32 +#define ISCSI_REASON_LEN 64 #define ISCSI_DIGEST_NONE 0 #define ISCSI_DIGEST_CRC32C 1 |