diff options
author | Charles Ting <Charles.Ting@Sun.COM> | 2009-03-27 16:08:25 -0400 |
---|---|---|
committer | Charles Ting <Charles.Ting@Sun.COM> | 2009-03-27 16:08:25 -0400 |
commit | 15ab2a72991d84ff601ecdbb27140f2dfcf91c61 (patch) | |
tree | 34f434adb39de295095e203780a85c2eea6f15b6 | |
parent | 48fe8920e23b4b291a6781c7307729f849003c16 (diff) | |
download | illumos-gate-15ab2a72991d84ff601ecdbb27140f2dfcf91c61.tar.gz |
6802995 iSCSI Target b99 - iscsitgt doesn't work any more with the GlobalSAN initiator
-rw-r--r-- | usr/src/cmd/iscsi/iscsitgtd/util.c | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/usr/src/cmd/iscsi/iscsitgtd/util.c b/usr/src/cmd/iscsi/iscsitgtd/util.c index 20b348a584..dfb767ec72 100644 --- a/usr/src/cmd/iscsi/iscsitgtd/util.c +++ b/usr/src/cmd/iscsi/iscsitgtd/util.c @@ -439,6 +439,8 @@ parse_text(iscsi_conn_t *c, int dlen, char **text, int *text_length, char param_rsp[32]; int plen; /* pair length */ Boolean_t rval = True; + char *target_name = NULL; + char *initiator_name = NULL; char param_buf[16]; if ((p = (char *)malloc(dlen)) == NULL) @@ -581,29 +583,7 @@ parse_text(iscsi_conn_t *c, int dlen, char **text, int *text_length, } else if (strcmp("TargetName", cur_pair) == 0) { send_named_msg(c, msg_target_name, n); - - /* - * Had to wait until now before loading any parameters - * because they are based on the TargetName which - * hasn't been known until now. This might fail - * because the target doesn't exist or the initiator - * doesn't have permission to access this target. - */ - if ((rval = connection_parameters_get(c, n)) == False) { - *errcode = - (ISCSI_STATUS_CLASS_INITIATOR_ERR << 8) | - ISCSI_LOGIN_STATUS_TGT_FORBIDDEN; - } else if ((rval = add_text(text, text_length, - "TargetAlias", c->c_targ_alias)) == True) { - - /* - * Add TPGT now - */ - (void) snprintf(param_buf, sizeof (param_buf), - "%d", c->c_tpgt); - rval = add_text(text, text_length, - "TargetPortalGroupTag", param_buf); - } + target_name = n; /* * 12.5 -- IntiatorName @@ -612,6 +592,7 @@ parse_text(iscsi_conn_t *c, int dlen, char **text, int *text_length, } else if (strcmp("InitiatorName", cur_pair) == 0) { send_named_msg(c, msg_initiator_name, n); + initiator_name = n; /* ---- Section 12.6 is handled within TargetName ---- */ @@ -826,6 +807,35 @@ parse_text(iscsi_conn_t *c, int dlen, char **text, int *text_length, c->c_num, cur_pair, n); } + /* + * If parsed both Initiator and Target names have been parsed, + * then it is now time to load the connection parameters. + * + * This may fail because the target doesn't exist or the + * initiator doesn't have permission to access this target. + */ + if ((target_name != NULL) && (initiator_name != NULL)) { + if ((rval = connection_parameters_get(c, target_name)) + == False) { + if ((errcode != NULL) && (*errcode == 0)) + *errcode = + (ISCSI_STATUS_CLASS_INITIATOR_ERR + << 8) | + ISCSI_LOGIN_STATUS_TGT_FORBIDDEN; + } else if ((rval = add_text(text, text_length, + "TargetAlias", c->c_targ_alias)) == True) { + + /* + * Add TPGT now + */ + (void) snprintf(param_buf, sizeof (param_buf), + "%d", c->c_tpgt); + rval = add_text(text, text_length, + "TargetPortalGroupTag", param_buf); + target_name = initiator_name = NULL; + } + } + if (rval == False) { /* * Make sure the caller wants error status and that it |