Blocking call in phosphor-networkd
Lei Yu
yulei.sh at bytedance.com
Wed Oct 19 18:09:47 AEDT 2022
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.
--
BRs,
Lei YU
More information about the openbmc
mailing list