mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
ID: 70 - Fixes and updates for ipmitool hpm
Update HpmfwupgPreUpgradeCheck to check if the Aux version is also different when it compares the Image version to the active and rollback versions. Fixed the indenting and style of HpmfwupgPreUpgradeCheck to make it more readable. Commit for Dan Gora
This commit is contained in:
parent
2db7f5f6b9
commit
bf8acad458
@ -1019,7 +1019,6 @@ typedef struct _VERSIONINFO
|
|||||||
unsigned char imageAux[4];
|
unsigned char imageAux[4];
|
||||||
unsigned char coldResetRequired;
|
unsigned char coldResetRequired;
|
||||||
unsigned char rollbackSupported;
|
unsigned char rollbackSupported;
|
||||||
unsigned char skipUpgrade;
|
|
||||||
char descString[15];
|
char descString[15];
|
||||||
}VERSIONINFO, *PVERSIONINFO;
|
}VERSIONINFO, *PVERSIONINFO;
|
||||||
|
|
||||||
@ -1851,6 +1850,37 @@ int HpmfwupgPreparationStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx*
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int image_version_upgradable(VERSIONINFO *pVersionInfo)
|
||||||
|
{
|
||||||
|
/* If the image and active target versions are different, then
|
||||||
|
* upgrade */
|
||||||
|
if ((pVersionInfo->imageMajor != pVersionInfo->targetMajor) ||
|
||||||
|
(pVersionInfo->imageMinor != pVersionInfo->targetMinor) ||
|
||||||
|
(pVersionInfo->imageAux[0] != pVersionInfo->targetAux[0]) ||
|
||||||
|
(pVersionInfo->imageAux[1] != pVersionInfo->targetAux[1]) ||
|
||||||
|
(pVersionInfo->imageAux[2] != pVersionInfo->targetAux[2]) ||
|
||||||
|
(pVersionInfo->imageAux[3] != pVersionInfo->targetAux[3]))
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
/* If the image and active target versions are the same and rollback
|
||||||
|
* is not supported, then there's nothing to do, skip the upgrade */
|
||||||
|
if (!pVersionInfo->rollbackSupported)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
/* If the image and rollback target versions are different, then
|
||||||
|
* go ahead and upgrade */
|
||||||
|
if ((pVersionInfo->imageMajor != pVersionInfo->rollbackMajor) ||
|
||||||
|
(pVersionInfo->imageMinor != pVersionInfo->rollbackMinor) ||
|
||||||
|
(pVersionInfo->imageAux[0] != pVersionInfo->rollbackAux[0]) ||
|
||||||
|
(pVersionInfo->imageAux[1] != pVersionInfo->rollbackAux[1]) ||
|
||||||
|
(pVersionInfo->imageAux[2] != pVersionInfo->rollbackAux[2]) ||
|
||||||
|
(pVersionInfo->imageAux[3] != pVersionInfo->rollbackAux[3]))
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
/* Image and rollback target versions are the same too, skip it */
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Function Name: HpmfwupgPreUpgradeCheck
|
* Function Name: HpmfwupgPreUpgradeCheck
|
||||||
@ -1860,206 +1890,155 @@ int HpmfwupgPreparationStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx*
|
|||||||
* is same as target version.
|
* is same as target version.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwupgCtx,
|
int HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf,
|
||||||
int componentToUpload,int option)
|
struct HpmfwupgUpgradeCtx* pFwupgCtx,
|
||||||
|
int componentToUpload, int option)
|
||||||
{
|
{
|
||||||
int rc = HPMFWUPG_SUCCESS;
|
|
||||||
unsigned char* pImagePtr;
|
unsigned char* pImagePtr;
|
||||||
struct HpmfwupgActionRecord* pActionRecord;
|
struct HpmfwupgActionRecord *pActionRecord;
|
||||||
unsigned int actionsSize;
|
|
||||||
int flagColdReset = FALSE;
|
int flagColdReset = FALSE;
|
||||||
struct HpmfwupgImageHeader* pImageHeader = (struct HpmfwupgImageHeader*)
|
struct HpmfwupgImageHeader *pImageHeader;
|
||||||
pFwupgCtx->pImageData;
|
|
||||||
|
pImageHeader = (struct HpmfwupgImageHeader*) pFwupgCtx->pImageData;
|
||||||
|
|
||||||
/* Put pointer after image header */
|
/* Put pointer after image header */
|
||||||
pImagePtr = (unsigned char*)
|
pImagePtr = (unsigned char*)
|
||||||
(pFwupgCtx->pImageData + sizeof(struct HpmfwupgImageHeader) +
|
(pFwupgCtx->pImageData + sizeof(struct HpmfwupgImageHeader) +
|
||||||
pImageHeader->oemDataLength + sizeof(unsigned char)/*checksum*/);
|
pImageHeader->oemDataLength + sizeof(unsigned char)/*chksum*/);
|
||||||
|
|
||||||
/* Deternime actions size */
|
if (option & VIEW_MODE) {
|
||||||
actionsSize = pFwupgCtx->imageSize - sizeof(struct HpmfwupgImageHeader);
|
|
||||||
|
|
||||||
if (option & VIEW_MODE)
|
|
||||||
{
|
|
||||||
HpmDisplayVersionHeader(TARGET_VER|ROLLBACK_VER|IMAGE_VER);
|
HpmDisplayVersionHeader(TARGET_VER|ROLLBACK_VER|IMAGE_VER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform actions defined in the image */
|
/* Perform actions defined in the image */
|
||||||
while( ( pImagePtr < (pFwupgCtx->pImageData + pFwupgCtx->imageSize -
|
while (pImagePtr < (pFwupgCtx->pImageData + pFwupgCtx->imageSize -
|
||||||
HPMFWUPG_MD5_SIGNATURE_LENGTH)) &&
|
HPMFWUPG_MD5_SIGNATURE_LENGTH)) {
|
||||||
( rc == HPMFWUPG_SUCCESS) )
|
/* Get action record */
|
||||||
{
|
pActionRecord = (struct HpmfwupgActionRecord*)pImagePtr;
|
||||||
/* Get action record */
|
|
||||||
pActionRecord = (struct HpmfwupgActionRecord*)pImagePtr;
|
|
||||||
|
|
||||||
/* Validate action record checksum */
|
/* Validate action record checksum */
|
||||||
if ( HpmfwupgCalculateChecksum((unsigned char*)pActionRecord,
|
if (HpmfwupgCalculateChecksum((unsigned char*)pActionRecord,
|
||||||
sizeof(struct HpmfwupgActionRecord)) != 0 )
|
sizeof(struct HpmfwupgActionRecord)) != 0) {
|
||||||
{
|
lprintf(LOG_NOTICE," Invalid Action record.");
|
||||||
lprintf(LOG_NOTICE," Invalid Action record.");
|
return HPMFWUPG_ERROR;
|
||||||
rc = HPMFWUPG_ERROR;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( rc == HPMFWUPG_SUCCESS )
|
switch( pActionRecord->actionType )
|
||||||
{
|
{
|
||||||
switch( pActionRecord->actionType )
|
case HPMFWUPG_ACTION_BACKUP_COMPONENTS:
|
||||||
{
|
{
|
||||||
case HPMFWUPG_ACTION_BACKUP_COMPONENTS:
|
pImagePtr += sizeof(struct HpmfwupgActionRecord);
|
||||||
{
|
}
|
||||||
pImagePtr += sizeof(struct HpmfwupgActionRecord);
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HPMFWUPG_ACTION_PREPARE_COMPONENTS:
|
case HPMFWUPG_ACTION_PREPARE_COMPONENTS:
|
||||||
{
|
{
|
||||||
if (componentToUpload != DEFAULT_COMPONENT_UPLOAD)
|
if (componentToUpload != DEFAULT_COMPONENT_UPLOAD) {
|
||||||
{
|
if (!((1 << componentToUpload) &
|
||||||
if (!(1<<componentToUpload & pActionRecord->components.ComponentBits.byte))
|
pActionRecord->components.ComponentBits.byte)) {
|
||||||
{
|
lprintf(LOG_NOTICE,
|
||||||
lprintf(LOG_NOTICE,"\nComponent Id given is not supported\n");
|
"\nComponent Id given is not supported\n");
|
||||||
return HPMFWUPG_ERROR;
|
return HPMFWUPG_ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
pImagePtr += sizeof(struct HpmfwupgActionRecord);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HPMFWUPG_ACTION_UPLOAD_FIRMWARE:
|
|
||||||
/* Upload all firmware blocks */
|
|
||||||
{
|
|
||||||
struct HpmfwupgFirmwareImage* pFwImage;
|
|
||||||
unsigned char* pData;
|
|
||||||
unsigned int firmwareLength = 0;
|
|
||||||
unsigned char mode = 0;
|
|
||||||
unsigned char componentId = 0x00;
|
|
||||||
unsigned char componentIdByte = 0x00;
|
|
||||||
VERSIONINFO *pVersionInfo;
|
|
||||||
|
|
||||||
struct HpmfwupgGetComponentPropertiesCtx getCompProp;
|
|
||||||
|
|
||||||
/* Save component ID on which the upload is done */
|
|
||||||
componentIdByte = pActionRecord->components.ComponentBits.byte;
|
|
||||||
|
|
||||||
while ((componentIdByte>>=1)!=0)
|
|
||||||
{
|
|
||||||
componentId++;
|
|
||||||
}
|
|
||||||
pFwupgCtx->componentId = componentId;
|
|
||||||
|
|
||||||
pFwImage = (struct HpmfwupgFirmwareImage*)(pImagePtr +
|
|
||||||
sizeof(struct HpmfwupgActionRecord));
|
|
||||||
|
|
||||||
pData = ((unsigned char*)pFwImage + sizeof(struct HpmfwupgFirmwareImage));
|
|
||||||
|
|
||||||
/* Get firmware length */
|
|
||||||
firmwareLength = pFwImage->length[0];
|
|
||||||
firmwareLength |= (pFwImage->length[1] << 8) & 0xff00;
|
|
||||||
firmwareLength |= (pFwImage->length[2] << 16) & 0xff0000;
|
|
||||||
firmwareLength |= (pFwImage->length[3] << 24) & 0xff000000;
|
|
||||||
|
|
||||||
pVersionInfo = &gVersionInfo[componentId];
|
|
||||||
|
|
||||||
pVersionInfo->imageMajor = pFwImage->version[0];
|
|
||||||
pVersionInfo->imageMinor = pFwImage->version[1];
|
|
||||||
pVersionInfo->imageAux[0] = pFwImage->version[2];
|
|
||||||
pVersionInfo->imageAux[1] = pFwImage->version[3];
|
|
||||||
pVersionInfo->imageAux[2] = pFwImage->version[4];
|
|
||||||
pVersionInfo->imageAux[3] = pFwImage->version[5];
|
|
||||||
|
|
||||||
mode = TARGET_VER | IMAGE_VER;
|
|
||||||
|
|
||||||
if (pVersionInfo->coldResetRequired)
|
|
||||||
{
|
|
||||||
flagColdReset = TRUE;
|
|
||||||
}
|
|
||||||
pVersionInfo->skipUpgrade = FALSE;
|
|
||||||
|
|
||||||
if (option & FORCE_MODE_ALL)
|
|
||||||
{
|
|
||||||
/* user has given all to upload all the components on the command line */
|
|
||||||
if(verbose) {
|
|
||||||
lprintf(LOG_NOTICE,"Forcing ALL components");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( option & FORCE_MODE_COMPONENT )
|
|
||||||
{
|
|
||||||
if( componentToUpload != componentId )
|
|
||||||
{
|
|
||||||
if(verbose) {
|
|
||||||
lprintf(LOG_NOTICE,"Forcing component %d skip", componentId);
|
|
||||||
}
|
|
||||||
/* user has given the component Id to upload on the command line */
|
|
||||||
pVersionInfo->skipUpgrade = TRUE;
|
|
||||||
}
|
|
||||||
else if(verbose)
|
|
||||||
{
|
|
||||||
lprintf(LOG_NOTICE,"Forcing component %d update", componentId);
|
|
||||||
/* user has given the component Id to upload on the command line */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
(pVersionInfo->imageMajor == pVersionInfo->targetMajor)
|
|
||||||
&&
|
|
||||||
(pVersionInfo->imageMinor == pVersionInfo->targetMinor))
|
|
||||||
{
|
|
||||||
if (pVersionInfo->rollbackSupported)
|
|
||||||
{
|
|
||||||
/*If the Image Versions are same as Target Versions then check for the
|
|
||||||
* rollback version*/
|
|
||||||
if
|
|
||||||
(
|
|
||||||
(pVersionInfo->imageMajor == pVersionInfo->rollbackMajor)
|
|
||||||
&&
|
|
||||||
(pVersionInfo->imageMinor == pVersionInfo->rollbackMinor)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
/* This indicates that the Rollback version is also same as
|
|
||||||
* Image version -- So now we must skip it */
|
|
||||||
pVersionInfo->skipUpgrade = TRUE;
|
|
||||||
}
|
|
||||||
mode |= ROLLBACK_VER;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pVersionInfo->skipUpgrade = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( verbose ) {
|
|
||||||
lprintf(LOG_NOTICE,"Component %d: %s", componentId , (pVersionInfo->skipUpgrade?"skipped":"to update"));
|
|
||||||
}
|
}
|
||||||
}
|
pImagePtr += sizeof(struct HpmfwupgActionRecord);
|
||||||
if( pVersionInfo->skipUpgrade == FALSE )
|
}
|
||||||
{
|
break;
|
||||||
pFwupgCtx->compUpdateMask.ComponentBits.byte |= 1<<componentId;
|
|
||||||
}
|
case HPMFWUPG_ACTION_UPLOAD_FIRMWARE:
|
||||||
if (option & VIEW_MODE)
|
/* Upload all firmware blocks */
|
||||||
{
|
{
|
||||||
HpmDisplayVersion(mode,pVersionInfo);
|
struct HpmfwupgFirmwareImage *pFwImage;
|
||||||
printf("\n");
|
unsigned char *pData;
|
||||||
}
|
unsigned int firmwareLength;
|
||||||
pImagePtr = pData + firmwareLength;
|
unsigned char mode;
|
||||||
}
|
unsigned char componentId;
|
||||||
break;
|
unsigned char componentIdByte;
|
||||||
default:
|
unsigned int upgrade_comp;
|
||||||
lprintf(LOG_NOTICE," Invalid Action type. Cannot continue");
|
VERSIONINFO *pVersionInfo;
|
||||||
rc = HPMFWUPG_ERROR;
|
struct HpmfwupgGetComponentPropertiesCtx getCompProp;
|
||||||
break;
|
|
||||||
}
|
/* Save component ID on which the upload is done */
|
||||||
}
|
componentIdByte = pActionRecord->components.ComponentBits.byte;
|
||||||
|
|
||||||
|
componentId = 0;
|
||||||
|
while ((componentIdByte >>= 1) !=0) {
|
||||||
|
componentId++;
|
||||||
|
}
|
||||||
|
pFwupgCtx->componentId = componentId;
|
||||||
|
|
||||||
|
pFwImage = (struct HpmfwupgFirmwareImage*)(pImagePtr +
|
||||||
|
sizeof(struct HpmfwupgActionRecord));
|
||||||
|
|
||||||
|
pData = ((unsigned char*)pFwImage +
|
||||||
|
sizeof(struct HpmfwupgFirmwareImage));
|
||||||
|
|
||||||
|
/* Get firmware length */
|
||||||
|
firmwareLength = pFwImage->length[0];
|
||||||
|
firmwareLength |= (pFwImage->length[1] << 8) & 0xff00;
|
||||||
|
firmwareLength |= (pFwImage->length[2] << 16) & 0xff0000;
|
||||||
|
firmwareLength |= (pFwImage->length[3] << 24) & 0xff000000;
|
||||||
|
|
||||||
|
pVersionInfo = &gVersionInfo[componentId];
|
||||||
|
|
||||||
|
pVersionInfo->imageMajor = pFwImage->version[0];
|
||||||
|
pVersionInfo->imageMinor = pFwImage->version[1];
|
||||||
|
pVersionInfo->imageAux[0] = pFwImage->version[2];
|
||||||
|
pVersionInfo->imageAux[1] = pFwImage->version[3];
|
||||||
|
pVersionInfo->imageAux[2] = pFwImage->version[4];
|
||||||
|
pVersionInfo->imageAux[3] = pFwImage->version[5];
|
||||||
|
|
||||||
|
mode = TARGET_VER | IMAGE_VER;
|
||||||
|
|
||||||
|
if (pVersionInfo->coldResetRequired)
|
||||||
|
flagColdReset = TRUE;
|
||||||
|
|
||||||
|
upgrade_comp = 0;
|
||||||
|
if (option & FORCE_MODE_ALL) {
|
||||||
|
upgrade_comp = 1;
|
||||||
|
}
|
||||||
|
else if ((option & FORCE_MODE_COMPONENT) &&
|
||||||
|
(componentToUpload == componentId)) {
|
||||||
|
upgrade_comp = 1;
|
||||||
|
}
|
||||||
|
else if (image_version_upgradable(pVersionInfo)) {
|
||||||
|
upgrade_comp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
lprintf(LOG_NOTICE,"%s component %d",
|
||||||
|
(upgrade_comp ? "Updating" : "Skipping"),
|
||||||
|
componentId);
|
||||||
|
|
||||||
|
if (upgrade_comp)
|
||||||
|
pFwupgCtx->compUpdateMask.ComponentBits.byte |=
|
||||||
|
1 << componentId;
|
||||||
|
|
||||||
|
if (option & VIEW_MODE) {
|
||||||
|
if (pVersionInfo->rollbackSupported)
|
||||||
|
mode |= ROLLBACK_VER;
|
||||||
|
HpmDisplayVersion(mode,pVersionInfo);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
pImagePtr = pData + firmwareLength;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
lprintf(LOG_NOTICE,
|
||||||
|
" Invalid Action type. Cannot continue");
|
||||||
|
return HPMFWUPG_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (option & VIEW_MODE)
|
|
||||||
{
|
if (option & VIEW_MODE) {
|
||||||
HpmDisplayLine("-",71);
|
HpmDisplayLine("-",71);
|
||||||
if (flagColdReset)
|
if (flagColdReset) {
|
||||||
{
|
fflush(stdout);
|
||||||
fflush(stdout);
|
lprintf(LOG_NOTICE,"(*) Component requires Payload Cold Reset");
|
||||||
lprintf(LOG_NOTICE,"(*) Component requires Payload Cold Reset");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return rc;
|
return HPMFWUPG_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user