From 27eb23ea4468e3e6bd0155ad3eb476049ab026d4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 17 May 2022 21:46:31 +0200 Subject: [PATCH] dhcp: move accept/decline function inside "nm-dhcp-client.c" They are no longer used from outside, NMDhcpClient fully handles this. Make them static and internal. Also, decline is currently unused. It will be used soon, with ACD support. (cherry picked from commit 4a256092ee5f6c8a00475f040d85df4f1af7fa7e) --- src/core/dhcp/nm-dhcp-client.c | 24 +++++++++++++++--------- src/core/dhcp/nm-dhcp-client.h | 5 ----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index 9b731dfc99..31498de6bc 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -73,6 +73,12 @@ G_DEFINE_ABSTRACT_TYPE(NMDhcpClient, nm_dhcp_client, G_TYPE_OBJECT) /*****************************************************************************/ +static gboolean _dhcp_client_accept(NMDhcpClient *self, GError **error); +static gboolean _dhcp_client_can_accept(NMDhcpClient *self); + +_nm_unused static gboolean +_dhcp_client_decline(NMDhcpClient *self, const char *error_message, GError **error); + static void l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMDhcpClient *self); @@ -404,7 +410,7 @@ _nm_dhcp_client_notify(NMDhcpClient *self, * as a configuration parameter (in NMDhcpClientConfig). When ACD is enabled, * when a new lease gets announced, it must first use NML3Cfg to run ACD on the * interface (the previous lease -- if any -- will still be used at that point). - * If ACD fails, we call nm_dhcp_client_decline() and try to get a different + * If ACD fails, we call _dhcp_client_decline() and try to get a different * lease. * If ACD passes, we need to notify the new lease, and the user (NMDevice) may * then configure the address. We need to watch the configured addresses (in NML3Cfg), @@ -418,7 +424,7 @@ _nm_dhcp_client_notify(NMDhcpClient *self, * as a static address (bypassing ACD), then NML3Cfg is aware of that and signals * immediate success. */ - if (nm_dhcp_client_can_accept(self) && client_event_type == NM_DHCP_CLIENT_EVENT_TYPE_BOUND + if (_dhcp_client_can_accept(self) && client_event_type == NM_DHCP_CLIENT_EVENT_TYPE_BOUND && priv->l3cd && nm_l3_config_data_get_num_addresses(priv->l3cd, priv->config.addr_family) > 0) { priv->l3cfg_notify.wait_dhcp_commit = TRUE; @@ -482,8 +488,8 @@ nm_dhcp_client_stop_watch_child(NMDhcpClient *self, pid_t pid) watch_cleanup(self); } -gboolean -nm_dhcp_client_accept(NMDhcpClient *self, GError **error) +static gboolean +_dhcp_client_accept(NMDhcpClient *self, GError **error) { NMDhcpClientPrivate *priv; @@ -500,8 +506,8 @@ nm_dhcp_client_accept(NMDhcpClient *self, GError **error) return TRUE; } -gboolean -nm_dhcp_client_can_accept(NMDhcpClient *self) +static gboolean +_dhcp_client_can_accept(NMDhcpClient *self) { gboolean can_accept; @@ -514,8 +520,8 @@ nm_dhcp_client_can_accept(NMDhcpClient *self) return can_accept; } -gboolean -nm_dhcp_client_decline(NMDhcpClient *self, const char *error_message, GError **error) +static gboolean +_dhcp_client_decline(NMDhcpClient *self, const char *error_message, GError **error) { NMDhcpClientPrivate *priv; @@ -653,7 +659,7 @@ l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMDhcp _LOGD("accept address"); - if (!nm_dhcp_client_accept(self, &error)) { + if (!_dhcp_client_accept(self, &error)) { gs_free char *reason = g_strdup_printf("error accepting lease: %s", error->message); _emit_notify(self, diff --git a/src/core/dhcp/nm-dhcp-client.h b/src/core/dhcp/nm-dhcp-client.h index ef735d7df2..e213a9c723 100644 --- a/src/core/dhcp/nm-dhcp-client.h +++ b/src/core/dhcp/nm-dhcp-client.h @@ -241,11 +241,6 @@ nm_dhcp_client_get_lease(NMDhcpClient *self) return NULL; } -gboolean nm_dhcp_client_accept(NMDhcpClient *self, GError **error); -gboolean nm_dhcp_client_can_accept(NMDhcpClient *self); - -gboolean nm_dhcp_client_decline(NMDhcpClient *self, const char *error_message, GError **error); - void nm_dhcp_client_stop(NMDhcpClient *self, gboolean release); /* Backend helpers for subclasses */