From a19ac24971214e6b14b9c50b377c24079523dbb5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 10 May 2017 15:30:51 +0100 Subject: [PATCH] [iscsi] Fix iBFT when no explicit initiator name setting exists Commit 7cfdd76 ("[block] Describe all SAN devices via ACPI tables") changed the definition of the iSCSI initiator IQN in the iBFT to represent a common initiator IQN used for all iSCSI sessions, and attempted to calculate this common initiator IQN by fetching the common ${initiator-iqn} setting. This fails when no explicit ${initiator-iqn} has been specified (i.e. when an initiator IQN has instead been constructed from either the hostname or system UUID), and results in an empty initiator IQN in the iBFT. Fix by using the initiator IQN of an arbitrary iSCSI session present in the iBFT. Debugged-by: Tal Aloni Signed-off-by: Michael Brown --- src/drivers/block/ibft.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/drivers/block/ibft.c b/src/drivers/block/ibft.c index bb7812b3..f9918363 100644 --- a/src/drivers/block/ibft.c +++ b/src/drivers/block/ibft.c @@ -338,10 +338,12 @@ static int ibft_fill_nic ( struct ibft_nic *nic, * * @v initiator Initiator portion of iBFT * @v strings iBFT string block descriptor + * @v initiator_iqn Initiator IQN * @ret rc Return status code */ static int ibft_fill_initiator ( struct ibft_initiator *initiator, - struct ibft_strings *strings ) { + struct ibft_strings *strings, + const char *initiator_iqn ) { int rc; /* Fill in common header */ @@ -352,9 +354,8 @@ static int ibft_fill_initiator ( struct ibft_initiator *initiator, IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED ); /* Fill in initiator name */ - if ( ( rc = ibft_set_string_setting ( NULL, strings, - &initiator->initiator_name, - &initiator_iqn_setting ) ) != 0 ) + if ( ( rc = ibft_set_string ( strings, &initiator->initiator_name, + initiator_iqn ) ) != 0 ) return rc; DBG ( "iBFT initiator name = %s\n", ibft_string ( strings, &initiator->initiator_name ) ); @@ -613,7 +614,10 @@ static int ibft_install ( int ( * install ) ( struct acpi_header *acpi ) ) { /* Fill in Initiator block */ initiator = ( data + initiator_offset ); table->control.initiator = cpu_to_le16 ( initiator_offset ); - if ( ( rc = ibft_fill_initiator ( initiator, &strings ) ) != 0 ) + iscsi = list_first_entry ( &ibft_model.descs, struct iscsi_session, + desc.list ); + if ( ( rc = ibft_fill_initiator ( initiator, &strings, + iscsi->initiator_iqn ) ) != 0 ) goto err_initiator; /* Fill in NIC blocks */