Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 271112
b: refs/heads/master
c: 28deb45
h: refs/heads/master
v: v3
  • Loading branch information
Lalit Chandivade authored and James Bottomley committed Oct 16, 2011
1 parent 8796c3b commit 1d6afb2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8de5b9582420acac5129ec7921711aded75406c0
refs/heads/master: 28deb45cea848e8389530b17c987339b62fea459
62 changes: 58 additions & 4 deletions trunk/drivers/scsi/qla4xxx/ql4_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -2877,6 +2877,60 @@ static int get_fw_boot_info(struct scsi_qla_host *ha, uint16_t ddb_index[])
return ret;
}

/**
* qla4xxx_get_bidi_chap - Get a BIDI CHAP user and password
* @ha: pointer to adapter structure
* @username: CHAP username to be returned
* @password: CHAP password to be returned
*
* If a boot entry has BIDI CHAP enabled then we need to set the BIDI CHAP
* user and password in the sysfs entry in /sys/firmware/iscsi_boot#/.
* So from the CHAP cache find the first BIDI CHAP entry and set it
* to the boot record in sysfs.
**/
static int qla4xxx_get_bidi_chap(struct scsi_qla_host *ha, char *username,
char *password)
{
int i, ret = -EINVAL;
int max_chap_entries = 0;
struct ql4_chap_table *chap_table;

if (is_qla8022(ha))
max_chap_entries = (ha->hw.flt_chap_size / 2) /
sizeof(struct ql4_chap_table);
else
max_chap_entries = MAX_CHAP_ENTRIES_40XX;

if (!ha->chap_list) {
ql4_printk(KERN_ERR, ha, "Do not have CHAP table cache\n");
return ret;
}

mutex_lock(&ha->chap_sem);
for (i = 0; i < max_chap_entries; i++) {
chap_table = (struct ql4_chap_table *)ha->chap_list + i;
if (chap_table->cookie !=
__constant_cpu_to_le16(CHAP_VALID_COOKIE)) {
continue;
}

if (chap_table->flags & BIT_7) /* local */
continue;

if (!(chap_table->flags & BIT_6)) /* Not BIDI */
continue;

strncpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN);
strncpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN);
ret = 0;
break;
}
mutex_unlock(&ha->chap_sem);

return ret;
}


static int qla4xxx_get_boot_target(struct scsi_qla_host *ha,
struct ql4_boot_session_info *boot_sess,
uint16_t ddb_index)
Expand Down Expand Up @@ -2948,10 +3002,10 @@ static int qla4xxx_get_boot_target(struct scsi_qla_host *ha,

DEBUG2(ql4_printk(KERN_INFO, ha, "Setting BIDI chap\n"));

ret = qla4xxx_get_chap(ha, (char *)&boot_conn->chap.
intr_chap_name,
(char *)&boot_conn->chap.intr_secret,
(idx + 1));
ret = qla4xxx_get_bidi_chap(ha,
(char *)&boot_conn->chap.intr_chap_name,
(char *)&boot_conn->chap.intr_secret);

if (ret) {
ql4_printk(KERN_ERR, ha, "Failed to set BIDI chap\n");
ret = QLA_ERROR;
Expand Down

0 comments on commit 1d6afb2

Please sign in to comment.