Skip to content

fru: Update the fru section offset only when they exist (offset is not 0) #368

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andrew8325
Copy link

Fix the issue #364 and also consider other fru section including Board and Product.

@andrew8325 andrew8325 marked this pull request as ready for review September 23, 2022 02:26
lib/ipmi_fru.c Show resolved Hide resolved
Originally, ipmitool will assume the FRU section offset will follow a specific order, but this is not true (or not be defined in IPMI FRU SPEC). So change the FRU edit method, now it will:
  - Calculate the section offset one by one according to their offset
  - Ignore the FRU section offset if its offset is 00 (area does not exist)
  - If the new FRU become smaller, reset the redundant data to 0
Fixes ipmitool#364
@andrew8325
Copy link
Author

I upload a new commit, which will do the following things:

  • Calculate the section offset one by one according to their offset
  • Ignore the FRU section offset if its offset is 00 (area does not exist)
  • If the new FRU become smaller, reset the redundant data to 0

After this change, the FRU edit still works normally

Before modify:

root@ubuntu:~$ ipmitool fru print 0               
 Chassis Type          : Rack Mount Chassis
 Chassis Part Number   : ServerNum
 Chassis Serial        : 0123456789
 Chassis Extra         : ---
 Chassis Extra         : ---
 Board Mfg Date        : Mon 26 Sep 2022 06:30:00 PM CST CST
 Board Mfg             : ServerMfc
 Board Product         : ServerName
 Board Part Number     : PartNumber
 Board Extra           : ---
 Board Extra           : ---
 Board Extra           : 00
 Product Manufacturer  : ServerMfc
 Product Name          : ServerName
 Product Part Number   : ServerModel
 Product Version       : Storage
 Product Asset Tag     : ---
 Product Extra         : ---
 Product Extra         : ---
 Product Extra         : ---

Edit Chassis area by command

root@ubuntu:~$ ipmitool fru edit 0 field c 1 ABC    
 String size are not equal, resizing fru to fit new string
 Read All FRU area
 Fru Size       : 512 bytes
 Copy to new FRU
 Section Length: 40
 Padding Length: 6
 NumByte Change: -7
 Start SecChnge: ca
End SecChnge  : 33
 Start Section : 1
 End Sec wo Pad: c1
 End Section   : 47
 New Padding Length: 13
 change_size_by_8: -1
 New Padding Length: 5
 change_size_by_8: -1
 header.offset.board: 6
 Moving Section Board, from 48 to 40
 Moving Section Product, from 112 to 104
 Reset to 0 from 176 to 184
 Updating Field : '0123456789' with 'ABC' ... (Length from '202' to '195')
 Copying remaining of sections: 14 
 Calculate New Checksum: ffffff96
 Writing new FRU.
 Done.

After editing the FRU

root@ubuntu:~$ ipmitool fru print 0
 Chassis Type          : Rack Mount Chassis
 Chassis Part Number   : ServerNum
 Chassis Serial        : ABC
 Chassis Extra         : ---
 Chassis Extra         : ---
 Board Mfg Date        : Mon 26 Sep 2022 06:30:00 PM CST CST
 Board Mfg             : ServerMfc
 Board Product         : ServerName
 Board Part Number     : PartNumber
 Board Extra           : ---
 Board Extra           : ---
 Board Extra           : 00
 Product Manufacturer  : ServerMfc
 Product Name          : ServerName
 Product Part Number   : ServerModel
 Product Version       : Storage
 Product Asset Tag     : ---
 Product Extra         : ---
 Product Extra         : ---
 Product Extra         : ---

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants