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
......@@ -35,6 +35,8 @@
#include <fcntl.h>
#include <linux/if_addr.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-common-macros.h"
#include "nm-device-private.h"
#include "NetworkManagerUtils.h"
......@@ -647,12 +649,32 @@ nm_device_get_netns (NMDevice *self)
return NM_DEVICE_GET_PRIVATE (self)->netns;
}
NMDedupMultiIndex *
nm_device_get_multi_index (NMDevice *self)
{
return nm_netns_get_multi_idx (nm_device_get_netns (self));
}
NMPlatform *
nm_device_get_platform (NMDevice *self)
{
return nm_netns_get_platform (nm_device_get_netns (self));
}
static NMIP4Config *
_ip4_config_new (NMDevice *self)
{
return nm_ip4_config_new (nm_device_get_multi_index (self),
nm_device_get_ip_ifindex (self));
}
static NMIP6Config *
_ip6_config_new (NMDevice *self)
{
return nm_ip6_config_new (nm_device_get_multi_index (self),
nm_device_get_ip_ifindex (self));
}
/*****************************************************************************/
NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_sys_iface_state_to_str, NMDeviceSysIfaceState,
......@@ -5058,7 +5080,7 @@ ipv4_manual_method_apply (NMDevice *self, NMIP4Config **configs, gboolean succes
NMIP4Config *empty;
if (success) {
empty = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
empty = _ip4_config_new (self);
nm_device_activate_schedule_ip4_config_result (self, empty);
g_object_unref (empty);
} else {
......@@ -5215,7 +5237,7 @@ ipv4ll_get_ip4_config (NMDevice *self, guint32 lla)
NMPlatformIP4Address address;
NMPlatformIP4Route route;
config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
config = _ip4_config_new (self);
g_assert (config);
memset (&address, 0, sizeof (address));
......@@ -5430,7 +5452,6 @@ static void
ensure_con_ip4_config (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
int ip_ifindex = nm_device_get_ip_ifindex (self);
NMConnection *connection;
if (priv->con_ip4_config)
......@@ -5440,7 +5461,7 @@ ensure_con_ip4_config (NMDevice *self)
if (!connection)
return;
priv->con_ip4_config = nm_ip4_config_new (ip_ifindex);
priv->con_ip4_config = _ip4_config_new (self);
nm_ip4_config_merge_setting (priv->con_ip4_config,
nm_connection_get_setting_ip4_config (connection),
nm_device_get_ip4_route_metric (self));
......@@ -5456,7 +5477,6 @@ static void
ensure_con_ip6_config (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
int ip_ifindex = nm_device_get_ip_ifindex (self);
NMConnection *connection;
if (priv->con_ip6_config)
......@@ -5466,7 +5486,7 @@ ensure_con_ip6_config (NMDevice *self)
if (!connection)
return;
priv->con_ip6_config = nm_ip6_config_new (ip_ifindex);
priv->con_ip6_config = _ip6_config_new (self);
nm_ip6_config_merge_setting (priv->con_ip6_config,
nm_connection_get_setting_ip6_config (connection),
nm_device_get_ip6_route_metric (self));
......@@ -5548,14 +5568,15 @@ ip4_config_merge_and_apply (NMDevice *self,
}
}
composite = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
composite = _ip4_config_new (self);
init_ip4_config_dns_priority (self, composite);
if (commit) {
ensure_con_ip4_config (self);
if (priv->queued_ip4_config_id) {
g_clear_object (&priv->ext_ip4_config);
priv->ext_ip4_config = nm_ip4_config_capture (nm_device_get_platform (self),
priv->ext_ip4_config = nm_ip4_config_capture (nm_device_get_multi_index (self),
nm_device_get_platform (self),
nm_device_get_ip_ifindex (self),
FALSE);
}
......@@ -5824,7 +5845,7 @@ dhcp4_state_changed (NMDhcpClient *client,
connection = nm_device_get_applied_connection (self);
g_assert (connection);
manual = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
manual = _ip4_config_new (self);
nm_ip4_config_merge_setting (manual,
nm_connection_get_setting_ip4_config (connection),
nm_device_get_ip4_route_metric (self));
......@@ -5905,6 +5926,7 @@ dhcp4_start (NMDevice *self,
/* Begin DHCP on the interface */
g_warn_if_fail (priv->dhcp4.client == NULL);
priv->dhcp4.client = nm_dhcp_manager_start_ip4 (nm_dhcp_manager_get (),
nm_netns_get_multi_idx (nm_device_get_netns (self)),
nm_device_get_ip_iface (self),
nm_device_get_ip_ifindex (self),
tmp,
......@@ -6012,7 +6034,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection)
is_generated = TRUE;
}
config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
config = _ip4_config_new (self);
nm_ip4_config_add_address (config, &address);
if (is_generated) {
/* Remove the address lock when the object gets disposed */
......@@ -6173,7 +6195,7 @@ act_stage3_ip4_config_start (NMDevice *self,
} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) {
NMIP4Config **configs, *config;
config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
config = _ip4_config_new (self);
nm_ip4_config_merge_setting (config,
nm_connection_get_setting_ip4_config (connection),
nm_device_get_ip4_route_metric (self));
......@@ -6273,7 +6295,7 @@ ip6_config_merge_and_apply (NMDevice *self,
}
}
composite = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
composite = _ip6_config_new (self);
nm_ip6_config_set_privacy (composite,
priv->ndisc ?
priv->ndisc_use_tempaddr :
......@@ -6285,7 +6307,8 @@ ip6_config_merge_and_apply (NMDevice *self,
if (priv->queued_ip6_config_id) {
g_clear_object (&priv->ext_ip6_config);
g_clear_object (&priv->ext_ip6_config_captured);
priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_platform (self),
priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_multi_index (self),
nm_device_get_platform (self),
nm_device_get_ip_ifindex (self),
FALSE,
NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
......@@ -6702,6 +6725,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
}
priv->dhcp6.client = nm_dhcp_manager_start_ip6 (nm_dhcp_manager_get (),
nm_device_get_multi_index (self),
nm_device_get_ip_iface (self),
nm_device_get_ip_ifindex (self),
tmp,
......@@ -6830,7 +6854,7 @@ nm_device_use_ip6_subnet (NMDevice *self, const NMPlatformIP6Address *subnet)
NMPlatformIP6Address address = *subnet;
if (!priv->ac_ip6_config)
priv->ac_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
priv->ac_ip6_config = _ip6_config_new (self);
/* Assign a ::1 address in the subnet for us. */
address.address.s6_addr32[3] |= htonl (1);
......@@ -6860,7 +6884,7 @@ nm_device_copy_ip6_dns_config (NMDevice *self, NMDevice *from_device)
nm_ip6_config_reset_nameservers (priv->ac_ip6_config);
nm_ip6_config_reset_searches (priv->ac_ip6_config);
} else
priv->ac_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
priv->ac_ip6_config = _ip6_config_new (self);
if (from_device)
from_config = nm_device_get_ip6_config (from_device);
......@@ -7280,7 +7304,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
g_return_if_fail (priv->act_request);
if (!priv->ac_ip6_config)
priv->ac_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
priv->ac_ip6_config = _ip6_config_new (self);
if (changed & NM_NDISC_CONFIG_GATEWAYS) {
/* Use the first gateway as ordered in neighbor discovery cache. */
......@@ -7802,7 +7826,8 @@ act_stage3_ip6_config_start (NMDevice *self,
*/
nm_platform_process_events (nm_device_get_platform (self));
g_clear_object (&priv->ext_ip6_config_captured);
priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_platform (self),
priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_multi_index (self),
nm_device_get_platform (self),
nm_device_get_ip_ifindex (self),
FALSE,
NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
......@@ -7876,7 +7901,7 @@ nm_device_activate_stage3_ip4_start (NMDevice *self)
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &ip4_config, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
if (!ip4_config)
ip4_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
ip4_config = _ip4_config_new (self);
nm_device_activate_schedule_ip4_config_result (self, ip4_config);
g_object_unref (ip4_config);
} else if (ret == NM_ACT_STAGE_RETURN_IP_DONE) {
......@@ -7923,7 +7948,7 @@ nm_device_activate_stage3_ip6_start (NMDevice *self)
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip6_config_start (self, &ip6_config, &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
if (!ip6_config)
ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
ip6_config = _ip6_config_new (self);
/* Here we get a static IPv6 config, like for Shared where it's
* autogenerated or from modems where it comes from ModemManager.
*/
......@@ -8510,7 +8535,7 @@ dad6_get_pending_addresses (NMDevice *self)
nm_platform_ip6_address_to_string (pl_addr, NULL, 0));
if (!dad6_config)
dad6_config = nm_ip6_config_new (ifindex);
dad6_config = _ip6_config_new (self);
nm_ip6_config_add_address (dad6_config, pl_addr);
}
......@@ -8925,7 +8950,7 @@ nm_device_reactivate_ip4_config (NMDevice *self,
if (priv->ip4_state != IP_NONE) {
g_clear_object (&priv->con_ip4_config);
g_clear_object (&priv->ext_ip4_config);
priv->con_ip4_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
priv->con_ip4_config = _ip4_config_new (self);
nm_ip4_config_merge_setting (priv->con_ip4_config,
s_ip4_new,
nm_device_get_ip4_route_metric (self));
......@@ -8967,7 +8992,7 @@ nm_device_reactivate_ip6_config (NMDevice *self,
if (priv->ip6_state != IP_NONE) {
g_clear_object (&priv->con_ip6_config);
g_clear_object (&priv->ext_ip6_config);
priv->con_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
priv->con_ip6_config = _ip6_config_new (self);
nm_ip6_config_merge_setting (priv->con_ip6_config,
s_ip6_new,
nm_device_get_ip6_route_metric (self));
......@@ -10562,6 +10587,7 @@ find_ip4_lease_config (NMDevice *self,
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
leases = nm_dhcp_manager_get_lease_ip_configs (nm_dhcp_manager_get (),
nm_device_get_multi_index (self),
ip_iface,
ip_ifindex,
nm_connection_get_uuid (connection),
......@@ -10680,7 +10706,8 @@ update_ip4_config (NMDevice *self, gboolean initial)
/* IPv4 */
g_clear_object (&priv->ext_ip4_config);
priv->ext_ip4_config = nm_ip4_config_capture (nm_device_get_platform (self),
priv->ext_ip4_config = nm_ip4_config_capture (nm_device_get_multi_index (self),
nm_device_get_platform (self),
ifindex,
capture_resolv_conf);
if (priv->ext_ip4_config) {
......@@ -10755,7 +10782,11 @@ update_ip6_config (NMDevice *self, gboolean initial)
/* IPv6 */
g_clear_object (&priv->ext_ip6_config);
g_clear_object (&priv->ext_ip6_config_captured);
priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_platform (self), ifindex, capture_resolv_conf, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_multi_index (self),
nm_device_get_platform (self),
ifindex,
capture_resolv_conf,
NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
if (priv->ext_ip6_config_captured) {
priv->ext_ip6_config = nm_ip6_config_new_cloned (priv->ext_ip6_config_captured);
......
......@@ -416,6 +416,7 @@ typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
GType nm_device_get_type (void);
struct _NMDedupMultiIndex *nm_device_get_multi_index (NMDevice *self);
NMNetns *nm_device_get_netns (NMDevice *self);
NMPlatform *nm_device_get_platform (NMDevice *self);
......
......@@ -910,7 +910,8 @@ static_stage3_ip4_done (NMModemBroadband *self)
data_port = mm_bearer_get_interface (self->_priv.bearer);
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));
address.address = address_network;
......@@ -1004,7 +1005,8 @@ stage3_ip6_done (NMModemBroadband *self)
data_port = mm_bearer_get_interface (self->_priv.bearer);
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);
if (address.plen <= 128)
......
......@@ -908,7 +908,8 @@ context_property_changed (GDBusProxy *proxy,
*
* 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! */
......
......@@ -30,6 +30,8 @@
#include <stdlib.h>
#include <uuid/uuid.h>
#include "nm-utils/nm-dedup-multi.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-dhcp-utils.h"
......@@ -48,6 +50,7 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_MULTI_IDX,
PROP_IFACE,
PROP_IFINDEX,
PROP_HWADDR,
......@@ -58,6 +61,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
);
typedef struct _NMDhcpClientPrivate {
NMDedupMultiIndex *multi_idx;
char * iface;
int ifindex;
GByteArray * hwaddr;
......@@ -91,6 +95,14 @@ nm_dhcp_client_get_pid (NMDhcpClient *self)
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 *
nm_dhcp_client_get_iface (NMDhcpClient *self)
{
......@@ -765,13 +777,15 @@ nm_dhcp_client_handle_event (gpointer unused,
if (g_hash_table_size (str_options)) {
if (priv->ipv6) {
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,
str_options,
priv->priority,
priv->info_only);
} 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,
str_options,
priv->priority);
......@@ -847,6 +861,13 @@ set_property (GObject *object, guint prop_id,
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE ((NMDhcpClient *) object);
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:
/* construct-only */
priv->iface = g_value_dup_string (value);
......@@ -924,6 +945,8 @@ dispose (GObject *object)
}
G_OBJECT_CLASS (nm_dhcp_client_parent_class)->dispose (object);
priv->multi_idx = nm_dedup_multi_index_unref (priv->multi_idx);
}
static void
......@@ -940,6 +963,12 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
client_class->stop = stop;
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] =
g_param_spec_string (NM_DHCP_CLIENT_INTERFACE, "", "",
NULL,
......
......@@ -38,6 +38,7 @@
#define NM_DHCP_CLIENT_UUID "uuid"
#define NM_DHCP_CLIENT_PRIORITY "priority"
#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_PREFIX_DELEGATED "prefix-delegated"
......@@ -101,6 +102,8 @@ typedef struct {
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);
const char *nm_dhcp_client_get_iface (NMDhcpClient *self);
......@@ -173,7 +176,8 @@ typedef struct {
GType (*get_type)(void);
const char *name;
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,
const char *uuid,
gboolean ipv6,
......
......@@ -25,6 +25,8 @@
#include <ctype.h>
#include <arpa/inet.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-dhcp-utils.h"
#include "nm-ip4-config.h"
#include "nm-utils.h"
......@@ -659,6 +661,7 @@ lease_validity_span (const char *str_expire, GDateTime *now)
/**
* 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
* @ifindex: interface index of @iface
* @contents: the contents of a dhclient leasefile
......@@ -673,7 +676,8 @@ lease_validity_span (const char *str_expire, GDateTime *now)
* #NMIP6Config objects (if @ipv6 is %TRUE) containing the lease data.
*/
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,
const char *contents,
gboolean ipv6,
......@@ -783,7 +787,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface,
address.lifetime = address.preferred = expiry;
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_set_gateway (ip4, gw);
......
......@@ -42,7 +42,8 @@ gboolean nm_dhcp_dhclient_save_duid (const char *leasefile,
const char *escaped_duid,
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,
const char *contents,
gboolean ipv6,
......
......@@ -38,6 +38,8 @@
#include <arpa/inet.h>
#include <ctype.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-utils.h"
#include "nm-dhcp-dhclient-utils.h"
#include "nm-dhcp-manager.h"
......@@ -148,7 +150,8 @@ get_dhclient_leasefile (const char *iface,
}
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,
const char *uuid,
gboolean ipv6,
......@@ -166,7 +169,7 @@ nm_dhcp_dhclient_get_lease_ip_configs (const char *iface,
&& g_file_get_contents (leasefile, &contents, NULL, NULL)
&& contents
&& 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 (contents);
......
......@@ -34,6 +34,8 @@
#include <fcntl.h>
#include <stdio.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-config.h"
#include "NetworkManagerUtils.h"
......@@ -152,6 +154,7 @@ client_state_changed (NMDhcpClient *client,
static NMDhcpClient *
client_start (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
const GByteArray *hwaddr,
......@@ -195,6 +198,7 @@ client_start (NMDhcpManager *self,
/* And make a new one */
client = g_object_new (priv->client_factory->get_type (),
NM_DHCP_CLIENT_MULTI_IDX, multi_idx,
NM_DHCP_CLIENT_INTERFACE, iface,
NM_DHCP_CLIENT_IFINDEX, ifindex,
NM_DHCP_CLIENT_HWADDR, hwaddr,
......@@ -222,6 +226,7 @@ client_start (NMDhcpManager *self,
/* Caller owns a reference to the NMDhcpClient on return */
NMDhcpClient *
nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
const GByteArray *hwaddr,
......@@ -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,
use_fqdn, FALSE, 0, last_ip_address, 0);
}
......@@ -275,6 +280,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
/* Caller owns a reference to the NMDhcpClient on return */
NMDhcpClient *
nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
const GByteArray *hwaddr,
......@@ -299,7 +305,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
/* Always prefer the explicit dhcp-hostname if given */
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,
privacy, NULL, needed_prefixes);
}
......@@ -320,6 +326,7 @@ nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, const char *hostna
GSList *
nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
const char *uuid,
......@@ -336,7 +343,7 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
if ( priv->client_factory
&& 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;
}
......
......@@ -46,6 +46,7 @@ void nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager,
const char *hostname);
NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
struct _NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
const GByteArray *hwaddr,
......@@ -60,6 +61,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
const char *last_ip_address);
NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
struct _NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
const GByteArray *hwaddr,
......@@ -75,6 +77,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
guint needed_prefixes);
GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
struct _NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
const char *uuid,
......
......@@ -28,6 +28,8 @@
#include <ctype.h>
#include <net/if_arp.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-utils.h"
#include "nm-dhcp-utils.h"
#include "NetworkManagerUtils.h"
......@@ -216,7 +218,8 @@ G_STMT_START { \
} G_STMT_END
static NMIP4Config *
lease_to_ip4_config (const char *iface,
lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
sd_dhcp_lease *lease,
GHashTable *options,
......@@ -244,7 +247,7 @@ lease_to_ip4_config (const char *iface,
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 */
sd_dhcp_lease_get_address (lease, &tmp_addr);
......@@ -433,7 +436,8 @@ get_leasefile_path (const char *iface, const char *uuid, gboolean ipv6)
}
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,
const char *uuid,
gboolean ipv6,
......@@ -451,7 +455,7 @@ nm_dhcp_systemd_get_lease_ip_configs (const char *iface,
path = get_leasefile_path (iface, uuid, FALSE);
r = dhcp_lease_load (&lease, path);
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)
leases = g_slist_append (leases, ip4_config);
sd_dhcp_lease_unref (lease);
......@@ -505,7 +509,8 @@ bound4_handle (NMDhcpSystemd *self)
_LOGD ("lease available");
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)),
lease,
options,
......@@ -725,7 +730,8 @@ error:
}
static NMIP6Config *
lease_to_ip6_config (const char *iface,
lease_to_ip6_config (NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
sd_dhcp6_lease *lease,
GHashTable *options,
......@@ -743,7 +749,7 @@ lease_to_ip6_config (const char *iface,
gint32 ts;
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 ();
/* Addresses */
......@@ -830,7 +836,8 @@ bound6_handle (NMDhcpSystemd *self)
_LOGD ("lease available");
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)),
lease,
options,
......
......@@ -24,6 +24,8 @@
#include <unistd.h>
#include <arpa/inet.h>
#include "nm-utils/nm-dedup-multi.h"
#include "nm-dhcp-utils.h"
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
......@@ -383,7 +385,8 @@ ip4_add_domain_search (gpointer data, gpointer user_data)
}
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,
GHashTable *options,
guint32 priority)
......@@ -398,7 +401,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
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));
address.timestamp = nm_utils_get_monotonic_timestamp_s ();
......@@ -616,7 +619,8 @@ nm_dhcp_utils_ip6_prefix_from_options (GHashTable *options)
}
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,
GHashTable *options,
guint32 priority,
......@@ -633,7 +637,7 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
address.plen = 128;
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");
if (str) {
......
......@@ -24,12 +24,14 @@
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"