Actions
Bug #3518
closedIncorrect hostid calculation
Start date:
2013-02-01
Due date:
% Done:
100%
Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:
Description
During some additional testing on some other hardware, we found a sign extension bug that I introduced when I committed the fix for 3359. This is a regression, and it expresses itself as an incorrectly formatted value of hw_serial, resulting in HW_INVALID_HOSTID.
Updated by Garrett D'Amore about 10 years ago
Here's the fix for my bug. Rather than switching to unsigned values throughout, I think masking off the sign bit is best, as other consumers of hostids may be ill-prepared for negative values there.
--- a/usr/src/uts/i86pc/os/startup.c +++ b/usr/src/uts/i86pc/os/startup.c @@ -2781,7 +2781,7 @@ uuid_to_hostid(const uint8_t *uuid) * generate 32-bit vaue by xor'ing the various sequences together, * which ensures that the enire UUID contributes to the hostid. */ - int32_t id = 0; + uint32_t id = 0; /* first check against the blacklist */ for (int i = 0; i < (sizeof (smbios_uuid_blacklist) / 16); i++) { @@ -2795,7 +2795,8 @@ uuid_to_hostid(const uint8_t *uuid) for (int i = 0; i < 16; i++) id ^= ((uuid[i]) << (8 * (i % sizeof (id)))); - return (id); + /* Make sure return value is positive */ + return (id & 0x7fffffff); }
Updated by Garrett D'Amore over 9 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
- Tags deleted (
needs-triage)
commit 2df37efa12a69b067c7197296dd802eb4b8a9e85
Author: Garrett D'Amore <garrett@dey-sys.com>
Date: Fri Feb 1 12:04:34 2013 -0800
3518 Incorrect hostid calculation
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Reviewed by: Richard Elling <richard.elling@dey-sys.com>
Reviewed by: Andy Giles <andy.giles@dey-sys.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Approved by: Dan McDonald <danmcd@nexenta.com>
Actions