Blocking call in phosphor-networkd
Patrick Williams
patrick at stwcx.xyz
Wed Oct 19 22:35:13 AEDT 2022
On Wed, Oct 19, 2022 at 03:09:47PM +0800, Lei Yu wrote:
> On Wed, Oct 19, 2022 at 12:52 PM Patrick Williams <patrick at stwcx.xyz> wrote:
> > On Wed, Oct 19, 2022 at 11:40:17AM +0800, Lei Yu wrote:
> >
> > > How about changing the code to read the `/etc/hostname` file directly?
> > > It is much faster than making DBus call to `systemd-hostnamed`.
> >
> > Absolutely not.
> >
> > The value of `/etc/hostname` is considered to be the "static hostname",
> > which is configured by default in the 'base-files' package to be the
> > value of ${MACHINE}:
> >
> > poky/meta/recipes-core/base-files/base-files_3.0.14.bb:hostname = "${MACHINE}"
> > poky/meta/recipes-core/base-files/base-files_3.0.14.bb: echo ${hostname} > ${D}${sysconfdir}/hostname
> >
> > The value from the dbus call is the "transient hostname" which is
> > typically assigned by the DHCP server and is much much more likely to be
> > something that resolves properly on your network. Since all the
> > machines of the same type will have the same static hostname (due to it
> > being derived from MACHINE) you are almost certain that this name is
> > useless for any purpose.
> >
>
> According to https://www.freedesktop.org/software/systemd/man/hostname.html:
>
> ```
> Otherwise, a transient hostname may be set during runtime, for example
> based on information in a DHCP lease, see
> systemd-hostnamed.service(8). Both NetworkManager and
> systemd-networkd.service(8) allow this. Note that
> systemd-hostnamed.service(8) gives higher priority to the static
> hostname, so the transient hostname will only be used if the static
> hostname is not configured.
> ```
>
> systemd-networkd will use the static hostname anyway even DHCP gives a
> transient hostname.
> So I do not think it makes any difference.
Agreed, this is all true. I think this points to a bug in our hostname
implementation within phosphor-networkd implementation. We probably
shouldn't make it worse though by using the `/etc/hostname` directly.
What I mean by bug is to me the desired behavior would be as follows:
- Out of the box, openbmc should use the DHCP-assigned hostname to
set the transient hostname.
- If a user sets the Hostname, this should become the static hostname
and override any transient.
- If a user sets the Hostname to an empty string, the static hostname
should be cleared.
What is happening today is:
- Out of the box, the hostname is set to MACHINE.
- DHCP-assigned hostnames are effectively ignored.
--
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20221019/7f7eb484/attachment.sig>
More information about the openbmc
mailing list