Commit 89385bd9 authored by Thomas Haller's avatar Thomas Haller

core: pass NMDedupMultiIndex instance to NMIP4Config and other

NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.

For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.

The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
parent 6d9c3eab
This diff is collapsed.
...@@ -416,6 +416,7 @@ typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device, ...@@ -416,6 +416,7 @@ typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
GType nm_device_get_type (void); GType nm_device_get_type (void);
struct _NMDedupMultiIndex *nm_device_get_multi_index (NMDevice *self);
NMNetns *nm_device_get_netns (NMDevice *self); NMNetns *nm_device_get_netns (NMDevice *self);
NMPlatform *nm_device_get_platform (NMDevice *self); NMPlatform *nm_device_get_platform (NMDevice *self);
......
...@@ -910,7 +910,8 @@ static_stage3_ip4_done (NMModemBroadband *self) ...@@ -910,7 +910,8 @@ static_stage3_ip4_done (NMModemBroadband *self)
data_port = mm_bearer_get_interface (self->_priv.bearer); data_port = mm_bearer_get_interface (self->_priv.bearer);
g_assert (data_port); g_assert (data_port);
config = nm_ip4_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); config = nm_ip4_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET),
nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port));
memset (&address, 0, sizeof (address)); memset (&address, 0, sizeof (address));
address.address = address_network; address.address = address_network;
...@@ -1004,7 +1005,8 @@ stage3_ip6_done (NMModemBroadband *self) ...@@ -1004,7 +1005,8 @@ stage3_ip6_done (NMModemBroadband *self)
data_port = mm_bearer_get_interface (self->_priv.bearer); data_port = mm_bearer_get_interface (self->_priv.bearer);
g_assert (data_port); g_assert (data_port);
config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); config = nm_ip6_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET),
nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port));
address.plen = mm_bearer_ip_config_get_prefix (self->_priv.ipv6_config); address.plen = mm_bearer_ip_config_get_prefix (self->_priv.ipv6_config);
if (address.plen <= 128) if (address.plen <= 128)
......
...@@ -908,7 +908,8 @@ context_property_changed (GDBusProxy *proxy, ...@@ -908,7 +908,8 @@ context_property_changed (GDBusProxy *proxy,
* *
* This needs discussion with upstream. * This needs discussion with upstream.
*/ */
priv->ip4_config = nm_ip4_config_new (0); priv->ip4_config = nm_ip4_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET),
0);
/* TODO: simply if/else error logic! */ /* TODO: simply if/else error logic! */
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include "nm-utils/nm-dedup-multi.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-dhcp-utils.h" #include "nm-dhcp-utils.h"
...@@ -48,6 +50,7 @@ enum { ...@@ -48,6 +50,7 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 }; static guint signals[LAST_SIGNAL] = { 0 };
NM_GOBJECT_PROPERTIES_DEFINE_BASE ( NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_MULTI_IDX,
PROP_IFACE, PROP_IFACE,
PROP_IFINDEX, PROP_IFINDEX,
PROP_HWADDR, PROP_HWADDR,
...@@ -58,6 +61,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( ...@@ -58,6 +61,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
); );
typedef struct _NMDhcpClientPrivate { typedef struct _NMDhcpClientPrivate {
NMDedupMultiIndex *multi_idx;
char * iface; char * iface;
int ifindex; int ifindex;
GByteArray * hwaddr; GByteArray * hwaddr;
...@@ -91,6 +95,14 @@ nm_dhcp_client_get_pid (NMDhcpClient *self) ...@@ -91,6 +95,14 @@ nm_dhcp_client_get_pid (NMDhcpClient *self)
return NM_DHCP_CLIENT_GET_PRIVATE (self)->pid; return NM_DHCP_CLIENT_GET_PRIVATE (self)->pid;
} }
NMDedupMultiIndex *
nm_dhcp_client_get_multi_idx (NMDhcpClient *self)
{
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL);
return NM_DHCP_CLIENT_GET_PRIVATE (self)->multi_idx;
}
const char * const char *
nm_dhcp_client_get_iface (NMDhcpClient *self) nm_dhcp_client_get_iface (NMDhcpClient *self)
{ {
...@@ -765,13 +777,15 @@ nm_dhcp_client_handle_event (gpointer unused, ...@@ -765,13 +777,15 @@ nm_dhcp_client_handle_event (gpointer unused,
if (g_hash_table_size (str_options)) { if (g_hash_table_size (str_options)) {
if (priv->ipv6) { if (priv->ipv6) {
prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options); prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options);
ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (priv->ifindex, ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self),
priv->ifindex,
priv->iface, priv->iface,
str_options, str_options,
priv->priority, priv->priority,
priv->info_only); priv->info_only);
} else { } else {
ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (priv->ifindex, ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (nm_dhcp_client_get_multi_idx (self),
priv->ifindex,
priv->iface, priv->iface,
str_options, str_options,
priv->priority); priv->priority);
...@@ -847,6 +861,13 @@ set_property (GObject *object, guint prop_id, ...@@ -847,6 +861,13 @@ set_property (GObject *object, guint prop_id,
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE ((NMDhcpClient *) object); NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE ((NMDhcpClient *) object);
switch (prop_id) { switch (prop_id) {
case PROP_MULTI_IDX:
/* construct-only */
priv->multi_idx = g_value_get_pointer (value);
if (!priv->multi_idx)
g_return_if_reached ();
nm_dedup_multi_index_ref (priv->multi_idx);
break;
case PROP_IFACE: case PROP_IFACE:
/* construct-only */ /* construct-only */
priv->iface = g_value_dup_string (value); priv->iface = g_value_dup_string (value);
...@@ -924,6 +945,8 @@ dispose (GObject *object) ...@@ -924,6 +945,8 @@ dispose (GObject *object)
} }
G_OBJECT_CLASS (nm_dhcp_client_parent_class)->dispose (object); G_OBJECT_CLASS (nm_dhcp_client_parent_class)->dispose (object);
priv->multi_idx = nm_dedup_multi_index_unref (priv->multi_idx);
} }
static void static void
...@@ -940,6 +963,12 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class) ...@@ -940,6 +963,12 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
client_class->stop = stop; client_class->stop = stop;
client_class->get_duid = get_duid; client_class->get_duid = get_duid;
obj_properties[PROP_MULTI_IDX] =
g_param_spec_pointer (NM_DHCP_CLIENT_MULTI_IDX, "", "",
G_PARAM_WRITABLE
| G_PARAM_CONSTRUCT_ONLY
| G_PARAM_STATIC_STRINGS);
obj_properties[PROP_IFACE] = obj_properties[PROP_IFACE] =
g_param_spec_string (NM_DHCP_CLIENT_INTERFACE, "", "", g_param_spec_string (NM_DHCP_CLIENT_INTERFACE, "", "",
NULL, NULL,
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#define NM_DHCP_CLIENT_UUID "uuid" #define NM_DHCP_CLIENT_UUID "uuid"
#define NM_DHCP_CLIENT_PRIORITY "priority" #define NM_DHCP_CLIENT_PRIORITY "priority"
#define NM_DHCP_CLIENT_TIMEOUT "timeout" #define NM_DHCP_CLIENT_TIMEOUT "timeout"
#define NM_DHCP_CLIENT_MULTI_IDX "multi-idx"
#define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed" #define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed"
#define NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED "prefix-delegated" #define NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED "prefix-delegated"
...@@ -101,6 +102,8 @@ typedef struct { ...@@ -101,6 +102,8 @@ typedef struct {
GType nm_dhcp_client_get_type (void); GType nm_dhcp_client_get_type (void);
struct _NMDedupMultiIndex *nm_dhcp_client_get_multi_idx (NMDhcpClient *self);
pid_t nm_dhcp_client_get_pid (NMDhcpClient *self); pid_t nm_dhcp_client_get_pid (NMDhcpClient *self);
const char *nm_dhcp_client_get_iface (NMDhcpClient *self); const char *nm_dhcp_client_get_iface (NMDhcpClient *self);
...@@ -173,7 +176,8 @@ typedef struct { ...@@ -173,7 +176,8 @@ typedef struct {
GType (*get_type)(void); GType (*get_type)(void);
const char *name; const char *name;
const char *(*get_path) (void); const char *(*get_path) (void);
GSList *(*get_lease_ip_configs) (const char *iface, GSList *(*get_lease_ip_configs) (struct _NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex, int ifindex,
const char *uuid, const char *uuid,
gboolean ipv6, gboolean ipv6,
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <ctype.h> #include <ctype.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-dhcp-utils.h" #include "nm-dhcp-utils.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "nm-utils.h" #include "nm-utils.h"
...@@ -659,6 +661,7 @@ lease_validity_span (const char *str_expire, GDateTime *now) ...@@ -659,6 +661,7 @@ lease_validity_span (const char *str_expire, GDateTime *now)
/** /**
* nm_dhcp_dhclient_read_lease_ip_configs: * nm_dhcp_dhclient_read_lease_ip_configs:
* @multi_idx: the multi index instance for the ip config object
* @iface: the interface name to match leases with * @iface: the interface name to match leases with
* @ifindex: interface index of @iface * @ifindex: interface index of @iface
* @contents: the contents of a dhclient leasefile * @contents: the contents of a dhclient leasefile
...@@ -673,7 +676,8 @@ lease_validity_span (const char *str_expire, GDateTime *now) ...@@ -673,7 +676,8 @@ lease_validity_span (const char *str_expire, GDateTime *now)
* #NMIP6Config objects (if @ipv6 is %TRUE) containing the lease data. * #NMIP6Config objects (if @ipv6 is %TRUE) containing the lease data.
*/ */
GSList * GSList *
nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, nm_dhcp_dhclient_read_lease_ip_configs (NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex, int ifindex,
const char *contents, const char *contents,
gboolean ipv6, gboolean ipv6,
...@@ -783,7 +787,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, ...@@ -783,7 +787,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface,
address.lifetime = address.preferred = expiry; address.lifetime = address.preferred = expiry;
address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
ip4 = nm_ip4_config_new (ifindex); ip4 = nm_ip4_config_new (multi_idx, ifindex);
nm_ip4_config_add_address (ip4, &address); nm_ip4_config_add_address (ip4, &address);
nm_ip4_config_set_gateway (ip4, gw); nm_ip4_config_set_gateway (ip4, gw);
......
...@@ -42,7 +42,8 @@ gboolean nm_dhcp_dhclient_save_duid (const char *leasefile, ...@@ -42,7 +42,8 @@ gboolean nm_dhcp_dhclient_save_duid (const char *leasefile,
const char *escaped_duid, const char *escaped_duid,
GError **error); GError **error);
GSList *nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, GSList *nm_dhcp_dhclient_read_lease_ip_configs (struct _NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex, int ifindex,
const char *contents, const char *contents,
gboolean ipv6, gboolean ipv6,
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <ctype.h> #include <ctype.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-dhcp-dhclient-utils.h" #include "nm-dhcp-dhclient-utils.h"
#include "nm-dhcp-manager.h" #include "nm-dhcp-manager.h"
...@@ -148,7 +150,8 @@ get_dhclient_leasefile (const char *iface, ...@@ -148,7 +150,8 @@ get_dhclient_leasefile (const char *iface,
} }
static GSList * static GSList *
nm_dhcp_dhclient_get_lease_ip_configs (const char *iface, nm_dhcp_dhclient_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex, int ifindex,
const char *uuid, const char *uuid,
gboolean ipv6, gboolean ipv6,
...@@ -166,7 +169,7 @@ nm_dhcp_dhclient_get_lease_ip_configs (const char *iface, ...@@ -166,7 +169,7 @@ nm_dhcp_dhclient_get_lease_ip_configs (const char *iface,
&& g_file_get_contents (leasefile, &contents, NULL, NULL) && g_file_get_contents (leasefile, &contents, NULL, NULL)
&& contents && contents
&& contents[0]) && contents[0])
leases = nm_dhcp_dhclient_read_lease_ip_configs (iface, ifindex, contents, ipv6, NULL); leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, iface, ifindex, contents, ipv6, NULL);
g_free (leasefile); g_free (leasefile);
g_free (contents); g_free (contents);
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-config.h" #include "nm-config.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
...@@ -152,6 +154,7 @@ client_state_changed (NMDhcpClient *client, ...@@ -152,6 +154,7 @@ client_state_changed (NMDhcpClient *client,
static NMDhcpClient * static NMDhcpClient *
client_start (NMDhcpManager *self, client_start (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
const char *iface, const char *iface,
int ifindex, int ifindex,
const GByteArray *hwaddr, const GByteArray *hwaddr,
...@@ -195,6 +198,7 @@ client_start (NMDhcpManager *self, ...@@ -195,6 +198,7 @@ client_start (NMDhcpManager *self,
/* And make a new one */ /* And make a new one */
client = g_object_new (priv->client_factory->get_type (), client = g_object_new (priv->client_factory->get_type (),
NM_DHCP_CLIENT_MULTI_IDX, multi_idx,
NM_DHCP_CLIENT_INTERFACE, iface, NM_DHCP_CLIENT_INTERFACE, iface,
NM_DHCP_CLIENT_IFINDEX, ifindex, NM_DHCP_CLIENT_IFINDEX, ifindex,
NM_DHCP_CLIENT_HWADDR, hwaddr, NM_DHCP_CLIENT_HWADDR, hwaddr,
...@@ -222,6 +226,7 @@ client_start (NMDhcpManager *self, ...@@ -222,6 +226,7 @@ client_start (NMDhcpManager *self,
/* Caller owns a reference to the NMDhcpClient on return */ /* Caller owns a reference to the NMDhcpClient on return */
NMDhcpClient * NMDhcpClient *
nm_dhcp_manager_start_ip4 (NMDhcpManager *self, nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
const char *iface, const char *iface,
int ifindex, int ifindex,
const GByteArray *hwaddr, const GByteArray *hwaddr,
...@@ -267,7 +272,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self, ...@@ -267,7 +272,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
} }
} }
return client_start (self, iface, ifindex, hwaddr, uuid, priority, FALSE, NULL, return client_start (self, multi_idx, iface, ifindex, hwaddr, uuid, priority, FALSE, NULL,
dhcp_client_id, timeout, dhcp_anycast_addr, hostname, dhcp_client_id, timeout, dhcp_anycast_addr, hostname,
use_fqdn, FALSE, 0, last_ip_address, 0); use_fqdn, FALSE, 0, last_ip_address, 0);
} }
...@@ -275,6 +280,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self, ...@@ -275,6 +280,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
/* Caller owns a reference to the NMDhcpClient on return */ /* Caller owns a reference to the NMDhcpClient on return */
NMDhcpClient * NMDhcpClient *
nm_dhcp_manager_start_ip6 (NMDhcpManager *self, nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
const char *iface, const char *iface,
int ifindex, int ifindex,
const GByteArray *hwaddr, const GByteArray *hwaddr,
...@@ -299,7 +305,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self, ...@@ -299,7 +305,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
/* Always prefer the explicit dhcp-hostname if given */ /* Always prefer the explicit dhcp-hostname if given */
hostname = dhcp_hostname ? dhcp_hostname : priv->default_hostname; hostname = dhcp_hostname ? dhcp_hostname : priv->default_hostname;
} }
return client_start (self, iface, ifindex, hwaddr, uuid, priority, TRUE, return client_start (self, multi_idx, iface, ifindex, hwaddr, uuid, priority, TRUE,
ll_addr, NULL, timeout, dhcp_anycast_addr, hostname, TRUE, info_only, ll_addr, NULL, timeout, dhcp_anycast_addr, hostname, TRUE, info_only,
privacy, NULL, needed_prefixes); privacy, NULL, needed_prefixes);
} }
...@@ -320,6 +326,7 @@ nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, const char *hostna ...@@ -320,6 +326,7 @@ nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, const char *hostna
GSList * GSList *
nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
const char *iface, const char *iface,
int ifindex, int ifindex,
const char *uuid, const char *uuid,
...@@ -336,7 +343,7 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, ...@@ -336,7 +343,7 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
priv = NM_DHCP_MANAGER_GET_PRIVATE (self); priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
if ( priv->client_factory if ( priv->client_factory
&& priv->client_factory->get_lease_ip_configs) && priv->client_factory->get_lease_ip_configs)
return priv->client_factory->get_lease_ip_configs (iface, ifindex, uuid, ipv6, default_route_metric); return priv->client_factory->get_lease_ip_configs (multi_idx, iface, ifindex, uuid, ipv6, default_route_metric);
return NULL; return NULL;
} }
......
...@@ -46,6 +46,7 @@ void nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, ...@@ -46,6 +46,7 @@ void nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager,
const char *hostname); const char *hostname);
NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager, NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
struct _NMDedupMultiIndex *multi_idx,
const char *iface, const char *iface,
int ifindex, int ifindex,
const GByteArray *hwaddr, const GByteArray *hwaddr,
...@@ -60,6 +61,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager, ...@@ -60,6 +61,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
const char *last_ip_address); const char *last_ip_address);
NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager, NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
struct _NMDedupMultiIndex *multi_idx,
const char *iface, const char *iface,
int ifindex, int ifindex,
const GByteArray *hwaddr, const GByteArray *hwaddr,
...@@ -75,6 +77,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager, ...@@ -75,6 +77,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
guint needed_prefixes); guint needed_prefixes);
GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
struct _NMDedupMultiIndex *multi_idx,
const char *iface, const char *iface,
int ifindex, int ifindex,
const char *uuid, const char *uuid,
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <ctype.h> #include <ctype.h>
#include <net/if_arp.h> #include <net/if_arp.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-dhcp-utils.h" #include "nm-dhcp-utils.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
...@@ -216,7 +218,8 @@ G_STMT_START { \ ...@@ -216,7 +218,8 @@ G_STMT_START { \
} G_STMT_END } G_STMT_END
static NMIP4Config * static NMIP4Config *
lease_to_ip4_config (const char *iface, lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex, int ifindex,
sd_dhcp_lease *lease, sd_dhcp_lease *lease,
GHashTable *options, GHashTable *options,
...@@ -244,7 +247,7 @@ lease_to_ip4_config (const char *iface, ...@@ -244,7 +247,7 @@ lease_to_ip4_config (const char *iface,
g_return_val_if_fail (lease != NULL, NULL); g_return_val_if_fail (lease != NULL, NULL);
ip4_config = nm_ip4_config_new (ifindex); ip4_config = nm_ip4_config_new (multi_idx, ifindex);
/* Address */ /* Address */
sd_dhcp_lease_get_address (lease, &tmp_addr); sd_dhcp_lease_get_address (lease, &tmp_addr);
...@@ -433,7 +436,8 @@ get_leasefile_path (const char *iface, const char *uuid, gboolean ipv6) ...@@ -433,7 +436,8 @@ get_leasefile_path (const char *iface, const char *uuid, gboolean ipv6)
} }
static GSList * static GSList *
nm_dhcp_systemd_get_lease_ip_configs (const char *iface, nm_dhcp_systemd_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex, int ifindex,
const char *uuid, const char *uuid,
gboolean ipv6, gboolean ipv6,
...@@ -451,7 +455,7 @@ nm_dhcp_systemd_get_lease_ip_configs (const char *iface, ...@@ -451,7 +455,7 @@ nm_dhcp_systemd_get_lease_ip_configs (const char *iface,
path = get_leasefile_path (iface, uuid, FALSE); path = get_leasefile_path (iface, uuid, FALSE);
r = dhcp_lease_load (&lease, path); r = dhcp_lease_load (&lease, path);
if (r == 0 && lease) { if (r == 0 && lease) {
ip4_config = lease_to_ip4_config (iface, ifindex, lease, NULL, default_route_metric, FALSE, NULL); ip4_config = lease_to_ip4_config (multi_idx, iface, ifindex, lease, NULL, default_route_metric, FALSE, NULL);
if (ip4_config) if (ip4_config)
leases = g_slist_append (leases, ip4_config); leases = g_slist_append (leases, ip4_config);
sd_dhcp_lease_unref (lease); sd_dhcp_lease_unref (lease);
...@@ -505,7 +509,8 @@ bound4_handle (NMDhcpSystemd *self) ...@@ -505,7 +509,8 @@ bound4_handle (NMDhcpSystemd *self)
_LOGD ("lease available"); _LOGD ("lease available");
options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
ip4_config = lease_to_ip4_config (iface, ip4_config = lease_to_ip4_config (nm_dhcp_client_get_multi_idx (NM_DHCP_CLIENT (self)),
iface,
nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)), nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)),
lease, lease,
options, options,
...@@ -725,7 +730,8 @@ error: ...@@ -725,7 +730,8 @@ error:
} }
static NMIP6Config * static NMIP6Config *
lease_to_ip6_config (const char *iface, lease_to_ip6_config (NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex, int ifindex,
sd_dhcp6_lease *lease, sd_dhcp6_lease *lease,
GHashTable *options, GHashTable *options,
...@@ -743,7 +749,7 @@ lease_to_ip6_config (const char *iface, ...@@ -743,7 +749,7 @@ lease_to_ip6_config (const char *iface,
gint32 ts; gint32 ts;
g_return_val_if_fail (lease, NULL); g_return_val_if_fail (lease, NULL);
ip6_config = nm_ip6_config_new (ifindex); ip6_config = nm_ip6_config_new (multi_idx, ifindex);
ts = nm_utils_get_monotonic_timestamp_s (); ts = nm_utils_get_monotonic_timestamp_s ();
/* Addresses */ /* Addresses */
...@@ -830,7 +836,8 @@ bound6_handle (NMDhcpSystemd *self) ...@@ -830,7 +836,8 @@ bound6_handle (NMDhcpSystemd *self)
_LOGD ("lease available"); _LOGD ("lease available");
options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
ip6_config = lease_to_ip6_config (iface, ip6_config = lease_to_ip6_config (nm_dhcp_client_get_multi_idx (NM_DHCP_CLIENT (self)),
iface,
nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)), nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)),
lease, lease,
options, options,
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <unistd.h> #include <unistd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-dhcp-utils.h" #include "nm-dhcp-utils.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
...@@ -383,7 +385,8 @@ ip4_add_domain_search (gpointer data, gpointer user_data) ...@@ -383,7 +385,8 @@ ip4_add_domain_search (gpointer data, gpointer user_data)
} }
NMIP4Config * NMIP4Config *
nm_dhcp_utils_ip4_config_from_options (int ifindex, nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx,
int ifindex,
const char *iface, const char *iface,
GHashTable *options, GHashTable *options,
guint32 priority) guint32 priority)
...@@ -398,7 +401,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex, ...@@ -398,7 +401,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
g_return_val_if_fail (options != NULL, NULL); g_return_val_if_fail (options != NULL, NULL);
ip4_config = nm_ip4_config_new (ifindex); ip4_config = nm_ip4_config_new (multi_idx, ifindex);
memset (&address, 0, sizeof (address)); memset (&address, 0, sizeof (address));
address.timestamp = nm_utils_get_monotonic_timestamp_s (); address.timestamp = nm_utils_get_monotonic_timestamp_s ();
...@@ -616,7 +619,8 @@ nm_dhcp_utils_ip6_prefix_from_options (GHashTable *options) ...@@ -616,7 +619,8 @@ nm_dhcp_utils_ip6_prefix_from_options (GHashTable *options)
} }
NMIP6Config * NMIP6Config *
nm_dhcp_utils_ip6_config_from_options (int ifindex, nm_dhcp_utils_ip6_config_from_options (NMDedupMultiIndex *multi_idx,
int ifindex,
const char *iface, const char *iface,
GHashTable *options, GHashTable *options,
guint32 priority, guint32 priority,
...@@ -633,7 +637,7 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex, ...@@ -633,7 +637,7 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
address.plen = 128; address.plen = 128;
address.timestamp = nm_utils_get_monotonic_timestamp_s (); address.timestamp = nm_utils_get_monotonic_timestamp_s ();
ip6_config = nm_ip6_config_new (ifindex); ip6_config = nm_ip6_config_new (multi_idx, ifindex);
str = g_hash_table_lookup (options, "max_life"); str = g_hash_table_lookup (options, "max_life");
if (str) { if (str) {
......
...@@ -24,12 +24,14 @@ ...@@ -24,12 +24,14 @@
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "nm-ip6-config.h" #include "nm-ip6-config.h"
NMIP4Config *nm_dhcp_utils_ip4_config_from_options (int ifindex, NMIP4Config *nm_dhcp_utils_ip4_config_from_options (struct _NMDedupMultiIndex *multi_idx,
int ifindex,
const char *iface, const char *iface,
GHashTable *options, GHashTable *options,
guint priority); guint priority);
NMIP6Config *nm_dhcp_utils_ip6_config_from_options (int ifindex, NMIP6Config *nm_dhcp_utils_ip6_config_from_options (struct _NMDedupMultiIndex *multi_idx,
int ifindex,
const char *iface, const char *iface,
GHashTable *options, GHashTable *options,
guint priority, guint priority,
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <unistd.h> #include <unistd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include "nm-utils/nm-dedup-multi.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "dhcp/nm-dhcp-dhclient-utils.h" #include "dhcp/nm-dhcp-dhclient-utils.h"
#include "dhcp/nm-dhcp-utils.h" #include "dhcp/nm-dhcp-utils.h"
...@@ -838,6 +840,7 @@ test_interface2 (void) ...@@ -838,6 +840,7 @@ test_interface2 (void)
static void static void