The branch stable/13 has been updated by kbowling (ports committer):

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8b043521b41664f4f2bd18087511508b7af776c0
commit 8b043521b41664f4f2bd18087511508b7af776c0
Author:     Kevin Bowling <kbowl...@freebsd.org>
AuthorDate: 2021-08-20 14:45:30 +0000
Commit:     Kevin Bowling <kbowl...@freebsd.org>
CommitDate: 2021-08-27 01:33:48 +0000

    intel ethernet: Use ether_gen_addr(9)
    
    Use ether_gen_addr(9) for VF MAC generation
    
    Reviewed by:    Intel Networking (erj), kevans
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D31616
    
    (cherry picked from commit 0e5811a2a9a1b4a7e0c79b73e3b9b9d15d481577)
---
 sys/dev/e1000/if_em.c  |  7 ++-----
 sys/dev/ixgbe/if_ixv.c | 10 ++++------
 sys/dev/ixl/if_iavf.c  | 10 +++-------
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 5c958806d824..6e3a8f73190f 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -1076,11 +1076,8 @@ em_if_attach_pre(if_ctx_t ctx)
 
        if (!em_is_valid_ether_addr(hw->mac.addr)) {
                if (adapter->vf_ifp) {
-                       u8 addr[ETHER_ADDR_LEN];
-                       arc4rand(&addr, sizeof(addr), 0);
-                       addr[0] &= 0xFE;
-                       addr[0] |= 0x02;
-                       bcopy(addr, hw->mac.addr, sizeof(addr));
+                       ether_gen_addr(iflib_get_ifp(ctx),
+                           (struct ether_addr *)hw->mac.addr);
                } else {
                        device_printf(dev, "Invalid MAC address\n");
                        error = EIO;
diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c
index 9744a3347cec..301d3c0368ae 100644
--- a/sys/dev/ixgbe/if_ixv.c
+++ b/sys/dev/ixgbe/if_ixv.c
@@ -465,12 +465,10 @@ ixv_if_attach_pre(if_ctx_t ctx)
 
        /* If no mac address was assigned, make a random one */
        if (!ixv_check_ether_addr(hw->mac.addr)) {
-               u8 addr[ETHER_ADDR_LEN];
-               arc4rand(&addr, sizeof(addr), 0);
-               addr[0] &= 0xFE;
-               addr[0] |= 0x02;
-               bcopy(addr, hw->mac.addr, sizeof(addr));
-               bcopy(addr, hw->mac.perm_addr, sizeof(addr));
+               ether_gen_addr(iflib_get_ifp(ctx),
+                   (struct ether_addr *)hw->mac.addr);
+               bcopy(hw->mac.addr, hw->mac.perm_addr,
+                   sizeof(hw->mac.perm_addr));
        }
 
        /* Most of the iflib initialization... */
diff --git a/sys/dev/ixl/if_iavf.c b/sys/dev/ixl/if_iavf.c
index f6eb91c2a855..123db2e2461d 100644
--- a/sys/dev/ixl/if_iavf.c
+++ b/sys/dev/ixl/if_iavf.c
@@ -433,13 +433,9 @@ iavf_if_attach_pre(if_ctx_t ctx)
        iavf_dbg_init(sc, "Resource Acquisition complete\n");
 
        /* If no mac address was assigned just make a random one */
-       if (!iavf_check_ether_addr(hw->mac.addr)) {
-               u8 addr[ETHER_ADDR_LEN];
-               arc4rand(&addr, sizeof(addr), 0);
-               addr[0] &= 0xFE;
-               addr[0] |= 0x02;
-               bcopy(addr, hw->mac.addr, sizeof(addr));
-       }
+       if (!iavf_check_ether_addr(hw->mac.addr))
+               ether_gen_addr(iflib_get_ifp(ctx),
+                   (struct ether_addr *)hw->mac.addr);
        bcopy(hw->mac.addr, hw->mac.perm_addr, ETHER_ADDR_LEN);
        iflib_set_mac(ctx, hw->mac.addr);
 
_______________________________________________
dev-commits-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"

Reply via email to