diff options
author | Maxim Shalomikhin <maxim.shalomikhin@kaspersky.com> | 2025-07-02 19:25:57 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2025-07-02 19:33:52 +0000 |
commit | 604d34c23f772ae0005a552b0b7189f3dc97d519 (patch) | |
tree | 272f661ff34ae2ad73892a6d433c6bf5347e04de | |
parent | b2f02b04948cea9b7f019b267e1fc2d083b1417c (diff) |
Some errors in ether_gen_addr() caused us to generate MAC addresses out
of range, and the ones that were within range had other errors causing
the pool of addresses that we might actually generate to shrink.
Fix both prblems by using only two bytes of the digest and then OR'ing
against the mask, which has the appropriate byte set for the fourth
octet of the range already; essentially, our digest is only contributing
the last two octets.
Change is the author, but any blame for the commit message goes to
kevans.
PR: 256850
Relnotes: yes
-rw-r--r-- | sys/net/if_ethersubr.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index cf697089708c..7be4dfac23e7 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1510,9 +1510,7 @@ ether_gen_addr_byname(const char *nameunit, struct ether_addr *hwaddr) SHA1Final(digest, &ctx); free(buf, M_TEMP); - addr = ((digest[0] << 16) | (digest[1] << 8) | digest[2]) & - OUI_FREEBSD_GENERATED_MASK; - addr = OUI_FREEBSD(addr); + addr = (digest[0] << 8) | digest[1] | OUI_FREEBSD_GENERATED_LOW; for (i = 0; i < ETHER_ADDR_LEN; ++i) { hwaddr->octet[i] = addr >> ((ETHER_ADDR_LEN - i - 1) * 8) & 0xFF; |