mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 11:40:08 +01:00
dhcp: cache info-only parameter in NMDhcpClient
Optimally, NMDhcpClient would be stateless and all paramters would be passed on as argument. Clearly that is not feasable, because there are so many paramters, and in many cases they need to be cached for the lifetime of the client instance. Instead of passing info_only paramter to ip6_start() and cache it both in NMDhcpClient and NMDhcpSystemd, keep it in NMDhcpClient at one place. In the next commit, we will initialize info-only only once during the constructor, so it is immutable and somewhat stateless.
This commit is contained in:
parent
badace72dd
commit
8ff962d9e4
6 changed files with 18 additions and 13 deletions
|
|
@ -260,6 +260,14 @@ nm_dhcp_client_get_hostname (NMDhcpClient *self)
|
|||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->hostname;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_get_info_only (NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->info_only;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_get_use_fqdn (NMDhcpClient *self)
|
||||
{
|
||||
|
|
@ -359,7 +367,6 @@ stop (NMDhcpClient *self, gboolean release, const GByteArray *duid)
|
|||
nm_dhcp_client_stop_pid (priv->pid, priv->iface);
|
||||
}
|
||||
priv->pid = -1;
|
||||
priv->info_only = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -626,7 +633,6 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
|
|||
return NM_DHCP_CLIENT_GET_CLASS (self)->ip6_start (self,
|
||||
dhcp_anycast_addr,
|
||||
ll_addr,
|
||||
info_only,
|
||||
privacy,
|
||||
priv->duid,
|
||||
needed_prefixes);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ typedef struct {
|
|||
gboolean (*ip6_start) (NMDhcpClient *self,
|
||||
const char *anycast_addr,
|
||||
const struct in6_addr *ll_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const GByteArray *duid,
|
||||
guint needed_prefixes);
|
||||
|
|
@ -134,6 +133,8 @@ GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self);
|
|||
|
||||
const char *nm_dhcp_client_get_hostname (NMDhcpClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_get_info_only (NMDhcpClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_get_use_fqdn (NMDhcpClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_start_ip4 (NMDhcpClient *self,
|
||||
|
|
|
|||
|
|
@ -533,7 +533,6 @@ static gboolean
|
|||
ip6_start (NMDhcpClient *client,
|
||||
const char *dhcp_anycast_addr,
|
||||
const struct in6_addr *ll_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const GByteArray *duid,
|
||||
guint needed_prefixes)
|
||||
|
|
@ -555,7 +554,11 @@ ip6_start (NMDhcpClient *client,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
return dhclient_start (client, info_only ? "-S" : "-N", duid, FALSE, NULL, needed_prefixes);
|
||||
return dhclient_start (client,
|
||||
nm_dhcp_client_get_info_only (NM_DHCP_CLIENT (self))
|
||||
? "-S"
|
||||
: "-N",
|
||||
duid, FALSE, NULL, needed_prefixes);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ static gboolean
|
|||
ip6_start (NMDhcpClient *client,
|
||||
const char *dhcp_anycast_addr,
|
||||
const struct in6_addr *ll_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const GByteArray *duid,
|
||||
guint needed_prefixes)
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ static gboolean
|
|||
ip6_start (NMDhcpClient *client,
|
||||
const char *dhcp_anycast_addr,
|
||||
const struct in6_addr *ll_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const GByteArray *duid,
|
||||
guint needed_prefixes)
|
||||
|
|
|
|||
|
|
@ -60,8 +60,7 @@ typedef struct {
|
|||
|
||||
guint request_count;
|
||||
|
||||
gboolean privacy;
|
||||
gboolean info_only;
|
||||
bool privacy:1;
|
||||
} NMDhcpSystemdPrivate;
|
||||
|
||||
struct _NMDhcpSystemd {
|
||||
|
|
@ -854,7 +853,7 @@ bound6_handle (NMDhcpSystemd *self)
|
|||
lease,
|
||||
options,
|
||||
TRUE,
|
||||
priv->info_only,
|
||||
nm_dhcp_client_get_info_only (NM_DHCP_CLIENT (self)),
|
||||
&error);
|
||||
|
||||
if (ip6_config) {
|
||||
|
|
@ -900,7 +899,6 @@ static gboolean
|
|||
ip6_start (NMDhcpClient *client,
|
||||
const char *dhcp_anycast_addr,
|
||||
const struct in6_addr *ll_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const GByteArray *duid,
|
||||
guint needed_prefixes)
|
||||
|
|
@ -918,7 +916,6 @@ ip6_start (NMDhcpClient *client,
|
|||
|
||||
g_free (priv->lease_file);
|
||||
priv->lease_file = get_leasefile_path (AF_INET6, iface, nm_dhcp_client_get_uuid (client));
|
||||
priv->info_only = info_only;
|
||||
|
||||
r = sd_dhcp6_client_new (&priv->client6);
|
||||
if (r < 0) {
|
||||
|
|
@ -933,7 +930,7 @@ ip6_start (NMDhcpClient *client,
|
|||
|
||||
_LOGT ("dhcp-client6: set %p", priv->client6);
|
||||
|
||||
if (info_only)
|
||||
if (nm_dhcp_client_get_info_only (client))
|
||||
sd_dhcp6_client_set_information_request (priv->client6, 1);
|
||||
|
||||
/* NM stores the entire DUID which includes the uint16 "type", while systemd
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue