merge: branch 'fg/duid_enforce_as_bool'

https://github.com/NetworkManager/NetworkManager/pull/142
This commit is contained in:
Francesco Giudici 2018-06-20 10:46:20 +02:00
commit 1dba7eda7a
7 changed files with 16 additions and 27 deletions

View file

@ -7828,7 +7828,7 @@ generate_duid_from_machine_id (void)
}
static GBytes *
dhcp6_get_duid (NMDevice *self, NMConnection *connection, GBytes *hwaddr, NMDhcpDuidEnforce *out_enforce)
dhcp6_get_duid (NMDevice *self, NMConnection *connection, GBytes *hwaddr, gboolean *out_enforce)
{
NMSettingIPConfig *s_ip6;
const char *duid;
@ -7837,7 +7837,7 @@ dhcp6_get_duid (NMDevice *self, NMConnection *connection, GBytes *hwaddr, NMDhcp
GBytes *duid_out;
guint8 sha256_digest[32];
gsize len = sizeof (sha256_digest);
NMDhcpDuidEnforce duid_enforce = NM_DHCP_DUID_ENFORCE_ALWAYS;
gboolean duid_enforce = TRUE;
gs_free char *logstr1 = NULL;
s_ip6 = nm_connection_get_setting_ip6_config (connection);
@ -7852,7 +7852,7 @@ dhcp6_get_duid (NMDevice *self, NMConnection *connection, GBytes *hwaddr, NMDhcp
}
if (nm_streq (duid, "lease")) {
duid_enforce = NM_DHCP_DUID_ENFORCE_NEVER;
duid_enforce = FALSE;
duid_out = generate_duid_from_machine_id ();
if (!duid_out) {
duid_error = "failure to read machine-id";
@ -7972,7 +7972,7 @@ out_good:
"ipv6.dhcp-duid: generate %s DUID '%s' (%s)",
duid,
(logstr1 = nm_dhcp_utils_duid_to_string (duid_out)),
(duid_enforce == NM_DHCP_DUID_ENFORCE_ALWAYS) ? "enforcing" : "fallback");
duid_enforce ? "enforcing" : "prefer lease");
NM_SET_OUT (out_enforce, duid_enforce);
return duid_out;
@ -7985,7 +7985,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
NMSettingIPConfig *s_ip6;
gs_unref_bytes GBytes *hwaddr = NULL;
gs_unref_bytes GBytes *duid = NULL;
NMDhcpDuidEnforce enforce_duid = NM_DHCP_DUID_ENFORCE_NEVER;
gboolean enforce_duid = FALSE;
const NMPlatformIP6Address *ll_addr = NULL;

View file

@ -513,7 +513,7 @@ nm_dhcp_client_start_ip4 (NMDhcpClient *self,
}
static GBytes *
get_duid (NMDhcpClient *self, gboolean global)
get_duid (NMDhcpClient *self)
{
return NULL;
}
@ -521,7 +521,7 @@ get_duid (NMDhcpClient *self, gboolean global)
gboolean
nm_dhcp_client_start_ip6 (NMDhcpClient *self,
GBytes *client_id,
NMDhcpDuidEnforce enforce_duid,
gboolean enforce_duid,
const char *dhcp_anycast_addr,
const struct in6_addr *ll_addr,
const char *hostname,
@ -541,12 +541,9 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
nm_assert (!priv->duid);
nm_assert (client_id);
if (enforce_duid == NM_DHCP_DUID_ENFORCE_NEVER)
priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self, TRUE);
else if (enforce_duid == NM_DHCP_DUID_ENFORCE_LEASE_FALLBACK)
priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self, FALSE);
if (!enforce_duid)
priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self);
/* NM_DHCP_DUID_ENFORCE_ALWAYS and fallback */
if (!priv->duid)
priv->duid = g_bytes_ref (client_id);

View file

@ -96,15 +96,13 @@ typedef struct {
/**
* get_duid:
* @self: the #NMDhcpClient
* @global: if set to #true, the duid should be searched also in the
* DHCP client's system-wide persistent configuration.
*
* Attempts to find an existing DHCPv6 DUID for this client in the DHCP
* client's persistent configuration. Returned DUID should be the binary
* representation of the DUID. If no DUID is found, %NULL should be
* returned.
*/
GBytes *(*get_duid) (NMDhcpClient *self, gboolean global);
GBytes *(*get_duid) (NMDhcpClient *self);
/* Signals */
void (*state_changed) (NMDhcpClient *self,
@ -153,7 +151,7 @@ gboolean nm_dhcp_client_start_ip4 (NMDhcpClient *self,
gboolean nm_dhcp_client_start_ip6 (NMDhcpClient *self,
GBytes *client_id,
NMDhcpDuidEnforce enforce_duid,
gboolean enforce_duid,
const char *dhcp_anycast_addr,
const struct in6_addr *ll_addr,
const char *hostname,

View file

@ -582,7 +582,7 @@ state_changed (NMDhcpClient *client,
}
static GBytes *
get_duid (NMDhcpClient *client, gboolean global)
get_duid (NMDhcpClient *client)
{
NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client);
NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
@ -607,7 +607,7 @@ get_duid (NMDhcpClient *client, gboolean global)
g_free (leasefile);
}
if (!duid && global) {
if (!duid) {
/* Otherwise read the default machine-wide DUID */
_LOGD ("looking for default DUID in '%s'", priv->def_leasefile);
duid = nm_dhcp_dhclient_read_duid (priv->def_leasefile, &error);

View file

@ -164,7 +164,7 @@ client_start (NMDhcpManager *self,
guint32 route_metric,
const struct in6_addr *ipv6_ll_addr,
GBytes *dhcp_client_id,
NMDhcpDuidEnforce enforce_duid,
gboolean enforce_duid,
guint32 timeout,
const char *dhcp_anycast_addr,
const char *hostname,
@ -299,7 +299,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
gboolean send_hostname,
const char *dhcp_hostname,
GBytes *duid,
NMDhcpDuidEnforce enforce_duid,
gboolean enforce_duid,
guint32 timeout,
const char *dhcp_anycast_addr,
gboolean info_only,

View file

@ -73,7 +73,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
gboolean send_hostname,
const char *dhcp_hostname,
GBytes *duid,
NMDhcpDuidEnforce enforce_duid,
gboolean enforce_duid,
guint32 timeout,
const char *dhcp_anycast_addr,
gboolean info_only,

View file

@ -24,12 +24,6 @@
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"
typedef enum {
NM_DHCP_DUID_ENFORCE_NEVER = 0,
NM_DHCP_DUID_ENFORCE_LEASE_FALLBACK,
NM_DHCP_DUID_ENFORCE_ALWAYS,
} NMDhcpDuidEnforce;
NMIP4Config *nm_dhcp_utils_ip4_config_from_options (struct _NMDedupMultiIndex *multi_idx,
int ifindex,
const char *iface,