Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Apr 2021 14:36:10 -0500
From:      Kyle Evans <kevans@freebsd.org>
To:        Ronald Klop <ronald-lists@klop.ws>
Cc:        Kevin Bowling <kbowling@freebsd.org>, src-committers <src-committers@freebsd.org>,  "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, dev-commits-src-main@freebsd.org
Subject:   Re: git: 68a46f11eada - main - e1000: Restore VF interface random MAC
Message-ID:  <CACNAnaFzdufDyvuafqu%2BUsDSfsJwjQhRew5iG1-gUsyAv45xXg@mail.gmail.com>
In-Reply-To: <5b50b23a-71cd-5221-c905-ccffe841bc98@klop.ws>
References:  <202104151848.13FImMA5091035@gitrepo.freebsd.org> <5b50b23a-71cd-5221-c905-ccffe841bc98@klop.ws>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Apr 15, 2021 at 2:32 PM Ronald Klop <ronald-lists@klop.ws> wrote:
>
> On 4/15/21 8:48 PM, Kevin Bowling wrote:
> > The branch main has been updated by kbowling (ports committer):
> >
> > URL: https://cgit.FreeBSD.org/src/commit/?id=68a46f11eadab48a1da9e3d3900569a6a1ce142e
> >
> > commit 68a46f11eadab48a1da9e3d3900569a6a1ce142e
> > Author:     Kevin Bowling <kbowling@FreeBSD.org>
> > AuthorDate: 2021-04-15 18:45:02 +0000
> > Commit:     Kevin Bowling <kbowling@FreeBSD.org>
> > CommitDate: 2021-04-15 18:45:02 +0000
> >
> >      e1000: Restore VF interface random MAC
> >
> >      Restore 525e07418c77 after the iflib conversion of igb(4). This
> >      reenables random MAC address generation when attaching to a VF with a
> >      zeroed MAC.
> >
> >      PR:             253535
> >      Reported by:    Balaev PA <mail@void.so>
> >      Reviewed by:    markj
> >      MFC after:      2 weeks
> >      Differential Revision:  https://reviews.freebsd.org/D29785
> > ---
> >   sys/dev/e1000/if_em.c | 21 ++++++++++++++++++---
> >   1 file changed, 18 insertions(+), 3 deletions(-)
> >
> > diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
> > index 6f022c80c01c..79a617b3342f 100644
> > --- a/sys/dev/e1000/if_em.c
> > +++ b/sys/dev/e1000/if_em.c
> > @@ -1061,9 +1061,17 @@ em_if_attach_pre(if_ctx_t ctx)
> >       }
> >
> >       if (!em_is_valid_ether_addr(hw->mac.addr)) {
> > -             device_printf(dev, "Invalid MAC address\n");
> > -             error = EIO;
> > -             goto err_late;
> > +             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));
> > +             } else {
> > +                     device_printf(dev, "Invalid MAC address\n");
> > +                     error = EIO;
> > +                     goto err_late;
> > +             }
>
>
> Just curious. Would ether_gen_addr() be useful here?
> It is implemented in net/if_ethersubr.c.
>

I had asked myself the same question, but I suspect these machines may
not necessarily have a hostuuid preloaded to avoid collisions from the
generated addresses.

Thanks,

Kyle Evans



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACNAnaFzdufDyvuafqu%2BUsDSfsJwjQhRew5iG1-gUsyAv45xXg>