sonic-net / sonic-platform-common

Python packages which provide a common interface to platform-specific hardware peripherals in SONiC
Other
46 stars 175 forks source link

[202311][SSD] Bug fix: the logic to match the vendor specific attribute is not accurate #483

Closed stephenxs closed 3 months ago

stephenxs commented 4 months ago

Description

The logic to match the vendor-specific attribute in SSD API is not accurate. The vendor-specific attribute should start with a new line (\n) otherwise it can hit a false match scenario.

Motivation and Context

How Has This Been Tested?

Unit test and manual test

Additional Information (Optional)

Eg. if the raw value of an attribute happens to contain the ID, the next line can be matched but it is wrong. For example the vendor-specific attribute ID is 248, but the output is like the following:

215 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       4275
231 Unknown_SSD_Attribute   0x1913   100   100   025    Pre-fail  Always       -       100
235 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       1302467136
235 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       1302467248
237 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       0
241 Total_LBAs_Written      0x0012   100   100   000    Old_age   Always       -       1186450104
242 Total_LBAs_Read         0x0012   100   100   000    Old_age   Always       -       2257141451
243 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       0
244 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       0
248 Unknown_Attribute       0x0112   100   100   001    Old_age   Always       -       100

The raw value of attribute 235 contains 248, the next line, which is of attribute 237, will be matched, which is wrong.