Re: kern/60592: random Mac address generation in genet Ethernet driver causes problems

"[email protected] via gnats" <[email protected]>
Newsgroups gmane.os.netbsd.bugs
Message-ID <[email protected]>
The following reply was made to PR kern/60592; it has been noted by GNATS.

From: [email protected]
To: [email protected]
Cc: 
Subject: Re: kern/60592: random Mac address generation in genet Ethernet
 driver causes problems
Date: Sat, 15 Aug 2026 06:46:51 +0000

 >  Index: sys/dev/ic/bcmgenet.c
 >  ===================================================================
 >  RCS file: /cvsroot/src/sys/dev/ic/bcmgenet.c,v
 >  retrieving revision 1.23
 >  diff -u -r1.23 bcmgenet.c
 >  --- sys/dev/ic/bcmgenet.c       4 Oct 2025 04:44:20 -0000       1.23
 >  +++ sys/dev/ic/bcmgenet.c       15 Aug 2026 06:13:21 -0000
 >  @@ -977,11 +977,13 @@
 >                  maclo = 0x00f2 | (cprng_strong32() & 0xffff0000);
 >                  machi = cprng_strong32() & 0xffff;
 >          }
 >  +       else
 >  +               maclo = htonl(maclo);
 >   
 >  -       eaddr[0] = (maclo >> 24) & 0xff;
 >  -       eaddr[1] = (maclo >> 16) & 0xff;
 >  -       eaddr[2] = (maclo >>  8) & 0xff;
 >  -       eaddr[3] = (maclo >>  0) & 0xff;
 >  +       eaddr[0] = (maclo >> 0) | 0xff;
 >  +       eaddr[1] = (maclo >> 8) & 0xff;
 >  +       eaddr[2] = (maclo >>  16) & 0xff;
 >  +       eaddr[3] = (maclo >>  24) & 0xff;
 >          eaddr[4] = (machi >>  8) & 0xff;
 >          eaddr[5] = (machi >>  0) & 0xff;
 >   }
 >   
 >  Emmanuel
 > 
 
 ndex: sys/dev/ic/bcmgenet.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/bcmgenet.c,v
 retrieving revision 1.23
 diff -u -r1.23 bcmgenet.c
 --- sys/dev/ic/bcmgenet.c       4 Oct 2025 04:44:20 -0000       1.23
 +++ sys/dev/ic/bcmgenet.c       15 Aug 2026 06:43:30 -0000
 @@ -977,11 +977,13 @@
                 maclo = 0x00f2 | (cprng_strong32() & 0xffff0000);
                 machi = cprng_strong32() & 0xffff;
         }
 +       else
 +               maclo = htonl(maclo);
  
 -       eaddr[0] = (maclo >> 24) & 0xff;
 -       eaddr[1] = (maclo >> 16) & 0xff;
 -       eaddr[2] = (maclo >>  8) & 0xff;
 -       eaddr[3] = (maclo >>  0) & 0xff;
 +       eaddr[0] = (maclo >> 0) & 0xff;
 +       eaddr[1] = (maclo >> 8) & 0xff;
 +       eaddr[2] = (maclo >>  16) & 0xff;
 +       eaddr[3] = (maclo >>  24) & 0xff;
         eaddr[4] = (machi >>  8) & 0xff;
         eaddr[5] = (machi >>  0) & 0xff;
 
 sorry typo. & 0xff not | 0xff
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.