Index: proc-0.4.10/include/iet_u.h diff -u proc-0.4.10/include/iet_u.h:1.1 proc-0.4.10/include/iet_u.h:1.3 --- proc-0.4.10/include/iet_u.h:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/include/iet_u.h Fri Jun 24 19:10:20 2005 @@ -77,8 +77,15 @@ }; enum { + key_incoming_user, + key_outgoing_user, + acct_key_last, +}; + +enum { key_session, key_target, + /* key_acct */ }; struct iscsi_param_info { @@ -113,6 +120,10 @@ #define NETLINK_IET 12 +#define PROC_LUN_TAG "Lun" +#define PROC_TRGT_PARAM_TAG "trgt_param" +#define PROC_SESS_PARAM_TAG "sess_param" + #define ADD_TARGET _IOW('i', 0, struct target_info) #define DEL_TARGET _IOW('i', 1, struct target_info) #define START_TARGET _IO('i', 2) Index: proc-0.4.10/kernel/config.c diff -u proc-0.4.10/kernel/config.c:1.1 proc-0.4.10/kernel/config.c:1.2 --- proc-0.4.10/kernel/config.c:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/kernel/config.c Fri Jun 24 16:00:11 2005 @@ -14,10 +14,24 @@ struct file_operations *fops; }; +static int iet_tgtcfg_seq_open(struct inode *inode, struct file *file) +{ + return single_open(file, iet_proc_tgtcfg, NULL); +} + +static struct file_operations config_seq_fops = { + .owner = THIS_MODULE, + .open = iet_tgtcfg_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static struct proc_entries iet_proc_entries[] = { {"volume", &volume_seq_fops}, {"session", &session_seq_fops}, + {"tgtcfg", &config_seq_fops}, }; static struct proc_dir_entry *proc_iet_dir; Index: proc-0.4.10/kernel/file-io.c diff -u proc-0.4.10/kernel/file-io.c:1.1 proc-0.4.10/kernel/file-io.c:1.2 --- proc-0.4.10/kernel/file-io.c:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/kernel/file-io.c Fri Jun 24 16:00:11 2005 @@ -262,6 +262,41 @@ seq_printf(seq, " path:%s\n", p->path); } +int fileio_showcfg(struct iet_volume *lu, struct seq_file *seq) +{ + struct fileio_data *p = (struct fileio_data *) lu->private; + +#if 0 + seq_printf(seq, " Path=%s,Type=%s\n", p->path, fileio.name); +#else + int i; + struct match_token *t; + + for (i = 0, t = tokens; i < sizeof(tokens)/sizeof(tokens[0]); i++, t++) { + seq_printf(seq, i?",":""); + switch (i) { + case Opt_type: + seq_printf(seq, t->pattern, fileio.name); + break; + case Opt_scsiid: + seq_printf(seq, t->pattern, lu->scsi_id); + // do we need to show all? + /* seq_printf(seq, "%x", lu->scsi_id); */ + break; + case Opt_path: + seq_printf(seq, t->pattern, p->path); + /*FALLTHROUGH*/ + case Opt_err: + break; + default: + seq_printf(seq, "??"); + break; + } + } +#endif + return 0; +} + struct iotype fileio = { .name = "fileio", @@ -270,4 +305,5 @@ .sync = fileio_sync, .detach = fileio_detach, .show = fileio_show, + .showcfg = fileio_showcfg, }; Index: proc-0.4.10/kernel/iotype.h diff -u proc-0.4.10/kernel/iotype.h:1.1 proc-0.4.10/kernel/iotype.h:1.2 --- proc-0.4.10/kernel/iotype.h:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/kernel/iotype.h Fri Jun 24 16:00:11 2005 @@ -17,6 +17,7 @@ int (*sync)(struct iet_volume *dev, struct tio *tio); void (*detach)(struct iet_volume *dev); void (*show)(struct iet_volume *dev, struct seq_file *seq); + int (*showcfg)(struct iet_volume *dev, struct seq_file *seq); }; extern struct iotype fileio; Index: proc-0.4.10/kernel/iscsi.h diff -u proc-0.4.10/kernel/iscsi.h:1.1 proc-0.4.10/kernel/iscsi.h:1.2 --- proc-0.4.10/kernel/iscsi.h:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/kernel/iscsi.h Fri Jun 24 16:00:11 2005 @@ -299,6 +299,7 @@ struct iscsi_target *target_lookup_by_id(u32); extern int target_add(struct target_info *); extern int target_del(u32 id); +extern int iet_proc_tgtcfg(struct seq_file *seq, void *v); /* config.c */ extern int iet_procfs_init(void); Index: proc-0.4.10/kernel/target.c diff -u proc-0.4.10/kernel/target.c:1.1 proc-0.4.10/kernel/target.c:1.5 --- proc-0.4.10/kernel/target.c:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/kernel/target.c Fri Jun 24 19:38:10 2005 @@ -7,6 +7,7 @@ #include "iscsi.h" #include "digest.h" #include "iscsi_dbg.h" +#include "iotype.h" #define MAX_NR_TARGETS (1UL << 30) @@ -279,3 +280,83 @@ return 0; } + +int iet_proc_tgtcfg(struct seq_file *seq, void *v) +{ + int err, tmp; + struct iscsi_target *target; + struct iet_volume *vol; + + if ((err = down_interruptible(&target_list_sem)) < 0) + return err; + +#define P(ptr, name) seq_printf(seq, "%d %d,", key_##name, (ptr)->name) +#define PrintTrgtParam(name) P(&target->trgt_param, name) +#define PrintSessParam(name) P(&target->sess_param, name) + + /* + * loose checking the return value of seq_printf(), + * since the possibility of filling an entire page is very low. + */ + list_for_each_entry(target, &target_list, t_list) { + seq_printf(seq, "%u,%s{", target->tid, target->name); + + /* + * Lun + */ + list_for_each_entry(vol, &target->volumes, list) { + seq_printf(seq, PROC_LUN_TAG "{%d,", vol->lun); + if (vol->iotype->showcfg) { + tmp = vol->iotype->showcfg(vol, seq); + if (tmp) goto end_of_loop; + } + tmp = seq_printf(seq, "},"); + if (tmp) goto end_of_loop; + } + + /* + * target parameters + */ + seq_printf(seq, PROC_TRGT_PARAM_TAG "{"); + PrintTrgtParam(wthreads); + PrintTrgtParam(target_type); + PrintTrgtParam(queued_cmnds); + tmp = seq_printf(seq, "},"); + if (tmp) goto end_of_loop; + + /* + * session parameters + */ + seq_printf(seq, PROC_SESS_PARAM_TAG "{"); + PrintSessParam(initial_r2t); + PrintSessParam(immediate_data); + PrintSessParam(max_connections); + PrintSessParam(max_data_pdu_length); + PrintSessParam(max_burst_length); + PrintSessParam(first_burst_length); + PrintSessParam(default_wait_time); + PrintSessParam(default_retain_time); + PrintSessParam(max_outstanding_r2t); + PrintSessParam(data_pdu_inorder); + PrintSessParam(data_sequence_inorder); + PrintSessParam(error_recovery_level); + PrintSessParam(header_digest); + PrintSessParam(data_digest); + PrintSessParam(ofmarker); + PrintSessParam(ifmarker); + PrintSessParam(ofmarkint); + PrintSessParam(ifmarkint); + tmp = seq_printf(seq, "}\n"); + + end_of_loop: + if ((err = target_lock(target, 1)) < 0) + break; + target_unlock(target); + err = tmp; + if (err) break; + } + + up(&target_list_sem); + + return err; +} Index: proc-0.4.10/usr/ietadm.c diff -u proc-0.4.10/usr/ietadm.c:1.1 proc-0.4.10/usr/ietadm.c:1.6 --- proc-0.4.10/usr/ietadm.c:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/usr/ietadm.c Fri Jun 24 19:59:35 2005 @@ -96,6 +96,10 @@ [OutgoingUser].\n\ If you don't specify a target (omit --tid option),\n\ you delete the account for discovery sessions.\n\ + --op show --tid=[id]\n\ + --op show\n\ + show the current configuration of all targets,\n\ + or one target specified by tid.\n\ --version display version and exit\n\ --help display this help and exit\n\ \n\ @@ -134,18 +138,31 @@ return err; } -static int ietd_response_recv(int fd) +static int ietd_response_recv(int fd, struct ietadm_rsp *rsp) { int err; - struct ietadm_rsp rsp; - if ((err = read(fd, &rsp, sizeof(rsp))) != sizeof(rsp)) { + if ((err = read(fd, rsp, sizeof(*rsp))) != sizeof(*rsp)) { fprintf(stderr, "%s %d %d\n", __FUNCTION__, __LINE__, err); if (err >= 0) err = -EIO; - } else - err = rsp.err; + } else { + err = rsp->err; + if (!rsp->size) goto out; + + rsp->data = malloc(rsp->size); + if (!rsp->data) { + err = -errno; + goto out; + } + if ((err = read(fd, rsp->data, rsp->size)) != rsp->size) { + fprintf(stderr, "%s %d %d\n", __FUNCTION__, __LINE__, err); + if (err >= 0) + err = -EIO; + } + } + out: return err; } @@ -168,9 +185,10 @@ return fd; } -static int ietd_request(struct ietadm_req *req) +static int ietd_request(struct ietadm_req *req, struct ietadm_rsp *rsp) { int fd = -1, err = -EIO; + struct ietadm_rsp tmp; if ((fd = ietd_connect()) < 0) { err = fd; @@ -180,7 +198,7 @@ if ((err = ietd_request_send(fd, req)) < 0) goto out; - err = ietd_response_recv(fd); + err = ietd_response_recv(fd, rsp?rsp:&tmp); out: if (fd > 0) @@ -225,6 +243,137 @@ return 0; } +static int show_lun(char *head, char **tail) +{ + char *p; + while (strncmp(head, PROC_LUN_TAG "{", sizeof(PROC_LUN_TAG)) == 0) { + printf("\t" PROC_LUN_TAG " "); + head += sizeof(PROC_LUN_TAG); + p = head+1; + while (*p != ',') p++; + *p = 0; + printf("%s ", head); + head = ++p; + while (*p != '}') p++; + *(p-1) = 0; + printf("%s\n", head); + head = p+2; + } + *tail = head; + return 0; +} + +static int show_param(char *head, char **tail, char tag[], struct iscsi_key keys[]) +{ + int i, e; + char *p; + char a[64]; + unsigned long val; + + i = strlen(tag); + if (strncmp(head, tag, i)) return 0; + + head += i+1; + i = 0; + *(a+sizeof(a)-1) = 0; + while (*head != '}') { + errno = 0; + i = strtoul(head, &p, 10); + if (errno) goto err; + head = p+1; + val = strtoul(head, &p, 10); + if (errno) goto err; + head = p+1; + + *a = 0; + param_val_to_str(keys, i, val, a); + if (*(a+sizeof(a)-1)) { + /* overrun? */ + errno = E2BIG; + goto err; + } + printf("\t%s %s\n", keys[i].name, a); + } + *tail = head+2; + return 0; + err: + e = errno; + perror(__func__); + while (head && !*head && *head != '}') head++; + return -e; +} + +static int user_handle(int op, u32 set, u32 tid, char *params); +static int show_acct(u32 tid) +{ + char a[64]; + int n, i; + +#define FakeStr "=fake" + for (i = 0; i < acct_key_last; i++) { + n = strlen(user_keys[i].name); + if (sizeof(a) < n+sizeof(FakeStr)) { + errno = E2BIG; + perror(__func__); + return -E2BIG; + } + strncpy(a, user_keys[i].name, sizeof(a)); + strncpy(a+n, FakeStr, sizeof(a)-n); + user_handle(OP_SHOW, SET_USER, tid, a); + } + + return 0; +} + +static int show_config(u32 tid) +{ + FILE *fp; + char a[BUFSIZ], *p, *o; + int doprt; + unsigned long ul; + + fp = fopen(PROC_TGTCFG, "r"); + if (!fp) return -1; + + printf("# discovery\n"); + show_acct(0); + + doprt = 0; + while(fgets(a, sizeof(a), fp)) { + if (strlen(a) >= BUFSIZ-1) { + fprintf(stderr, "internal error: expand the array\n"); + return -1; + } + + errno = 0; + ul = strtoul(a, &p, 10); + if (errno) { + perror("tid"); + return -1; + } + doprt = (!tid || tid == ul); + if (!doprt) continue; + + printf("\n# tid %lu\n", ul); + o = ++p; + while (*p != '{') p++; + *p = 0; + printf("Target %s\n", o); + + show_lun(p+1, &p); + show_acct(ul); + + printf("\t# target parameters\n"); + /* "Alias", "MaxSessions"; */ + show_param(p, &p, PROC_TRGT_PARAM_TAG, target_keys); + + printf("\t# session parameters\n"); + show_param(p, &p, PROC_SESS_PARAM_TAG, session_keys); + } + + return 0; +} + static int trgt_handle(int op, u32 set, u32 tid, char *params) { int err = -EINVAL; @@ -259,11 +408,10 @@ goto out; break; case OP_SHOW: - req.rcmnd = C_TRGT_SHOW; - break; + return show_config(tid); } - err = ietd_request(&req); + err = ietd_request(&req, NULL); out: return err; @@ -300,7 +448,7 @@ break; } - err = ietd_request(&req); + err = ietd_request(&req, NULL); out: return err; } @@ -335,6 +483,8 @@ int err = -EINVAL; char *p, *q, *user = NULL, *pass = NULL; struct ietadm_req req; + struct ietadm_rsp rsp; + char *show_kind = NULL; if (set & ~(SET_TARGET | SET_USER)) goto out; @@ -350,9 +500,11 @@ req.rcmnd = C_ACCT_DEL; break; case OP_UPDATE: - case OP_SHOW: fprintf(stderr, "Unsupported.\n"); goto out; + case OP_SHOW: + req.rcmnd = C_ACCT_SHOW; + break; } while ((p = strsep(¶ms, ",")) != NULL) { @@ -366,11 +518,13 @@ q++; if (!strcasecmp(p, "IncomingUser")) { + show_kind = "IncomingUser"; if (user) fprintf(stderr, "Already specified user %s\n", q); user = q; req.u.acnt.auth_dir = AUTH_DIR_INCOMING; } else if (!strcasecmp(p, "OutgoingUser")) { + show_kind = "OutgoingUser"; if (user) fprintf(stderr, "Already specified user %s\n", q); user = q; @@ -390,13 +544,31 @@ fprintf(stderr, "You need to specify a user and its password %s %s\n", pass, user); goto out; + } else if (op == OP_SHOW && !show_kind) { + errno = EINVAL; + err = -errno; + perror(NULL); + goto out; } - strncpy(req.u.acnt.user, user, sizeof(req.u.acnt.user) - 1); + if (user) + strncpy(req.u.acnt.user, user, sizeof(req.u.acnt.user) - 1); if (pass) strncpy(req.u.acnt.pass, pass, sizeof(req.u.acnt.pass) - 1); - err = ietd_request(&req); + err = ietd_request(&req, &rsp); + if (err < 0) goto out; + + if (op == OP_SHOW && rsp.size && rsp.data) { + struct msg_acnt *acct = rsp.data; + int n = rsp.size/sizeof(*acct); + while (n-- > 0) { + if (tid) printf("\t"); + printf("%s %s ****************\n", show_kind, acct->user); + acct++; + } + free(rsp.data); + } out: return err; } @@ -429,7 +601,7 @@ break; } - err = ietd_request(&req); + err = ietd_request(&req, NULL); out: return err; } @@ -450,10 +622,10 @@ case OP_UPDATE: break; case OP_SHOW: - break; + return show_config(0); } - err = ietd_request(&req); + err = ietd_request(&req, NULL); return err; } Index: proc-0.4.10/usr/ietadm.h diff -u proc-0.4.10/usr/ietadm.h:1.1 proc-0.4.10/usr/ietadm.h:1.2 --- proc-0.4.10/usr/ietadm.h:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/usr/ietadm.h Fri Jun 24 16:00:11 2005 @@ -73,6 +73,8 @@ struct ietadm_rsp { int err; + int size; + void *data; }; #endif Index: proc-0.4.10/usr/iscsid.h diff -u proc-0.4.10/usr/iscsid.h:1.1 proc-0.4.10/usr/iscsid.h:1.3 --- proc-0.4.10/usr/iscsid.h:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/usr/iscsid.h Fri Jun 24 19:10:20 2005 @@ -20,6 +20,7 @@ #define ISCSI_TARGET_DEFAULT_PORT 3260 #define PROC_SESSION "/proc/net/iet/session" +#define PROC_TGTCFG "/proc/net/iet/tgtcfg" struct PDU { struct iscsi_hdr bhs; Index: proc-0.4.10/usr/message.c diff -u proc-0.4.10/usr/message.c:1.1 proc-0.4.10/usr/message.c:1.3 --- proc-0.4.10/usr/message.c:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/usr/message.c Fri Jun 24 19:10:20 2005 @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,10 @@ static void ietadm_request_exec(struct ietadm_req *req, struct ietadm_rsp *rsp) { int err = 0; + struct qelem *list; + struct msg_acnt *acct; + int n; + struct user *user; log_debug(1, "%u %u %" PRIu64 " %u %u", req->rcmnd, req->tid, req->sid, req->cid, req->lun); @@ -101,8 +106,33 @@ err = cops->account_del(req->tid, req->u.acnt.auth_dir, req->u.acnt.user); break; case C_ACCT_UPDATE: + break; + case C_ACCT_SHOW: + list = account_list_get(req->tid, req->u.acnt.auth_dir); + if (!list || list_empty(list)) break; + + n = 0; + list_for_each_entry(user, list, ulist) + n++; + if (!n) break; + + rsp->size = n*sizeof(*acct); + rsp->data = acct = calloc(n, sizeof(*acct)); + if (!rsp->data) { + log_error("%s\n", "C_ACCT_SHOW failed calloc"); + err = -errno; + break; + } + + list_for_each_entry(user, list, ulist) { + acct->auth_dir = req->u.acnt.auth_dir; + strncpy(acct->user, user->name, sizeof(acct->user)); + /* strncpy(acct->pass, user->pass, sizeof(acct->pass)); */ + acct++; + } break; + case C_SYS_NEW: break; case C_SYS_DEL: @@ -127,6 +157,7 @@ socklen_t len; struct ietadm_req req; struct ietadm_rsp rsp; + void *tmp; memset(&rsp, 0, sizeof(rsp)); len = sizeof(addr); @@ -159,9 +190,18 @@ ietadm_request_exec(&req, &rsp); send: + tmp = rsp.data; + rsp.data = NULL; if ((err = write(fd, &rsp, sizeof(rsp))) != sizeof(rsp)) if (err >= 0) err = -EIO; + if (err > 0 && rsp.size && tmp) { + if ((err = write(fd, tmp, rsp.size)) != rsp.size) + if (err >= 0) + err = -EIO; + } + if (rsp.size && tmp) + free(tmp); out: if (fd > 0) close(fd); Index: proc-0.4.10/usr/param.c diff -u proc-0.4.10/usr/param.c:1.1 proc-0.4.10/usr/param.c:1.3 --- proc-0.4.10/usr/param.c:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/usr/param.c Fri Jun 24 19:10:20 2005 @@ -12,6 +12,49 @@ #include "iscsid.h" +/* + * Account configuration code + */ + +static struct qelem discovery_users_in = LIST_HEAD_INIT(discovery_users_in); +static struct qelem discovery_users_out = LIST_HEAD_INIT(discovery_users_out); +static struct qelem trgt_acct_in[1 << HASH_ORDER]; +static struct qelem trgt_acct_out[1 << HASH_ORDER]; + +struct qelem *account_list_get(u32 tid, int dir) +{ + struct qelem *list = NULL; + + if (tid) { + list = (dir == AUTH_DIR_INCOMING) ? + &trgt_acct_in[acct_hash(tid)] : &trgt_acct_out[acct_hash(tid)]; + } else + list = (dir == AUTH_DIR_INCOMING) + ? &discovery_users_in : &discovery_users_out; + + return list; +} + +int account_init(void) +{ + int i; + + for (i = 0; i < 1 << HASH_ORDER; i++) { + INIT_LIST_HEAD(&trgt_acct_in[i]); + INIT_LIST_HEAD(&trgt_acct_out[i]); + } + + return 0; +} + +struct iscsi_key user_keys[] = { + [key_incoming_user] = {"IncomingUser",}, + [key_outgoing_user] = {"OutgoingUser",}, + [acct_key_last] = {NULL,}, +}; + +/* ---------------------------------------------------------------------- */ + int param_index_by_name(char *name, struct iscsi_key *keys) { int i, err = -ENOENT; @@ -284,30 +327,51 @@ #define SET_KEY_VALUES(x) DEFAULT_NR_##x,MIN_NR_##x, MAX_NR_##x struct iscsi_key target_keys[] = { - {"Wthreads", SET_KEY_VALUES(WTHREADS), &minimum_ops}, - {"Type", 0, 16, 0, &minimum_ops}, - {"QueuedCommands", SET_KEY_VALUES(QUEUED_CMNDS), &minimum_ops}, - {NULL,}, + [key_wthreads] + = {"Wthreads", SET_KEY_VALUES(WTHREADS), &minimum_ops}, + [key_target_type] + = {"Type", 0, 16, 0, &minimum_ops}, + [key_queued_cmnds] + = {"QueuedCommands", SET_KEY_VALUES(QUEUED_CMNDS), &minimum_ops}, + [target_key_last] = {NULL,} }; struct iscsi_key session_keys[] = { - {"InitialR2T", 1, 0, 1, &or_ops}, - {"ImmediateData", 1, 0, 1, &and_ops}, - {"MaxConnections", 1, 1, 65535, &minimum_ops}, - {"MaxRecvDataSegmentLength", 8192, 512, 16777215, &minimum_ops}, - {"MaxBurstLength", 262144, 512, 16777215, &minimum_ops}, - {"FirstBurstLength", 65536, 512, 16777215, &minimum_ops}, - {"DefaultTime2Wait", 2, 0, 3600, &maximum_ops}, - {"DefaultTime2Retain", 20, 0, 3600, &minimum_ops}, - {"MaxOutstandingR2T", 1, 1, 65535, &minimum_ops}, - {"DataPDUInOrder", 1, 0, 1, &or_ops}, - {"DataSequenceInOrder", 1, 0, 1, &or_ops}, - {"ErrorRecoveryLevel", 0, 0, 2, &minimum_ops}, - {"HeaderDigest", DIGEST_NONE, DIGEST_NONE, DIGEST_ALL, &digest_ops}, - {"DataDigest", DIGEST_NONE, DIGEST_NONE, DIGEST_ALL, &digest_ops}, - {"OFMarker", 0, 0, 1, &and_ops}, - {"IFMarker", 0, 0, 1, &and_ops}, - {"OFMarkInt", 2048, 1, 65535, &marker_ops}, - {"IFMarkInt", 2048, 1, 65535, &marker_ops}, - {NULL,}, + [key_initial_r2t] + = {"InitialR2T", 1, 0, 1, &or_ops}, + [key_immediate_data] + = {"ImmediateData", 1, 0, 1, &and_ops}, + [key_max_connections] + = {"MaxConnections", 1, 1, 65535, &minimum_ops}, + [key_max_data_pdu_length] + = {"MaxRecvDataSegmentLength", 8192, 512, 16777215, &minimum_ops}, + [key_max_burst_length] + = {"MaxBurstLength", 262144, 512, 16777215, &minimum_ops}, + [key_first_burst_length] + = {"FirstBurstLength", 65536, 512, 16777215, &minimum_ops}, + [key_default_wait_time] + = {"DefaultTime2Wait", 2, 0, 3600, &maximum_ops}, + [key_default_retain_time] + = {"DefaultTime2Retain", 20, 0, 3600, &minimum_ops}, + [key_max_outstanding_r2t] + = {"MaxOutstandingR2T", 1, 1, 65535, &minimum_ops}, + [key_data_pdu_inorder] + = {"DataPDUInOrder", 1, 0, 1, &or_ops}, + [key_data_sequence_inorder] + = {"DataSequenceInOrder", 1, 0, 1, &or_ops}, + [key_error_recovery_level] + = {"ErrorRecoveryLevel", 0, 0, 2, &minimum_ops}, + [key_header_digest] + = {"HeaderDigest", DIGEST_NONE, DIGEST_NONE, DIGEST_ALL, &digest_ops}, + [key_data_digest] + = {"DataDigest", DIGEST_NONE, DIGEST_NONE, DIGEST_ALL, &digest_ops}, + [key_ofmarker] + = {"OFMarker", 0, 0, 1, &and_ops}, + [key_ifmarker] + = {"IFMarker", 0, 0, 1, &and_ops}, + [key_ofmarkint] + = {"OFMarkInt", 2048, 1, 65535, &marker_ops}, + [key_ifmarkint] + = {"IFMarkInt", 2048, 1, 65535, &marker_ops}, + [session_key_last] = {NULL,} }; Index: proc-0.4.10/usr/param.h diff -u proc-0.4.10/usr/param.h:1.1 proc-0.4.10/usr/param.h:1.2 --- proc-0.4.10/usr/param.h:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/usr/param.h Fri Jun 24 19:10:20 2005 @@ -7,6 +7,8 @@ #ifndef PARAMS_H #define PARAMS_H +#include "misc.h" + struct iscsi_key; struct iscsi_param { @@ -39,4 +41,23 @@ extern int param_check_val(struct iscsi_key *, int, unsigned int *); extern int param_set_val(struct iscsi_key *, struct iscsi_param *, int, unsigned int *); +/* + * Account configuration code + */ +struct user { + struct qelem ulist; + + u32 tid; + char *name; + char *password; +}; + +#define HASH_ORDER 4 +#define acct_hash(x) ((x) & ((1 << HASH_ORDER) - 1)) + +extern struct iscsi_key user_keys[]; + +extern struct qelem *account_list_get(u32 tid, int dir); +extern int account_init(void); + #endif Index: proc-0.4.10/usr/plain.c diff -u proc-0.4.10/usr/plain.c:1.1 proc-0.4.10/usr/plain.c:1.2 --- proc-0.4.10/usr/plain.c:1.1 Thu Jun 23 18:25:07 2005 +++ proc-0.4.10/usr/plain.c Fri Jun 24 16:00:11 2005 @@ -29,14 +29,6 @@ * Account configuration code */ -struct user { - struct qelem ulist; - - u32 tid; - char *name; - char *password; -}; - /* this is the orignal Ardis code. */ static char *target_sep_string(char **pp) { @@ -55,46 +47,14 @@ return p; } -static struct iscsi_key user_keys[] = { - {"IncomingUser",}, - {"OutgoingUser",}, - {NULL,}, -}; - -static struct qelem discovery_users_in = LIST_HEAD_INIT(discovery_users_in); -static struct qelem discovery_users_out = LIST_HEAD_INIT(discovery_users_out); - -#define HASH_ORDER 4 -#define acct_hash(x) ((x) & ((1 << HASH_ORDER) - 1)) - -static struct qelem trgt_acct_in[1 << HASH_ORDER]; -static struct qelem trgt_acct_out[1 << HASH_ORDER]; - -static struct qelem *account_list_get(u32 tid, int dir) -{ - struct qelem *list = NULL; - - if (tid) { - list = (dir == AUTH_DIR_INCOMING) ? - &trgt_acct_in[acct_hash(tid)] : &trgt_acct_out[acct_hash(tid)]; - } else - list = (dir == AUTH_DIR_INCOMING) - ? &discovery_users_in : &discovery_users_out; - - return list; -} - static int plain_account_init(char *filename) { FILE *fp; char buf[BUFSIZE], *p, *q; u32 tid; - int i, idx; + int idx; - for (i = 0; i < 1 << HASH_ORDER; i++) { - INIT_LIST_HEAD(&trgt_acct_in[i]); - INIT_LIST_HEAD(&trgt_acct_out[i]); - } + account_init(); if (!(fp = fopen(filename, "r"))) return -EIO; @@ -491,7 +451,7 @@ if ((err = plain_main_init(params ? params : CONFIG_FILE))) return err; - if ((err = plain_account_init(ACCT_CONFIG_FILE)) < 0) + if ((err = plain_account_init(params ? params : ACCT_CONFIG_FILE)) < 0) return err; /* TODO: error handling */