-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemd-networkd: Conditionalize hostnamed/timedated DBUS calls #3232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch as is will work for the case of startup. Looking at the code again, I am wondering about the other call sites of these functions.
The manager_set_timezone
and manager_set_hostname
functions are also called when handling dhcp leases. The tz and hostname data can also be configured through a dhcp lease it seems (see functions dhcp_lease_acquired
, dhcp_reset_hostname
, dhcp6_address_acquired
in src/network/networkd-dhcp4.c
and src/network/networkd-dhcp6.c
).
Do we plan to not support such use cases where a user wants to use this? As far as I can tell those are non-essential features not implemented by quite some DHCP clients, but we should be sure we are doing the right thing here and are not in need of a service (hostnamed or something else) to service these requests.
I am no DHCP expert myself though, so I might be over-cautious here.
If we want to make this conditional on build-time options (good idea!), a more universal approach that targets the other call sites as well and is robust against future changes would be to provide stub implementations in the #if ENABLE_HOSTNAMED
int manager_set_hostname(Manager *m, const char *hostname);
#else
static inline int manager_set_hostname(_unused_ Manager *m, _unused_ const char *hostname) {
return 0;
}
#endif /* ENABLE_HOSTNAMED */ while also wrapping the real implementation of |
@foersleo I also found this after I put out the PR and was in the middle of fixing it up - thanks for keeping me honest! :) . At least currently, we don't allow the configuration of tz and hostname via DHCP. Timezone isn't something currently configurable, and hostname is a configurable API setting. I'd expect it would be a decent re-architecture for us to support tz/hostname via DHCP lease. Because of that, it feels pretty safe to make the I'll plan to fix that up and put out a new revision. |
This is a great idea - I'll dig into that! |
b669260
to
8d03cff
Compare
^ Addresses @markusboehme and @foersleo 's comments |
packages/systemd/9013-systemd-networkd-Conditionalize-hostnamed-timezoned-DBUS.patch
Outdated
Show resolved
Hide resolved
systemd-networkd registers a function to call when first connecting to DBUS. This function makes three calls to other DBUS services (hostnamed and timedated) which aren't used in Bottlerocket. Calls to the same DBUS services are also made in the DHCP clients. This change makes a patch to systemd-networkd that conditionalizes these calls based on the underlying service being built, return 0 if the services isn't built. Removing the calls to non-existent services cleans up some confusing and inconsequential messages in the journal on boot.
8d03cff
to
7c8a8dc
Compare
^ Uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This looks a lot cleaner and more robust.
Issue number:
Related to #2449
Description of changes:
An example of messages logged on boot because of nonexistent
hostnamed
DBUS service:Testing done:
aws-k8s-1.24
image to ensure nothing breaksaws-dev
image with a hard-coded network config file and a dependency onconsole-getty.service
inpreconfigured.target
. Outside of the expected boot failures, observe that the above logs don't show up in the journal, andsystemd-networkd is running, and
networkctl` is happy. Observe no other related messages are logged in the journal.Testing of this change will be ongoing during development, but this patch avoids the most obvious and inconsequential failure messages.
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.