From owner-dev-commits-src-branches@freebsd.org Fri Aug 27 01:39:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A57C3675322; Fri, 27 Aug 2021 01:39:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gwj794Fydz4qCX; Fri, 27 Aug 2021 01:39:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6FB991AA88; Fri, 27 Aug 2021 01:39:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R1dHX6065494; Fri, 27 Aug 2021 01:39:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1dHDT065493; Fri, 27 Aug 2021 01:39:17 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:39:17 GMT Message-Id: <202108270139.17R1dHDT065493@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 200842074ba6 - stable/12 - intel ethernet: Use ether_gen_addr(9) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 200842074ba60e8e4c8ab2776a3d2b85d3cd4101 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:39:17 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=200842074ba60e8e4c8ab2776a3d2b85d3cd4101 commit 200842074ba60e8e4c8ab2776a3d2b85d3cd4101 Author: Kevin Bowling AuthorDate: 2021-08-20 14:45:30 +0000 Commit: Kevin Bowling CommitDate: 2021-08-27 01:38:09 +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 2a6afd244445..315437145e1c 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -1078,11 +1078,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 8a242b9b8cba..ca69275928a5 100644 --- a/sys/dev/ixgbe/if_ixv.c +++ b/sys/dev/ixgbe/if_ixv.c @@ -468,12 +468,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 066c565ec53e..72853a35138a 100644 --- a/sys/dev/ixl/if_iavf.c +++ b/sys/dev/ixl/if_iavf.c @@ -435,13 +435,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);