[PATCH] net: uclass: Save ethernet MAC address when generated
Wolfgang Denk
wd at denx.de
Thu Nov 18 20:04:22 CET 2021
Dear Tom,
In message <20211118162920.GH24579 at bill-the-cat> you wrote:
>
> > It is perfectly OK for U-Boot to start with a random MAC address,
> > use this for a while, and change it so something else later. This
> > is what may happen at production: say the MAC address is stored in
> > some EEPROM or fuses, which are initially empty, so U-Boot will use
> > a random MAC address, download it's board specific date (serial#,
> > MAC address, ...) over network, programm it into the respective
> > storage devices, and switch to using the new "official" MAC address.
>
> Yes. And up until this patch saying I want to use this random MAC with
> Linux required user intervention.
Correct - this is a bug in the implementation of thispatch, and
apparently the few people that ever used it did not notice it or
care enough about it to submit fixes.
> And I dare say that half the time or
> more that was probably just not noticed (everything comes up with
> dynamic host names/dns these days, noticing the IP changed between
> U-Boot and Linux is easy to miss in those cases).
Agreed.
> > CONFIG_NET_RANDOM_ETHADDR is the attempt to do the same
> > automatically, except that it falls short of setting the "ethaddr"
> > environment variable. I consider this a bug.
>
> Since the code isn't that old, it shouldn't be hard to pull up the
> thread / patch on introducing it. So, lets:
> https://patchwork.ozlabs.org/project/uboot/patch/1430769315-27109-1-git-sen=
> d-email-joe.hershberger at ni.com/
> https://patchwork.ozlabs.org/project/uboot/patch/1430769315-27109-2-git-sen=
> d-email-joe.hershberger at ni.com/
> https://patchwork.ozlabs.org/project/uboot/patch/1430769315-27109-3-git-sen=
> d-email-joe.hershberger at ni.com/
>
> And from there we can take away I think two important things:
> 1: Not setting ethaddr with NET_RANDOM_ETHADDR is intentional
Ummm... From which part of the patches or the comments do you take
this conclusion? Not a single line of code, or comments in the code
or commit messages, nor any of the review comments refer to the
"ethadddr" environment variable. I thing it was just an oversight
to set it here, which was not detected during testing as everything
appeared to work.
I actually see the opposite - Joes initial commit messages speaks
about "Implement the random *ethaddr* fallback", and as his
following patches clean up the use of hard codes definitions of the
"ethaddr" environment variable, I see it more likely that he means
the environment variable and not MAC address.
> 2: It was widely inconsistent before! Lots of platforms were generating
> a random MAC and then setting ethaddr. I think in fact most were and
> it's just a few (which coincidentally are some of Michael's other
> platforms) that were not.
Agreed.
> > Yes, and it should be clear that this is not a reasonable approach.
> > It thwarts the original intent of the NET_RANDOM_ETHADDR patch to do
> > thing in an automated, scriptable way. I see this actually as a
> > manifestation of the bug that ethaddr does not get set. At this
> > point the problem was recognized, but instead of properly fixing it,
> > a poor workaround was documented.
>
> Well, for the record, with the above patch links, NET_RANDOM_ETHADDR
> _is_ working as intended. That said..
No, it works only half. It fails to set the "ethaddr" environment
variable which is mandatory for correct funktion (query by the user,
passing to Linux).
> So, yes, OK, this is a bug fix, in that NET_RANDOM_ETHADDR was incorrect
> at introduction. That means we do need a v2 of this patch that updates
> the Kconfig help text as that currently says it will not update the
> environment.
This makes no sense to me. Instead of documenting the bug we should
fix it and add the missing eth_env_set_enetaddr().
If I prepare such patches, will you accept these?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Microsoft Multitasking:
several applications can crash at the same time.
More information about the U-Boot
mailing list