Skip to content
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

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
From a30b5e19083d88a9e26027488e42cc3105ad4689 Mon Sep 17 00:00:00 2001
From: Zac Mrowicki <mrowicki@amazon.com>
Date: Thu, 6 Jul 2023 17:50:28 +0000
Subject: [PATCH] systemd-networkd: Conditionalize hostnamed/timezoned DBUS
calls

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 made in the DHCP clients. This change makes a patch
to systemd-networkd that conditionalizes these calls based on the
underlying services being built, returning 0 if the service isn't built.

Removing the calls to non-existent services cleans up some confusing and
inconsequential messages in the journal on boot.
---
src/network/networkd-dhcp-common.c | 2 ++
src/network/networkd-dhcp-common.h | 6 ++++++
src/network/networkd-manager.c | 4 ++++
src/network/networkd-manager.h | 13 +++++++++++++
4 files changed, 25 insertions(+)

diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c
index 4f13ead..1c1b2ec 100644
--- a/src/network/networkd-dhcp-common.c
+++ b/src/network/networkd-dhcp-common.c
@@ -170,6 +170,7 @@ static int get_product_uuid_handler(sd_bus_message *m, void *userdata, sd_bus_er
return 0;
}

+#if ENABLE_HOSTNAMED
int manager_request_product_uuid(Manager *m) {
static bool bus_method_is_called = false;
int r;
@@ -207,6 +208,7 @@ int manager_request_product_uuid(Manager *m) {

return 0;
}
+#endif

int dhcp_configure_duid(Link *link, const DUID *duid) {
Manager *m;
diff --git a/src/network/networkd-dhcp-common.h b/src/network/networkd-dhcp-common.h
index c19bc10..9d13cde 100644
--- a/src/network/networkd-dhcp-common.h
+++ b/src/network/networkd-dhcp-common.h
@@ -72,7 +72,13 @@ static inline const DUID *link_get_dhcp6_duid(Link *link) {
}

int dhcp_configure_duid(Link *link, const DUID *duid);
+#if ENABLE_HOSTNAMED
int manager_request_product_uuid(Manager *m);
+#else
+static inline int manager_request_product_uuid(_unused_ Manager *m) {
+ return 0;
+}
+#endif

bool address_is_filtered(int family, const union in_addr_union *address, uint8_t prefixlen, Set *allow_list, Set *deny_list);
static inline bool in4_address_is_filtered(const struct in_addr *address, Set *allow_list, Set *deny_list) {
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index ff2770f..a225526 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -845,6 +845,7 @@ static int set_hostname_handler(sd_bus_message *m, void *userdata, sd_bus_error
return 1;
}

+#if ENABLE_HOSTNAMED
int manager_set_hostname(Manager *m, const char *hostname) {
int r;

@@ -876,6 +877,7 @@ int manager_set_hostname(Manager *m, const char *hostname) {

return 0;
}
+#endif

static int set_timezone_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
const sd_bus_error *e;
@@ -892,6 +894,7 @@ static int set_timezone_handler(sd_bus_message *m, void *userdata, sd_bus_error
return 1;
}

+#if ENABLE_TIMEDATED
int manager_set_timezone(Manager *m, const char *tz) {
int r;

@@ -925,3 +928,4 @@ int manager_set_timezone(Manager *m, const char *tz) {

return 0;
}
+#endif
diff --git a/src/network/networkd-manager.h b/src/network/networkd-manager.h
index 86de529..b80c6c5 100644
--- a/src/network/networkd-manager.h
+++ b/src/network/networkd-manager.h
@@ -110,7 +110,20 @@ bool manager_should_reload(Manager *m);

int manager_enumerate(Manager *m);

+#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 */
+
+#if ENABLE_TIMEDATED
int manager_set_timezone(Manager *m, const char *timezone);
+#else
+static inline int manager_set_timezone(_unused_ Manager *m, _unused_ const char *timezone) {
+ return 0;
+}
+#endif /* ENABLE_TIMEDATED */

DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
--
2.38.1

4 changes: 4 additions & 0 deletions packages/systemd/systemd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ Patch9011: 9011-units-keep-modprobe-service-units-running.patch
# allows us to exclude them when not using networkd.
Patch9012: 9012-tmpfiles-Split-networkd-entries-into-a-separate-file.patch

# Local patch to conditionalize systemd-networkd calls to hostname and timezone
# DBUS services not used in Bottlerocket
Patch9013: 9013-systemd-networkd-Conditionalize-hostnamed-timezoned-DBUS.patch

BuildRequires: gperf
BuildRequires: intltool
BuildRequires: meson
Expand Down