The branch main has been updated by kevans:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=604d34c23f772ae0005a552b0b7189f3dc97d519

commit 604d34c23f772ae0005a552b0b7189f3dc97d519
Author:     Maxim Shalomikhin <maxim.shalomik...@kaspersky.com>
AuthorDate: 2025-07-02 19:25:57 +0000
Commit:     Kyle Evans <kev...@freebsd.org>
CommitDate: 2025-07-02 19:33:52 +0000

    net: ether_gen_addr: fix address generation
    
    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
---
 sys/net/if_ethersubr.c | 4 +---
 1 file changed, 1 insertion(+), 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;

Reply via email to