Date: Tue, 26 Oct 2021 20:17:55 GMT From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 48cb3fee2586 - main - Retire obsolete iscsi_initiator(4) Message-ID: <202110262017.19QKHta1051755@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=48cb3fee25862a6adc10fe0b2c2dc15c7fd7fd9e commit 48cb3fee25862a6adc10fe0b2c2dc15c7fd7fd9e Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-10-26 17:24:30 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2021-10-26 20:17:35 +0000 Retire obsolete iscsi_initiator(4) The new iSCSI initiator iscsi(4) was introduced with FreeBSD 10.0, and the old intiator was marked obsolete shortly thereafter (in commit d32789d95cfbf, MFC'd to stable/10 in ba54910169c4). Remove it now. Reviewed by: jhb, mav Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32673 --- ObsoleteFiles.inc | 5 + sbin/Makefile | 1 - sbin/iscontrol/Makefile | 14 - sbin/iscontrol/Makefile.depend | 21 - sbin/iscontrol/auth_subr.c | 206 ----- sbin/iscontrol/config.c | 382 --------- sbin/iscontrol/fsm.c | 759 ------------------ sbin/iscontrol/iscontrol.8 | 141 ---- sbin/iscontrol/iscontrol.c | 264 ------- sbin/iscontrol/iscontrol.h | 167 ---- sbin/iscontrol/login.c | 442 ----------- sbin/iscontrol/misc.c | 228 ------ sbin/iscontrol/pdu.c | 178 ----- share/man/man4/Makefile | 1 - share/man/man4/iscsi_initiator.4 | 118 --- sys/conf/NOTES | 1 - sys/conf/files | 6 - sys/dev/iscsi_initiator/isc_cam.c | 351 -------- sys/dev/iscsi_initiator/isc_sm.c | 750 ------------------ sys/dev/iscsi_initiator/isc_soc.c | 680 ---------------- sys/dev/iscsi_initiator/isc_subr.c | 184 ----- sys/dev/iscsi_initiator/iscsi.c | 880 --------------------- sys/dev/iscsi_initiator/iscsi.h | 502 ------------ sys/dev/iscsi_initiator/iscsi_subr.c | 603 -------------- sys/dev/iscsi_initiator/iscsivar.h | 571 ------------- sys/modules/Makefile | 1 - sys/modules/iscsi_initiator/Makefile | 14 - targets/pseudo/userland/Makefile.depend | 1 - tools/build/mk/OptionalObsoleteFiles.inc | 3 - .../kerneldoc/subsys/Doxyfile-dev_iscsi_initiator | 21 - usr.bin/iscsictl/iscsi.conf.5 | 5 +- usr.bin/iscsictl/iscsictl.8 | 15 - 32 files changed, 6 insertions(+), 7509 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index b6a2d299bc8c..c60629197386 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -40,6 +40,11 @@ # xargs -n1 | sort | uniq -d; # done +# 20211026: retire obsolete iscsi initiator +OLD_FILES+=sbin/iscontrol +OLD_FILES+=usr/share/man/man4/iscsi_initiator.4.gz +OLD_FILES+=usr/share/man/man8/iscontrol.8.gz + # 20211022 OLD_FILES+=sbin/spppcontrol .if ${TARGET_ARCH} == "i386" diff --git a/sbin/Makefile b/sbin/Makefile index b4da58680458..7eb497e3e3dd 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -76,7 +76,6 @@ SUBDIR.${MK_INET6}+= rtsol SUBDIR.${MK_IPFILTER}+= ipf SUBDIR.${MK_IPFW}+= ipfw SUBDIR.${MK_IPFW}+= natd -SUBDIR.${MK_ISCSI}+= iscontrol SUBDIR.${MK_NVME}+= nvmecontrol SUBDIR.${MK_OPENSSL}+= decryptcore SUBDIR.${MK_PF}+= pfctl diff --git a/sbin/iscontrol/Makefile b/sbin/iscontrol/Makefile deleted file mode 100644 index 613444a468f4..000000000000 --- a/sbin/iscontrol/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -PACKAGE=iscsilegacy -SRCS= iscontrol.c pdu.c fsm.c config.c login.c auth_subr.c misc.c -PROG= iscontrol -LIBADD= cam md -S= ${SRCTOP}/sys - -WARNS?= 3 -CFLAGS+= -I$S - -MAN= iscontrol.8 - -.include <bsd.prog.mk> diff --git a/sbin/iscontrol/Makefile.depend b/sbin/iscontrol/Makefile.depend deleted file mode 100644 index c800a3df77c3..000000000000 --- a/sbin/iscontrol/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcam \ - lib/libcompiler_rt \ - lib/libmd \ - lib/libsbuf \ - - -.include <dirdeps.mk> - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/sbin/iscontrol/auth_subr.c b/sbin/iscontrol/auth_subr.c deleted file mode 100644 index a4c17ba20868..000000000000 --- a/sbin/iscontrol/auth_subr.c +++ /dev/null @@ -1,206 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005-2010 Daniel Braniss <danny@cs.huji.ac.il> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - */ - -/* - | $Id: auth_subr.c,v 2.2 2007/06/01 08:09:37 danny Exp $ - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/sysctl.h> - -#include <netinet/in.h> -#include <netinet/tcp.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <fcntl.h> - -#include <md5.h> -#include <sha.h> - -#include <dev/iscsi_initiator/iscsi.h> -#include "iscontrol.h" - -static int -chapMD5(char id, char *cp, char *chapSecret, unsigned char *digest) -{ - MD5_CTX ctx; - char *tmp; - int len; - - debug_called(3); - - MD5Init(&ctx); - - MD5Update(&ctx, &id, 1); - - if((len = str2bin(chapSecret, &tmp)) == 0) { - // print error - return -1; - } - MD5Update(&ctx, tmp, len); - free(tmp); - - if((len = str2bin(cp, &tmp)) == 0) { - // print error - return -1; - } - MD5Update(&ctx, tmp, len); - free(tmp); - - MD5Final(digest, &ctx); - - - return 0; -} - -static int -chapSHA1(char id, char *cp, char *chapSecret, unsigned char *digest) -{ - SHA1_CTX ctx; - char *tmp; - int len; - - debug_called(3); - - SHA1_Init(&ctx); - - SHA1_Update(&ctx, &id, 1); - - if((len = str2bin(chapSecret, &tmp)) == 0) { - // print error - return -1; - } - SHA1_Update(&ctx, tmp, len); - free(tmp); - - if((len = str2bin(cp, &tmp)) == 0) { - // print error - return -1; - } - SHA1_Update(&ctx, tmp, len); - free(tmp); - - SHA1_Final(digest, &ctx); - - return 0; - -} -/* - | the input text format can be anything that the rfc3270 defines - | (see section 5.1 and str2bin) - | digest length for md5 is 128bits, and for sha1 is 160bits. - | digest is an ASCII string which represents the bits in - | hexadecimal or base64 according to the challenge(cp) format - */ -char * -chapDigest(char *ap, char id, char *cp, char *chapSecret) -{ - int len; - unsigned char digest[20]; - char encoding[3]; - - debug_called(3); - - len = 0; - if(strcmp(ap, "5") == 0 && chapMD5(id, cp, chapSecret, digest) == 0) - len = 16; - else - if(strcmp(ap, "7") == 0 && chapSHA1(id, cp, chapSecret, digest) == 0) - len = 20; - - if(len) { - sprintf(encoding, "%.2s", cp); - return bin2str(encoding, digest, len); - } - - return NULL; -} - -char * -genChapChallenge(char *encoding, uint len) -{ - int fd; - unsigned char tmp[1024]; - - if(len > sizeof(tmp)) - return NULL; - - if((fd = open("/dev/random", O_RDONLY)) != -1) { - read(fd, tmp, len); - close(fd); - return bin2str(encoding, tmp, len); - } - perror("/dev/random"); - // make up something ... - return NULL; -} - -#ifdef TEST_AUTH -static void -puke(char *str, unsigned char *dg, int len) -{ - printf("%3d] %s\n 0x", len, str); - while(len-- > 0) - printf("%02x", *dg++); - printf("\n"); -} - -main(int cc, char **vv) -{ - char *p, *ap, *ip, *cp, *chapSecret, *digest; - int len; - -#if 0 - ap = "5"; - chapSecret = "0xa5aff013dd839b1edd31ee73a1df0b1b"; -// chapSecret = "abcdefghijklmnop"; - len = str2bin(chapSecret, &cp); - puke(chapSecret, cp, len); - - ip = "238"; - cp = "0xbd456029"; - - - if((digest = chapDigest(ap, ip, cp, chapSecret)) != NULL) { - len = str2bin(digest, &cp); - puke(digest, cp, len); - } -#else - printf("%d] %s\n", 24, genChallenge("0X", 24)); -#endif -} -#endif diff --git a/sbin/iscontrol/config.c b/sbin/iscontrol/config.c deleted file mode 100644 index 2fe44512f311..000000000000 --- a/sbin/iscontrol/config.c +++ /dev/null @@ -1,382 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005-2009 Daniel Braniss <danny@cs.huji.ac.il> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - */ -/* - | $Id: config.c,v 2.1 2006/11/12 08:06:51 danny Exp danny $ - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stdlib.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <fcntl.h> -#include <time.h> -#include <ctype.h> -#include <camlib.h> - -#include <dev/iscsi_initiator/iscsi.h> -#include "iscontrol.h" - -/* - | ints - */ -#define OPT_port 1 -#define OPT_tags 2 - -#define OPT_maxConnections 3 -#define OPT_maxRecvDataSegmentLength 4 -#define OPT_maxXmitDataSegmentLength 5 -#define OPT_maxBurstLength 6 -#define OPT_firstBurstLength 7 -#define OPT_defaultTime2Wait 8 -#define OPT_defaultTime2Retain 9 -#define OPT_maxOutstandingR2T 10 -#define OPT_errorRecoveryLevel 11 -#define OPT_targetPortalGroupTag 12 -#define OPT_headerDigest 13 -#define OPT_dataDigest 14 -/* - | Booleans - */ -#define OPT_initialR2T 16 -#define OPT_immediateData 17 -#define OPT_dataPDUInOrder 18 -#define OPT_dataSequenceInOrder 19 -/* - | strings - */ -#define OPT_sessionType 15 - -#define OPT_targetAddress 21 -#define OPT_targetAlias 22 -#define OPT_targetName 23 -#define OPT_initiatorName 24 -#define OPT_initiatorAlias 25 -#define OPT_authMethod 26 - -#define OPT_chapSecret 27 -#define OPT_chapIName 28 -#define OPT_chapDigest 29 -#define OPT_tgtChapName 30 -#define OPT_tgtChapSecret 31 -#define OPT_tgtChallengeLen 32 -/* - | private - */ -#define OPT_maxluns 33 -#define OPT_iqn 34 -#define OPT_sockbufsize 35 - -/* - | sentinel - */ -#define OPT_end 0 - -#define _OFF(v) ((int)&((isc_opt_t *)NULL)->v) -#define _E(u, s, v) {.usage=u, .scope=s, .name=#v, .tokenID=OPT_##v} - -textkey_t keyMap[] = { - _E(U_PR, S_PR, port), - _E(U_PR, S_PR, tags), - _E(U_PR, S_PR, maxluns), - _E(U_PR, S_PR, sockbufsize), - - _E(U_PR, S_PR, iqn), - _E(U_PR, S_PR, chapSecret), - _E(U_PR, S_PR, chapIName), - _E(U_PR, S_PR, chapDigest), - _E(U_PR, S_PR, tgtChapName), - _E(U_PR, S_PR, tgtChapSecret), - _E(U_PR, S_PR, tgtChallengeLen), - - _E(U_IO, S_CO, headerDigest), - _E(U_IO, S_CO, dataDigest), - - _E(U_IO, S_CO, authMethod), - - _E(U_LO, S_SW, maxConnections), - _E(U_IO, S_SW, targetName), - - _E(U_IO, S_SW, initiatorName), - _E(U_ALL,S_SW, targetAlias), - _E(U_ALL,S_SW, initiatorAlias), - _E(U_ALL,S_SW, targetAddress), - - _E(U_ALL,S_SW, targetPortalGroupTag), - - _E(U_LO, S_SW, initialR2T), - _E(U_LO, S_SW, immediateData), - - _E(U_ALL,S_CO, maxRecvDataSegmentLength), - _E(U_ALL,S_CO, maxXmitDataSegmentLength), - - _E(U_LO, S_SW, maxBurstLength), - _E(U_LO, S_SW, firstBurstLength), - _E(U_LO, S_SW, defaultTime2Wait), - _E(U_LO, S_SW, defaultTime2Retain), - - _E(U_LO, S_SW, maxOutstandingR2T), - _E(U_LO, S_SW, dataPDUInOrder), - _E(U_LO, S_SW, dataSequenceInOrder), - - _E(U_LO, S_SW, errorRecoveryLevel), - - _E(U_LO, S_SW, sessionType), - - _E(0, 0, end) -}; - -#define _OPT_INT(w) strtol((char *)w, NULL, 0) -#define _OPT_STR(w) (char *)(w) - -static __inline int -_OPT_BOOL(char *w) -{ - if(isalpha((unsigned char)*w)) - return strcasecmp(w, "TRUE") == 0; - else - return _OPT_INT(w); -} - -#define _CASE(k, v) case OPT_##k: op->k = v; break -static void -setOption(isc_opt_t *op, int which, void *rval) -{ - switch(which) { - _CASE(port, _OPT_INT(rval)); - _CASE(tags, _OPT_INT(rval)); - _CASE(maxluns, _OPT_INT(rval)); - _CASE(iqn, _OPT_STR(rval)); - _CASE(sockbufsize, _OPT_INT(rval)); - - _CASE(maxConnections, _OPT_INT(rval)); - _CASE(maxRecvDataSegmentLength, _OPT_INT(rval)); - _CASE(maxXmitDataSegmentLength, _OPT_INT(rval)); - _CASE(maxBurstLength, _OPT_INT(rval)); - _CASE(firstBurstLength, _OPT_INT(rval)); - _CASE(defaultTime2Wait, _OPT_INT(rval)); - _CASE(defaultTime2Retain, _OPT_INT(rval)); - _CASE(maxOutstandingR2T, _OPT_INT(rval)); - _CASE(errorRecoveryLevel, _OPT_INT(rval)); - _CASE(targetPortalGroupTag, _OPT_INT(rval)); - _CASE(headerDigest, _OPT_STR(rval)); - _CASE(dataDigest, _OPT_STR(rval)); - - _CASE(targetAddress, _OPT_STR(rval)); - _CASE(targetAlias, _OPT_STR(rval)); - _CASE(targetName, _OPT_STR(rval)); - _CASE(initiatorName, _OPT_STR(rval)); - _CASE(initiatorAlias, _OPT_STR(rval)); - _CASE(authMethod, _OPT_STR(rval)); - _CASE(chapSecret, _OPT_STR(rval)); - _CASE(chapIName, _OPT_STR(rval)); - _CASE(chapDigest, _OPT_STR(rval)); - - _CASE(tgtChapName, _OPT_STR(rval)); - _CASE(tgtChapSecret, _OPT_STR(rval)); - - _CASE(initialR2T, _OPT_BOOL(rval)); - _CASE(immediateData, _OPT_BOOL(rval)); - _CASE(dataPDUInOrder, _OPT_BOOL(rval)); - _CASE(dataSequenceInOrder, _OPT_BOOL(rval)); - } -} - -static char * -get_line(FILE *fd) -{ - static char *sp, line[BUFSIZ]; - char *lp, *p; - - do { - if(sp == NULL) - sp = fgets(line, sizeof line, fd); - - if((lp = sp) == NULL) - break; - if((p = strchr(lp, '\n')) != NULL) - *p = 0; - if((p = strchr(lp, '#')) != NULL) - *p = 0; - if((p = strchr(lp, ';')) != NULL) { - *p++ = 0; - sp = p; - } else - sp = NULL; - if(*lp) - return lp; - } while (feof(fd) == 0); - return NULL; -} - -static int -getConfig(FILE *fd, char *key, char **Ar, int *nargs) -{ - char *lp, *p, **ar; - int state, len, n; - - ar = Ar; - if(key) - len = strlen(key); - else - len = 0; - state = 0; - while((lp = get_line(fd)) != NULL) { - for(; isspace((unsigned char)*lp); lp++) - ; - switch(state) { - case 0: - if((p = strchr(lp, '{')) != NULL) { - while((--p > lp) && *p && isspace((unsigned char)*p)); - n = p - lp; - if(len && strncmp(lp, key, MAX(n, len)) == 0) - state = 2; - else - state = 1; - continue; - } - break; - - case 1: - if(*lp == '}') - state = 0; - continue; - - case 2: - if(*lp == '}') - goto done; - - break; - } - - - for(p = &lp[strlen(lp)-1]; isspace((unsigned char)*p); p--) - *p = 0; - if((*nargs)-- > 0) - *ar++ = strdup(lp); - } - - done: - if(*nargs > 0) - *ar = 0; - *nargs = ar - Ar; - return ar - Ar; -} - -static textkey_t * -keyLookup(char *key) -{ - textkey_t *tk; - - for(tk = keyMap; tk->name && strcmp(tk->name, "end"); tk++) { - if(strcasecmp(key, tk->name) == 0) - return tk; - } - return NULL; -} - -static void -puke(isc_opt_t *op) -{ - printf("%24s = %d\n", "port", op->port); - printf("%24s = %d\n", "tags", op->tags); - printf("%24s = %d\n", "maxluns", op->maxluns); - printf("%24s = %s\n", "iqn", op->iqn); - - printf("%24s = %d\n", "maxConnections", op->maxConnections); - printf("%24s = %d\n", "maxRecvDataSegmentLength", op->maxRecvDataSegmentLength); - printf("%24s = %d\n", "maxXmitDataSegmentLength", op->maxRecvDataSegmentLength); - printf("%24s = %d\n", "maxBurstLength", op->maxBurstLength); - printf("%24s = %d\n", "firstBurstLength", op->firstBurstLength); - printf("%24s = %d\n", "defaultTime2Wait", op->defaultTime2Wait); - printf("%24s = %d\n", "defaultTime2Retain", op->defaultTime2Retain); - printf("%24s = %d\n", "maxOutstandingR2T", op->maxOutstandingR2T); - printf("%24s = %d\n", "errorRecoveryLevel", op->errorRecoveryLevel); - printf("%24s = %d\n", "targetPortalGroupTag", op->targetPortalGroupTag); - - printf("%24s = %s\n", "headerDigest", op->headerDigest); - printf("%24s = %s\n", "dataDigest", op->dataDigest); - - printf("%24s = %d\n", "initialR2T", op->initialR2T); - printf("%24s = %d\n", "immediateData", op->immediateData); - printf("%24s = %d\n", "dataPDUInOrder", op->dataPDUInOrder); - printf("%24s = %d\n", "dataSequenceInOrder", op->dataSequenceInOrder); - - printf("%24s = %s\n", "sessionType", op->sessionType); - printf("%24s = %s\n", "targetAddress", op->targetAddress); - printf("%24s = %s\n", "targetAlias", op->targetAlias); - printf("%24s = %s\n", "targetName", op->targetName); - printf("%24s = %s\n", "initiatorName", op->initiatorName); - printf("%24s = %s\n", "initiatorAlias", op->initiatorAlias); - printf("%24s = %s\n", "authMethod", op->authMethod); - printf("%24s = %s\n", "chapSecret", op->chapSecret); - printf("%24s = %s\n", "chapIName", op->chapIName); - printf("%24s = %s\n", "tgtChapName", op->tgtChapName); - printf("%24s = %s\n", "tgtChapSecret", op->tgtChapSecret); - printf("%24s = %d\n", "tgttgtChallengeLen", op->tgtChallengeLen); -} - -void -parseArgs(int nargs, char **args, isc_opt_t *op) -{ - char **ar; - char *p, *v; - textkey_t *tk; - - for(ar = args; nargs > 0; nargs--, ar++) { - p = strchr(*ar, '='); - if(p == NULL) - continue; - *p = 0; - v = p + 1; - while(isspace((unsigned char)*--p)) - *p = 0; - while(isspace((unsigned char)*v)) - v++; - if((tk = keyLookup(*ar)) == NULL) - continue; - setOption(op, tk->tokenID, v); - } -} - -void -parseConfig(FILE *fd, char *key, isc_opt_t *op) -{ - char *Ar[256]; - int cc; - - cc = 256; - if(getConfig(fd, key, Ar, &cc)) - parseArgs(cc, Ar, op); - if(vflag) - puke(op); -} diff --git a/sbin/iscontrol/fsm.c b/sbin/iscontrol/fsm.c deleted file mode 100644 index 8efbe6667b16..000000000000 --- a/sbin/iscontrol/fsm.c +++ /dev/null @@ -1,759 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005-2010 Daniel Braniss <danny@cs.huji.ac.il> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - */ - -/* - | $Id: fsm.c,v 2.8 2007/05/19 16:34:21 danny Exp danny $ - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/sysctl.h> - -#include <netinet/in.h> -#include <netinet/tcp.h> -#include <arpa/inet.h> -#include <sys/ioctl.h> -#include <netdb.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <fcntl.h> -#include <time.h> -#include <syslog.h> -#include <stdarg.h> -#include <camlib.h> - -#include <dev/iscsi_initiator/iscsi.h> -#include "iscontrol.h" - -typedef enum { - T1 = 1, - T2, /*T3,*/ T4, T5, /*T6,*/ T7, T8, T9, - T10, T11, T12, T13, T14, T15, T16, T18 -} trans_t; - -/* - | now supports IPV6 - | thanks to: - | Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan - | ume@mahoroba.org ume@{,jp.}FreeBSD.org - | http://www.imasy.org/~ume/ - */ -static trans_t -tcpConnect(isess_t *sess) -{ - isc_opt_t *op = sess->op; - int val, sv_errno, soc; - struct addrinfo *res, *res0, hints; - char pbuf[10]; - - debug_called(3); - if(sess->flags & (SESS_RECONNECT|SESS_REDIRECT)) { - syslog(LOG_INFO, "%s", (sess->flags & SESS_RECONNECT) - ? "Reconnect": "Redirected"); - - debug(1, "%s", (sess->flags & SESS_RECONNECT) ? "Reconnect": "Redirected"); - shutdown(sess->soc, SHUT_RDWR); - //close(sess->soc); - sess->soc = -1; - - sess->flags &= ~SESS_CONNECTED; - if(sess->flags & SESS_REDIRECT) { - sess->redirect_cnt++; - sess->flags |= SESS_RECONNECT; - } else - sleep(2); // XXX: actually should be ? -#ifdef notyet - { - time_t sec; - // make sure we are not in a loop - // XXX: this code has to be tested - sec = time(0) - sess->reconnect_time; - if(sec > (5*60)) { - // if we've been connected for more that 5 minutes - // then just reconnect - sess->reconnect_time = sec; - sess->reconnect_cnt1 = 0; - } - else { - // - sess->reconnect_cnt1++; - if((sec / sess->reconnect_cnt1) < 2) { - // if less that 2 seconds from the last reconnect - // we are most probably looping - syslog(LOG_CRIT, "too many reconnects %d", sess->reconnect_cnt1); - return 0; - } - } - } -#endif - sess->reconnect_cnt++; - } - - snprintf(pbuf, sizeof(pbuf), "%d", op->port); - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - debug(1, "targetAddress=%s port=%d", op->targetAddress, op->port); - if((val = getaddrinfo(op->targetAddress, pbuf, &hints, &res0)) != 0) { - fprintf(stderr, "getaddrinfo(%s): %s\n", op->targetAddress, gai_strerror(val)); - return 0; - } - sess->flags &= ~SESS_CONNECTED; - sv_errno = 0; - soc = -1; - for(res = res0; res; res = res->ai_next) { - soc = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (soc == -1) - continue; - - // from Patrick.Guelat@imp.ch: - // iscontrol can be called without waiting for the socket entry to time out - val = 1; - if(setsockopt(soc, SOL_SOCKET, SO_REUSEADDR, &val, (socklen_t)sizeof(val)) < 0) { - fprintf(stderr, "Cannot set socket SO_REUSEADDR %d: %s\n\n", - errno, strerror(errno)); - } - - if(connect(soc, res->ai_addr, res->ai_addrlen) == 0) - break; - sv_errno = errno; - close(soc); - soc = -1; - } - freeaddrinfo(res0); - if(soc != -1) { - sess->soc = soc; - -#if 0 - struct timeval timeout; - - val = 1; - if(setsockopt(sess->soc, IPPROTO_TCP, TCP_KEEPALIVE, &val, sizeof(val)) < 0) - fprintf(stderr, "Cannot set socket KEEPALIVE option err=%d %s\n", - errno, strerror(errno)); - - if(setsockopt(sess->soc, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) < 0) - fprintf(stderr, "Cannot set socket NO delay option err=%d %s\n", - errno, strerror(errno)); - - timeout.tv_sec = 10; - timeout.tv_usec = 0; - if((setsockopt(sess->soc, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0) - || (setsockopt(sess->soc, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)) { - fprintf(stderr, "Cannot set socket timeout to %ld err=%d %s\n", - timeout.tv_sec, errno, strerror(errno)); - } -#endif -#ifdef CURIOUS - { - int len = sizeof(val); - if(getsockopt(sess->soc, SOL_SOCKET, SO_SNDBUF, &val, &len) == 0) - fprintf(stderr, "was: SO_SNDBUF=%dK\n", val/1024); - } -#endif - if(sess->op->sockbufsize) { - val = sess->op->sockbufsize * 1024; - if((setsockopt(sess->soc, SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)) < 0) - || (setsockopt(sess->soc, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)) < 0)) { - fprintf(stderr, "Cannot set socket sndbuf & rcvbuf to %d err=%d %s\n", - val, errno, strerror(errno)); - return 0; - } - } - sess->flags |= SESS_CONNECTED; - return T1; - } - - fprintf(stderr, "errno=%d\n", sv_errno); - perror("connect"); - switch(sv_errno) { - case ECONNREFUSED: - case EHOSTUNREACH: - case ENETUNREACH: - case ETIMEDOUT: - if((sess->flags & SESS_REDIRECT) == 0) { - if(strcmp(op->targetAddress, sess->target.address) != 0) { - syslog(LOG_INFO, "reconnecting to original target address"); - free(op->targetAddress); - op->targetAddress = sess->target.address; - op->port = sess->target.port; - op->targetPortalGroupTag = sess->target.pgt; - return T1; - } - } - sleep(5); // for now ... - return T1; - default: - return 0; // terminal error - } -} - -int -setOptions(isess_t *sess, int flag) -{ - isc_opt_t oop; - char *sep; - - debug_called(3); - - bzero(&oop, sizeof(isc_opt_t)); - - if((flag & SESS_FULLFEATURE) == 0) { - oop.initiatorName = sess->op->initiatorName; - oop.targetAddress = sess->op->targetAddress; - if(sess->op->targetName != 0) - oop.targetName = sess->op->targetName; - - oop.maxRecvDataSegmentLength = sess->op->maxRecvDataSegmentLength; - oop.maxXmitDataSegmentLength = sess->op->maxXmitDataSegmentLength; // XXX: - oop.maxBurstLength = sess->op->maxBurstLength; - oop.maxluns = sess->op->maxluns; - } - else { - /* - | turn on digestion only after login - */ - if(sess->op->headerDigest != NULL) { - sep = strchr(sess->op->headerDigest, ','); - if(sep == NULL) *** 6836 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110262017.19QKHta1051755>