device: keep NMNetns instance per device

This also ensures that we own a reference to the
NMPlatform, NMRouteManager and NMDefaultRouteManager
instances. See bug rh#1440089 where we might access
the singleton getter after destroing the singleton
instance of NMRouteManager. This is prevented by
keeping a reference to those instances -- indirectly
via the netns instance.

Later, we may add support for multiple namespaces. Then it might
make sense to swap the NMNetns instance of a device when moving
the device between namespaces.

Also, drop the use of singelton instances.

https://bugzilla.redhat.com/show_bug.cgi?id=1440089
(cherry picked from commit c48a19b7c6)
This commit is contained in:
Thomas Haller
2017-04-17 20:17:45 +02:00
parent d37b9d79bc
commit 8a6eef6aa7
14 changed files with 210 additions and 171 deletions

View File

@@ -56,6 +56,7 @@
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "settings/nm-settings.h" #include "settings/nm-settings.h"
#include "nm-auth-utils.h" #include "nm-auth-utils.h"
#include "nm-netns.h"
#include "nm-dispatcher.h" #include "nm-dispatcher.h"
#include "nm-config.h" #include "nm-config.h"
#include "dns/nm-dns-manager.h" #include "dns/nm-dns-manager.h"
@@ -445,6 +446,8 @@ typedef struct _NMDevicePrivate {
NMSettings *settings; NMSettings *settings;
NMNetns *netns;
NMLldpListener *lldp_listener; NMLldpListener *lldp_listener;
NMConnectivityState connectivity_state; NMConnectivityState connectivity_state;
guint concheck_periodic_id; guint concheck_periodic_id;
@@ -622,6 +625,18 @@ nm_device_get_settings (NMDevice *self)
return NM_DEVICE_GET_PRIVATE (self)->settings; return NM_DEVICE_GET_PRIVATE (self)->settings;
} }
NMNetns *
nm_device_get_netns (NMDevice *self)
{
return NM_DEVICE_GET_PRIVATE (self)->netns;
}
NMPlatform *
nm_device_get_platform (NMDevice *self)
{
return nm_netns_get_platform (nm_device_get_netns (self));
}
/*****************************************************************************/ /*****************************************************************************/
NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_sys_iface_state_to_str, NMDeviceSysIfaceState, NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_sys_iface_state_to_str, NMDeviceSysIfaceState,
@@ -716,7 +731,7 @@ init_ip6_config_dns_priority (NMDevice *self, NMIP6Config *config)
static gboolean static gboolean
nm_device_ipv4_sysctl_set (NMDevice *self, const char *property, const char *value) nm_device_ipv4_sysctl_set (NMDevice *self, const char *property, const char *value)
{ {
NMPlatform *platform = NM_PLATFORM_GET; NMPlatform *platform = nm_device_get_platform (self);
gs_free char *value_to_free = NULL; gs_free char *value_to_free = NULL;
const char *value_to_set; const char *value_to_set;
@@ -737,7 +752,7 @@ nm_device_ipv4_sysctl_set (NMDevice *self, const char *property, const char *val
static guint32 static guint32
nm_device_ipv4_sysctl_get_uint32 (NMDevice *self, const char *property, guint32 fallback) nm_device_ipv4_sysctl_get_uint32 (NMDevice *self, const char *property, guint32 fallback)
{ {
return nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, return nm_platform_sysctl_get_int_checked (nm_device_get_platform (self),
NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip4_property_path (nm_device_get_ip_iface (self), property)), NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip4_property_path (nm_device_get_ip_iface (self), property)),
10, 10,
0, 0,
@@ -748,13 +763,13 @@ nm_device_ipv4_sysctl_get_uint32 (NMDevice *self, const char *property, guint32
gboolean gboolean
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value) nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
{ {
return nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property)), value); return nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property)), value);
} }
static guint32 static guint32
nm_device_ipv6_sysctl_get_uint32 (NMDevice *self, const char *property, guint32 fallback) nm_device_ipv6_sysctl_get_uint32 (NMDevice *self, const char *property, guint32 fallback)
{ {
return nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, return nm_platform_sysctl_get_int_checked (nm_device_get_platform (self),
NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property)), NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property)),
10, 10,
0, 0,
@@ -984,7 +999,7 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
if (nm_streq0 (iface, priv->ip_iface)) { if (nm_streq0 (iface, priv->ip_iface)) {
if (!iface) if (!iface)
return FALSE; return FALSE;
ifindex = nm_platform_if_nametoindex (NM_PLATFORM_GET, iface); ifindex = nm_platform_if_nametoindex (nm_device_get_platform (self), iface);
if ( ifindex <= 0 if ( ifindex <= 0
|| priv->ip_ifindex == ifindex) || priv->ip_ifindex == ifindex)
return FALSE; return FALSE;
@@ -1002,7 +1017,7 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
* with this name still exists and we resolve the ifindex * with this name still exists and we resolve the ifindex
* anew. * anew.
*/ */
priv->ip_ifindex = nm_platform_if_nametoindex (NM_PLATFORM_GET, iface); priv->ip_ifindex = nm_platform_if_nametoindex (nm_device_get_platform (self), iface);
if (priv->ip_ifindex > 0) if (priv->ip_ifindex > 0)
_LOGD (LOGD_DEVICE, "ip-ifname: set ifname '%s', ifindex %d", iface, priv->ip_ifindex); _LOGD (LOGD_DEVICE, "ip-ifname: set ifname '%s', ifindex %d", iface, priv->ip_ifindex);
else else
@@ -1014,11 +1029,11 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
} }
if (priv->ip_ifindex > 0) { if (priv->ip_ifindex > 0) {
if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) if (nm_platform_check_support_user_ipv6ll (nm_device_get_platform (self)))
nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ip_ifindex, TRUE); nm_platform_link_set_user_ipv6ll_enabled (nm_device_get_platform (self), priv->ip_ifindex, TRUE);
if (!nm_platform_link_is_up (NM_PLATFORM_GET, priv->ip_ifindex)) if (!nm_platform_link_is_up (nm_device_get_platform (self), priv->ip_ifindex))
nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL); nm_platform_link_set_up (nm_device_get_platform (self), priv->ip_ifindex, NULL);
} }
/* We don't care about any saved values from the old iface */ /* We don't care about any saved values from the old iface */
@@ -1220,7 +1235,7 @@ _stats_timeout_cb (gpointer user_data)
_LOGT (LOGD_DEVICE, "stats: refresh %d", ifindex); _LOGT (LOGD_DEVICE, "stats: refresh %d", ifindex);
if (ifindex > 0) if (ifindex > 0)
nm_platform_link_refresh (NM_PLATFORM_GET, ifindex); nm_platform_link_refresh (nm_device_get_platform (self), ifindex);
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }
@@ -1277,7 +1292,7 @@ _stats_set_refresh_rate (NMDevice *self, guint refresh_rate_ms)
* we don't get the result right away. */ * we don't get the result right away. */
ifindex = nm_device_get_ip_ifindex (self); ifindex = nm_device_get_ip_ifindex (self);
if (ifindex > 0) if (ifindex > 0)
nm_platform_link_refresh (NM_PLATFORM_GET, ifindex); nm_platform_link_refresh (nm_device_get_platform (self), ifindex);
priv->stats.timeout_id = g_timeout_add (refresh_rate_ms, _stats_timeout_cb, self); priv->stats.timeout_id = g_timeout_add (refresh_rate_ms, _stats_timeout_cb, self);
} }
@@ -1296,7 +1311,7 @@ get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid)
ifindex = nm_device_get_ip_ifindex (self); ifindex = nm_device_get_ip_ifindex (self);
g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (ifindex > 0, FALSE);
pllink = nm_platform_link_get (NM_PLATFORM_GET, ifindex); pllink = nm_platform_link_get (nm_device_get_platform (self), ifindex);
if ( !pllink if ( !pllink
|| NM_IN_SET (pllink->type, NM_LINK_TYPE_NONE, NM_LINK_TYPE_UNKNOWN)) || NM_IN_SET (pllink->type, NM_LINK_TYPE_NONE, NM_LINK_TYPE_UNKNOWN))
return FALSE; return FALSE;
@@ -1574,9 +1589,9 @@ _update_default_route (NMDevice *self, int addr_family, gboolean has, gboolean i
*p_is_assumed = is_assumed; *p_is_assumed = is_assumed;
if (addr_family == AF_INET) if (addr_family == AF_INET)
nm_default_route_manager_ip4_update_default_route (nm_default_route_manager_get (), self); nm_default_route_manager_ip4_update_default_route (nm_netns_get_default_route_manager (priv->netns), self);
else else
nm_default_route_manager_ip6_update_default_route (nm_default_route_manager_get (), self); nm_default_route_manager_ip6_update_default_route (nm_netns_get_default_route_manager (priv->netns), self);
} }
const NMPlatformIP4Route * const NMPlatformIP4Route *
@@ -2051,7 +2066,7 @@ is_unmanaged_external_down (NMDevice *self, gboolean consider_can)
/* Manage externally-created software interfaces only when they are IFF_UP */ /* Manage externally-created software interfaces only when they are IFF_UP */
if ( priv->ifindex <= 0 if ( priv->ifindex <= 0
|| !priv->up || !priv->up
|| !(priv->slaves || nm_platform_link_can_assume (NM_PLATFORM_GET, priv->ifindex))) || !(priv->slaves || nm_platform_link_can_assume (nm_device_get_platform (self), priv->ifindex)))
return NM_UNMAN_FLAG_OP_SET_UNMANAGED; return NM_UNMAN_FLAG_OP_SET_UNMANAGED;
return NM_UNMAN_FLAG_OP_SET_MANAGED; return NM_UNMAN_FLAG_OP_SET_MANAGED;
@@ -2123,7 +2138,7 @@ nm_device_update_dynamic_ip_setup (NMDevice *self)
if (priv->lldp_listener && nm_lldp_listener_is_running (priv->lldp_listener)) { if (priv->lldp_listener && nm_lldp_listener_is_running (priv->lldp_listener)) {
nm_lldp_listener_stop (priv->lldp_listener); nm_lldp_listener_stop (priv->lldp_listener);
addr = nm_platform_link_get_address (NM_PLATFORM_GET, priv->ifindex, &addr_length); addr = nm_platform_link_get_address (nm_device_get_platform (self), priv->ifindex, &addr_length);
if (!nm_lldp_listener_start (priv->lldp_listener, nm_device_get_ifindex (self), &error)) { if (!nm_lldp_listener_start (priv->lldp_listener, nm_device_get_ifindex (self), &error)) {
_LOGD (LOGD_DEVICE, "LLDP listener %p could not be restarted: %s", _LOGD (LOGD_DEVICE, "LLDP listener %p could not be restarted: %s",
@@ -2295,7 +2310,7 @@ device_recheck_slave_status (NMDevice *self, const NMPlatformLink *plink)
} else { } else {
_LOGW (LOGD_DEVICE, "enslaved to unknown device %d %s", _LOGW (LOGD_DEVICE, "enslaved to unknown device %d %s",
plink->master, plink->master,
nm_platform_link_get_name (NM_PLATFORM_GET, plink->master)); nm_platform_link_get_name (nm_device_get_platform (self), plink->master));
} }
} }
} }
@@ -2386,13 +2401,13 @@ device_link_changed (NMDevice *self)
priv->device_link_changed_id = 0; priv->device_link_changed_id = 0;
ifindex = nm_device_get_ifindex (self); ifindex = nm_device_get_ifindex (self);
pllink = nm_platform_link_get (NM_PLATFORM_GET, ifindex); pllink = nm_platform_link_get (nm_device_get_platform (self), ifindex);
if (!pllink) if (!pllink)
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
info = *pllink; info = *pllink;
udi = nm_platform_link_get_udi (NM_PLATFORM_GET, info.ifindex); udi = nm_platform_link_get_udi (nm_device_get_platform (self), info.ifindex);
if (udi && g_strcmp0 (udi, priv->udi)) { if (udi && g_strcmp0 (udi, priv->udi)) {
/* Update UDI to what udev gives us */ /* Update UDI to what udev gives us */
g_free (priv->udi); g_free (priv->udi);
@@ -2540,7 +2555,7 @@ device_ip_link_changed (NMDevice *self)
if (!priv->ip_ifindex) if (!priv->ip_ifindex)
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
pllink = nm_platform_link_get (NM_PLATFORM_GET, priv->ip_ifindex); pllink = nm_platform_link_get (nm_device_get_platform (self), priv->ip_ifindex);
if (!pllink) if (!pllink)
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
@@ -2742,7 +2757,7 @@ nm_device_create_and_realize (NMDevice *self,
const NMPlatformLink *plink = NULL; const NMPlatformLink *plink = NULL;
/* Must be set before device is realized */ /* Must be set before device is realized */
priv->is_nm_owned = !nm_platform_link_get_by_ifname (NM_PLATFORM_GET, priv->iface); priv->is_nm_owned = !nm_platform_link_get_by_ifname (nm_device_get_platform (self), priv->iface);
_LOGD (LOGD_DEVICE, "create (is %snm-owned)", priv->is_nm_owned ? "" : "not "); _LOGD (LOGD_DEVICE, "create (is %snm-owned)", priv->is_nm_owned ? "" : "not ");
@@ -2773,7 +2788,7 @@ update_device_from_platform_link (NMDevice *self, const NMPlatformLink *plink)
g_return_if_fail (plink != NULL); g_return_if_fail (plink != NULL);
udi = nm_platform_link_get_udi (NM_PLATFORM_GET, plink->ifindex); udi = nm_platform_link_get_udi (nm_device_get_platform (self), plink->ifindex);
if (udi && !g_strcmp0 (udi, priv->udi)) { if (udi && !g_strcmp0 (udi, priv->udi)) {
g_free (priv->udi); g_free (priv->udi);
priv->udi = g_strdup (udi); priv->udi = g_strdup (udi);
@@ -2819,7 +2834,7 @@ check_carrier (NMDevice *self)
int ifindex = nm_device_get_ip_ifindex (self); int ifindex = nm_device_get_ip_ifindex (self);
if (!nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) if (!nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER))
nm_device_set_carrier (self, nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); nm_device_set_carrier (self, nm_platform_link_is_connected (nm_device_get_platform (self), ifindex));
} }
static void static void
@@ -2893,21 +2908,21 @@ realize_start_setup (NMDevice *self,
} }
if (priv->ifindex > 0) { if (priv->ifindex > 0) {
priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex); priv->physical_port_id = nm_platform_link_get_physical_port_id (nm_device_get_platform (self), priv->ifindex);
_notify (self, PROP_PHYSICAL_PORT_ID); _notify (self, PROP_PHYSICAL_PORT_ID);
priv->dev_id = nm_platform_link_get_dev_id (NM_PLATFORM_GET, priv->ifindex); priv->dev_id = nm_platform_link_get_dev_id (nm_device_get_platform (self), priv->ifindex);
if (nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex)) if (nm_platform_link_is_software (nm_device_get_platform (self), priv->ifindex))
capabilities |= NM_DEVICE_CAP_IS_SOFTWARE; capabilities |= NM_DEVICE_CAP_IS_SOFTWARE;
mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex); mtu = nm_platform_link_get_mtu (nm_device_get_platform (self), priv->ifindex);
if (priv->mtu != mtu) { if (priv->mtu != mtu) {
priv->mtu = mtu; priv->mtu = mtu;
_notify (self, PROP_MTU); _notify (self, PROP_MTU);
} }
nm_platform_link_get_driver_info (NM_PLATFORM_GET, nm_platform_link_get_driver_info (nm_device_get_platform (self),
priv->ifindex, priv->ifindex,
NULL, NULL,
&priv->driver_version, &priv->driver_version,
@@ -2917,8 +2932,8 @@ realize_start_setup (NMDevice *self,
if (priv->firmware_version) if (priv->firmware_version)
_notify (self, PROP_FIRMWARE_VERSION); _notify (self, PROP_FIRMWARE_VERSION);
if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) if (nm_platform_check_support_user_ipv6ll (nm_device_get_platform (self)))
priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ifindex); priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (nm_device_get_platform (self), priv->ifindex);
} }
if (klass->get_generic_capabilities) if (klass->get_generic_capabilities)
@@ -3107,7 +3122,7 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
if (!NM_DEVICE_GET_CLASS (self)->unrealize (self, error)) if (!NM_DEVICE_GET_CLASS (self)->unrealize (self, error))
return FALSE; return FALSE;
} else if (ifindex > 0) { } else if (ifindex > 0) {
nm_platform_link_delete (NM_PLATFORM_GET, ifindex); nm_platform_link_delete (nm_device_get_platform (self), ifindex);
} }
} }
@@ -3457,7 +3472,7 @@ nm_device_master_release_slaves (NMDevice *self)
if (priv->state == NM_DEVICE_STATE_FAILED) if (priv->state == NM_DEVICE_STATE_FAILED)
reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED;
if (!nm_platform_link_get (NM_PLATFORM_GET, priv->ifindex)) if (!nm_platform_link_get (nm_device_get_platform (self), priv->ifindex))
configure = FALSE; configure = FALSE;
while (priv->slaves) { while (priv->slaves) {
@@ -3897,7 +3912,7 @@ device_has_config (NMDevice *self)
return TRUE; return TRUE;
/* Master-slave relationship is also a configuration */ /* Master-slave relationship is also a configuration */
if (priv->slaves || nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) > 0) if (priv->slaves || nm_platform_link_get_master (nm_device_get_platform (self), priv->ifindex) > 0)
return TRUE; return TRUE;
return FALSE; return FALSE;
@@ -4010,7 +4025,7 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
s_ip6 = nm_ip6_config_create_setting (priv->ip6_config); s_ip6 = nm_ip6_config_create_setting (priv->ip6_config);
nm_connection_add_setting (connection, s_ip6); nm_connection_add_setting (connection, s_ip6);
pllink = nm_platform_link_get (NM_PLATFORM_GET, priv->ifindex); pllink = nm_platform_link_get (nm_device_get_platform (self), priv->ifindex);
if (pllink && pllink->inet6_token.id) { if (pllink && pllink->inet6_token.id) {
_LOGD (LOGD_IP6, "IPv6 tokenized identifier present"); _LOGD (LOGD_IP6, "IPv6 tokenized identifier present");
g_object_set (s_ip6, g_object_set (s_ip6,
@@ -4639,7 +4654,7 @@ lldp_init (NMDevice *self, gboolean restart)
} }
if (!nm_lldp_listener_is_running (priv->lldp_listener)) { if (!nm_lldp_listener_is_running (priv->lldp_listener)) {
addr = nm_platform_link_get_address (NM_PLATFORM_GET, priv->ifindex, &addr_length); addr = nm_platform_link_get_address (nm_device_get_platform (self), priv->ifindex, &addr_length);
if (nm_lldp_listener_start (priv->lldp_listener, nm_device_get_ifindex (self), &error)) if (nm_lldp_listener_start (priv->lldp_listener, nm_device_get_ifindex (self), &error))
_LOGD (LOGD_DEVICE, "LLDP listener %p started", priv->lldp_listener); _LOGD (LOGD_DEVICE, "LLDP listener %p started", priv->lldp_listener);
@@ -4986,7 +5001,7 @@ ipv4_dad_start (NMDevice *self, NMIP4Config **configs, ArpingCallback cb)
} }
timeout = get_ipv4_dad_timeout (self); timeout = get_ipv4_dad_timeout (self);
hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, hw_addr = nm_platform_link_get_address (nm_device_get_platform (self),
nm_device_get_ip_ifindex (self), nm_device_get_ip_ifindex (self),
&hw_addr_len); &hw_addr_len);
@@ -5191,7 +5206,7 @@ ipv4ll_start (NMDevice *self)
} }
ifindex = nm_device_get_ip_ifindex (self); ifindex = nm_device_get_ip_ifindex (self);
addr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addr_len); addr = nm_platform_link_get_address (nm_device_get_platform (self), ifindex, &addr_len);
if (!addr || addr_len != ETH_ALEN) { if (!addr || addr_len != ETH_ALEN) {
_LOGE (LOGD_AUTOIP4, "IPv4LL: can't retrieve hardware address"); _LOGE (LOGD_AUTOIP4, "IPv4LL: can't retrieve hardware address");
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;
@@ -5238,9 +5253,9 @@ _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlat
GArray *routes; GArray *routes;
if (addr_family == AF_INET) if (addr_family == AF_INET)
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT); routes = nm_platform_ip4_route_get_all (nm_device_get_platform (self), ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT);
else else
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT); routes = nm_platform_ip6_route_get_all (nm_device_get_platform (self), ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT);
if (routes) { if (routes) {
guint route_metric = G_MAXUINT32, m; guint route_metric = G_MAXUINT32, m;
@@ -5472,7 +5487,7 @@ ip4_config_merge_and_apply (NMDevice *self,
*/ */
connection_has_default_route connection_has_default_route
= nm_default_route_manager_ip4_connection_has_default_route (nm_default_route_manager_get (), = nm_default_route_manager_ip4_connection_has_default_route (nm_netns_get_default_route_manager (priv->netns),
connection, &connection_is_never_default); connection, &connection_is_never_default);
if ( !priv->v4_commit_first_time if ( !priv->v4_commit_first_time
@@ -5754,7 +5769,7 @@ dhcp4_start (NMDevice *self,
nm_exported_object_clear_and_unexport (&priv->dhcp4.config); nm_exported_object_clear_and_unexport (&priv->dhcp4.config);
priv->dhcp4.config = nm_dhcp4_config_new (); priv->dhcp4.config = nm_dhcp4_config_new ();
hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), &hw_addr_len); hw_addr = nm_platform_link_get_address (nm_device_get_platform (self), nm_device_get_ip_ifindex (self), &hw_addr_len);
if (hw_addr_len) { if (hw_addr_len) {
tmp = g_byte_array_sized_new (hw_addr_len); tmp = g_byte_array_sized_new (hw_addr_len);
g_byte_array_append (tmp, hw_addr, hw_addr_len); g_byte_array_append (tmp, hw_addr, hw_addr_len);
@@ -6219,7 +6234,7 @@ ip6_config_merge_and_apply (NMDevice *self,
*/ */
connection_has_default_route connection_has_default_route
= nm_default_route_manager_ip6_connection_has_default_route (nm_default_route_manager_get (), = nm_default_route_manager_ip6_connection_has_default_route (nm_netns_get_default_route_manager (priv->netns),
connection, &connection_is_never_default); connection, &connection_is_never_default);
if ( !priv->v6_commit_first_time if ( !priv->v6_commit_first_time
@@ -6284,7 +6299,7 @@ END_ADD_DEFAULT_ROUTE:
NMUtilsIPv6IfaceId iid; NMUtilsIPv6IfaceId iid;
if (token && nm_utils_ipv6_interface_identifier_get_from_token (&iid, token)) { if (token && nm_utils_ipv6_interface_identifier_get_from_token (&iid, token)) {
nm_platform_link_set_ipv6_token (NM_PLATFORM_GET, nm_platform_link_set_ipv6_token (nm_device_get_platform (self),
nm_device_get_ip_ifindex (self), nm_device_get_ip_ifindex (self),
iid); iid);
} }
@@ -6560,7 +6575,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
return FALSE; return FALSE;
} }
hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), &hw_addr_len); hw_addr = nm_platform_link_get_address (nm_device_get_platform (self), nm_device_get_ip_ifindex (self), &hw_addr_len);
if (hw_addr_len) { if (hw_addr_len) {
tmp = g_byte_array_sized_new (hw_addr_len); tmp = g_byte_array_sized_new (hw_addr_len);
g_byte_array_append (tmp, hw_addr, hw_addr_len); g_byte_array_append (tmp, hw_addr, hw_addr_len);
@@ -6880,7 +6895,7 @@ check_and_add_ipv6ll_addr (NMDevice *self)
} }
_LOGD (LOGD_IP6, "linklocal6: adding IPv6LL address %s", nm_utils_inet6_ntop (&lladdr, NULL)); _LOGD (LOGD_IP6, "linklocal6: adding IPv6LL address %s", nm_utils_inet6_ntop (&lladdr, NULL));
if (!nm_platform_ip6_address_add (NM_PLATFORM_GET, if (!nm_platform_ip6_address_add (nm_device_get_platform (self),
ip_ifindex, ip_ifindex,
lladdr, lladdr,
64, 64,
@@ -7060,7 +7075,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
mtu_desired_orig = mtu_desired; mtu_desired_orig = mtu_desired;
ip6_mtu_orig = ip6_mtu; ip6_mtu_orig = ip6_mtu;
mtu_plat = nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex); mtu_plat = nm_platform_link_get_mtu (nm_device_get_platform (self), ifindex);
if (ip6_mtu) { if (ip6_mtu) {
ip6_mtu = NM_MAX (1280, ip6_mtu); ip6_mtu = NM_MAX (1280, ip6_mtu);
@@ -7102,7 +7117,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
} }
if (mtu_desired && mtu_desired != mtu_plat) if (mtu_desired && mtu_desired != mtu_plat)
nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, mtu_desired); nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, mtu_desired);
if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) { if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) {
nm_device_ipv6_sysctl_set (self, "mtu", nm_device_ipv6_sysctl_set (self, "mtu",
@@ -7127,7 +7142,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
* addresses as /128. The reason for the /128 is to prevent the kernel * addresses as /128. The reason for the /128 is to prevent the kernel
* from adding a prefix route for this address. * from adding a prefix route for this address.
**/ **/
system_support = nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET); system_support = nm_platform_check_support_kernel_extended_ifa_flags (nm_device_get_platform (self));
if (system_support) if (system_support)
ifa_flags = IFA_F_NOPREFIXROUTE; ifa_flags = IFA_F_NOPREFIXROUTE;
@@ -7232,7 +7247,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
} }
if (changed & NM_NDISC_CONFIG_HOP_LIMIT) if (changed & NM_NDISC_CONFIG_HOP_LIMIT)
nm_platform_sysctl_set_ip6_hop_limit_safe (NM_PLATFORM_GET, nm_device_get_ip_iface (self), rdata->hop_limit); nm_platform_sysctl_set_ip6_hop_limit_safe (nm_device_get_platform (self), nm_device_get_ip_iface (self), rdata->hop_limit);
if (changed & NM_NDISC_CONFIG_MTU) { if (changed & NM_NDISC_CONFIG_MTU) {
if (priv->ip6_mtu != rdata->mtu) { if (priv->ip6_mtu != rdata->mtu) {
@@ -7364,7 +7379,7 @@ addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
stable_id = _get_stable_id (self, connection, &stable_type); stable_id = _get_stable_id (self, connection, &stable_type);
if (stable_id) { if (stable_id) {
priv->ndisc = nm_lndp_ndisc_new (NM_PLATFORM_GET, priv->ndisc = nm_lndp_ndisc_new (nm_device_get_platform (self),
nm_device_get_ip_ifindex (self), nm_device_get_ip_ifindex (self),
nm_device_get_ip_iface (self), nm_device_get_ip_iface (self),
stable_type, stable_type,
@@ -7382,7 +7397,7 @@ addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
priv->ndisc_use_tempaddr = use_tempaddr; priv->ndisc_use_tempaddr = use_tempaddr;
if ( NM_IN_SET (use_tempaddr, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR) if ( NM_IN_SET (use_tempaddr, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)
&& !nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET)) { && !nm_platform_check_support_kernel_extended_ifa_flags (nm_device_get_platform (self))) {
_LOGW (LOGD_IP6, "The kernel does not support extended IFA_FLAGS needed by NM for " _LOGW (LOGD_IP6, "The kernel does not support extended IFA_FLAGS needed by NM for "
"IPv6 private addresses. This feature is not available"); "IPv6 private addresses. This feature is not available");
} }
@@ -7440,7 +7455,7 @@ save_ip6_properties (NMDevice *self)
g_hash_table_remove_all (priv->ip6_saved_properties); g_hash_table_remove_all (priv->ip6_saved_properties);
for (i = 0; i < G_N_ELEMENTS (ip6_properties_to_save); i++) { for (i = 0; i < G_N_ELEMENTS (ip6_properties_to_save); i++) {
value = nm_platform_sysctl_get (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i]))); value = nm_platform_sysctl_get (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i])));
if (value) { if (value) {
g_hash_table_insert (priv->ip6_saved_properties, g_hash_table_insert (priv->ip6_saved_properties,
(char *) ip6_properties_to_save[i], (char *) ip6_properties_to_save[i],
@@ -7480,7 +7495,7 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable)
int ifindex = nm_device_get_ip_ifindex (self); int ifindex = nm_device_get_ip_ifindex (self);
char *value; char *value;
if (!nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) if (!nm_platform_check_support_user_ipv6ll (nm_device_get_platform (self)))
return; return;
priv->nm_ipv6ll = enable; priv->nm_ipv6ll = enable;
@@ -7489,7 +7504,7 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable)
const char *detail = enable ? "enable" : "disable"; const char *detail = enable ? "enable" : "disable";
_LOGD (LOGD_IP6, "will %s userland IPv6LL", detail); _LOGD (LOGD_IP6, "will %s userland IPv6LL", detail);
plerr = nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, enable); plerr = nm_platform_link_set_user_ipv6ll_enabled (nm_device_get_platform (self), ifindex, enable);
if (plerr != NM_PLATFORM_ERROR_SUCCESS) { if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
_NMLOG (plerr == NM_PLATFORM_ERROR_NOT_FOUND ? LOGL_DEBUG : LOGL_WARN, _NMLOG (plerr == NM_PLATFORM_ERROR_NOT_FOUND ? LOGL_DEBUG : LOGL_WARN,
LOGD_IP6, LOGD_IP6,
@@ -7500,7 +7515,7 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable)
if (enable) { if (enable) {
/* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */ /* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */
value = nm_platform_sysctl_get (NM_PLATFORM_GET, value = nm_platform_sysctl_get (nm_device_get_platform (self),
NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), "disable_ipv6"))); NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), "disable_ipv6")));
if (g_strcmp0 (value, "0") == 0) if (g_strcmp0 (value, "0") == 0)
nm_device_ipv6_sysctl_set (self, "disable_ipv6", "1"); nm_device_ipv6_sysctl_set (self, "disable_ipv6", "1");
@@ -7567,7 +7582,7 @@ _ip6_privacy_get (NMDevice *self)
* Instead of reading static config files in /etc, just read the current sysctl value. * Instead of reading static config files in /etc, just read the current sysctl value.
* This works as NM only writes to "/proc/sys/net/ipv6/conf/IFNAME/use_tempaddr", but leaves * This works as NM only writes to "/proc/sys/net/ipv6/conf/IFNAME/use_tempaddr", but leaves
* the "default" entry untouched. */ * the "default" entry untouched. */
ip6_privacy = nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/default/use_tempaddr"), NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); ip6_privacy = nm_platform_sysctl_get_int32 (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/default/use_tempaddr"), NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
return _ip6_privacy_clamp (ip6_privacy); return _ip6_privacy_clamp (ip6_privacy);
} }
@@ -7812,7 +7827,7 @@ activate_stage3_ip_config_start (NMDevice *self)
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
/* Device should be up before we can do anything with it */ /* Device should be up before we can do anything with it */
if (!nm_platform_link_is_up (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self))) if (!nm_platform_link_is_up (nm_device_get_platform (self), nm_device_get_ip_ifindex (self)))
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self)); _LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
/* If the device is a slave, then we don't do any IP configuration but we /* If the device is a slave, then we don't do any IP configuration but we
@@ -8064,7 +8079,7 @@ nm_device_activate_schedule_ip6_config_timeout (NMDevice *self)
} }
static gboolean static gboolean
share_init (void) share_init (NMDevice *self)
{ {
char *modules[] = { "ip_tables", "iptable_nat", "nf_nat_ftp", "nf_nat_irc", char *modules[] = { "ip_tables", "iptable_nat", "nf_nat_ftp", "nf_nat_irc",
"nf_nat_sip", "nf_nat_tftp", "nf_nat_pptp", "nf_nat_h323", "nf_nat_sip", "nf_nat_tftp", "nf_nat_pptp", "nf_nat_h323",
@@ -8072,14 +8087,14 @@ share_init (void)
char **iter; char **iter;
int errsv; int errsv;
if (!nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_forward"), "1")) { if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_forward"), "1")) {
errsv = errno; errsv = errno;
nm_log_err (LOGD_SHARING, "share: error enabling IPv4 forwarding: (%d) %s", nm_log_err (LOGD_SHARING, "share: error enabling IPv4 forwarding: (%d) %s",
errsv, strerror (errsv)); errsv, strerror (errsv));
return FALSE; return FALSE;
} }
if (!nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_dynaddr"), "1")) { if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_dynaddr"), "1")) {
errsv = errno; errsv = errno;
nm_log_err (LOGD_SHARING, "share: error enabling dynamic addresses: (%d) %s", nm_log_err (LOGD_SHARING, "share: error enabling dynamic addresses: (%d) %s",
errsv, strerror (errsv)); errsv, strerror (errsv));
@@ -8126,7 +8141,7 @@ start_sharing (NMDevice *self, NMIP4Config *config)
if (!inet_ntop (AF_INET, &network, str_addr, sizeof (str_addr))) if (!inet_ntop (AF_INET, &network, str_addr, sizeof (str_addr)))
return FALSE; return FALSE;
if (!share_init ()) if (!share_init (self))
return FALSE; return FALSE;
req = nm_device_get_act_request (self); req = nm_device_get_act_request (self);
@@ -8182,7 +8197,7 @@ arp_announce (NMDevice *self)
arp_cleanup (self); arp_cleanup (self);
hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, hw_addr = nm_platform_link_get_address (nm_device_get_platform (self),
nm_device_get_ip_ifindex (self), nm_device_get_ip_ifindex (self),
&hw_addr_len); &hw_addr_len);
@@ -8233,9 +8248,9 @@ activate_stage5_ip4_config_commit (NMDevice *self)
/* Interface must be IFF_UP before IP config can be applied */ /* Interface must be IFF_UP before IP config can be applied */
ip_ifindex = nm_device_get_ip_ifindex (self); ip_ifindex = nm_device_get_ip_ifindex (self);
if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex) && !nm_device_sys_iface_state_is_external_or_assume (self)) { if (!nm_platform_link_is_up (nm_device_get_platform (self), ip_ifindex) && !nm_device_sys_iface_state_is_external_or_assume (self)) {
nm_platform_link_set_up (NM_PLATFORM_GET, ip_ifindex, NULL); nm_platform_link_set_up (nm_device_get_platform (self), ip_ifindex, NULL);
if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex)) if (!nm_platform_link_is_up (nm_device_get_platform (self), ip_ifindex))
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self)); _LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
} }
@@ -8342,7 +8357,7 @@ dad6_get_pending_addresses (NMDevice *self)
num = nm_ip6_config_get_num_addresses (confs[i]); num = nm_ip6_config_get_num_addresses (confs[i]);
for (j = 0; j < num; j++) { for (j = 0; j < num; j++) {
addr = nm_ip6_config_get_address (confs[i], j); addr = nm_ip6_config_get_address (confs[i], j);
pl_addr = nm_platform_ip6_address_get (NM_PLATFORM_GET, pl_addr = nm_platform_ip6_address_get (nm_device_get_platform (self),
ifindex, ifindex,
addr->address, addr->address,
addr->plen); addr->plen);
@@ -8382,9 +8397,9 @@ activate_stage5_ip6_config_commit (NMDevice *self)
/* Interface must be IFF_UP before IP config can be applied */ /* Interface must be IFF_UP before IP config can be applied */
ip_ifindex = nm_device_get_ip_ifindex (self); ip_ifindex = nm_device_get_ip_ifindex (self);
if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex) && !nm_device_sys_iface_state_is_external_or_assume (self)) { if (!nm_platform_link_is_up (nm_device_get_platform (self), ip_ifindex) && !nm_device_sys_iface_state_is_external_or_assume (self)) {
nm_platform_link_set_up (NM_PLATFORM_GET, ip_ifindex, NULL); nm_platform_link_set_up (nm_device_get_platform (self), ip_ifindex, NULL);
if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex)) if (!nm_platform_link_is_up (nm_device_get_platform (self), ip_ifindex))
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self)); _LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
} }
@@ -8411,7 +8426,7 @@ activate_stage5_ip6_config_commit (NMDevice *self)
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG); method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) { if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) {
if (!nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/all/forwarding"), "1")) { if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/all/forwarding"), "1")) {
errsv = errno; errsv = errno;
_LOGE (LOGD_SHARING, "share: error enabling IPv6 forwarding: (%d) %s", errsv, strerror (errsv)); _LOGE (LOGD_SHARING, "share: error enabling IPv6 forwarding: (%d) %s", errsv, strerror (errsv));
nm_device_ip_method_failed (self, AF_INET6, NM_DEVICE_STATE_REASON_SHARED_START_FAILED); nm_device_ip_method_failed (self, AF_INET6, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
@@ -8598,7 +8613,7 @@ delete_on_deactivate_link_delete (gpointer user_data)
if (!nm_device_unrealize (data->device, TRUE, &error)) if (!nm_device_unrealize (data->device, TRUE, &error))
_LOGD (LOGD_DEVICE, "delete_on_deactivate: unrealizing %d failed (%s)", data->ifindex, error->message); _LOGD (LOGD_DEVICE, "delete_on_deactivate: unrealizing %d failed (%s)", data->ifindex, error->message);
} else } else
nm_platform_link_delete (NM_PLATFORM_GET, data->ifindex); nm_platform_link_delete (nm_device_get_platform (self), data->ifindex);
g_free (data); g_free (data);
return FALSE; return FALSE;
@@ -9640,7 +9655,10 @@ nm_device_set_ip4_config (NMDevice *self,
/* For assumed devices we must not touch the kernel-routes, such as the device-route. /* For assumed devices we must not touch the kernel-routes, such as the device-route.
* FIXME: this is wrong in case where "assumed" means "take-over-seamlessly". In this * FIXME: this is wrong in case where "assumed" means "take-over-seamlessly". In this
* case, we should manage the device route, for example on new DHCP lease. */ * case, we should manage the device route, for example on new DHCP lease. */
success = nm_ip4_config_commit (new_config, ip_ifindex, success = nm_ip4_config_commit (new_config,
nm_device_get_platform (self),
nm_netns_get_route_manager (priv->netns),
ip_ifindex,
routes_full_sync, routes_full_sync,
assumed ? (gint64) -1 : (gint64) default_route_metric); assumed ? (gint64) -1 : (gint64) default_route_metric);
} }
@@ -9673,7 +9691,7 @@ nm_device_set_ip4_config (NMDevice *self,
g_clear_object (&priv->dev_ip4_config); g_clear_object (&priv->dev_ip4_config);
} }
def_route_changed = nm_default_route_manager_ip4_update_default_route (nm_default_route_manager_get (), self); def_route_changed = nm_default_route_manager_ip4_update_default_route (nm_netns_get_default_route_manager (priv->netns), self);
concheck_periodic_update (self); concheck_periodic_update (self);
if (!nm_device_sys_iface_state_is_external_or_assume (self)) if (!nm_device_sys_iface_state_is_external_or_assume (self))
@@ -9811,6 +9829,8 @@ nm_device_set_ip6_config (NMDevice *self,
if (commit && new_config) { if (commit && new_config) {
_commit_mtu (self, priv->ip4_config); _commit_mtu (self, priv->ip4_config);
success = nm_ip6_config_commit (new_config, success = nm_ip6_config_commit (new_config,
nm_device_get_platform (self),
nm_netns_get_route_manager (priv->netns),
ip_ifindex, ip_ifindex,
routes_full_sync); routes_full_sync);
} }
@@ -9841,7 +9861,7 @@ nm_device_set_ip6_config (NMDevice *self,
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config)));
} }
def_route_changed = nm_default_route_manager_ip6_update_default_route (nm_default_route_manager_get (), self); def_route_changed = nm_default_route_manager_ip6_update_default_route (nm_netns_get_default_route_manager (priv->netns), self);
if (has_changes) { if (has_changes) {
NMSettingsConnection *settings_connection; NMSettingsConnection *settings_connection;
@@ -10206,7 +10226,7 @@ nm_device_is_up (NMDevice *self)
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
ifindex = nm_device_get_ip_ifindex (self); ifindex = nm_device_get_ip_ifindex (self);
return ifindex > 0 ? nm_platform_link_is_up (NM_PLATFORM_GET, ifindex) : TRUE; return ifindex > 0 ? nm_platform_link_is_up (nm_device_get_platform (self), ifindex) : TRUE;
} }
gboolean gboolean
@@ -10231,7 +10251,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
if (ifindex <= 0) { if (ifindex <= 0) {
/* assume success. */ /* assume success. */
} else { } else {
if (!nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, no_firmware)) if (!nm_platform_link_set_up (nm_device_get_platform (self), ifindex, no_firmware))
return FALSE; return FALSE;
} }
@@ -10245,7 +10265,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
do { do {
g_usleep (200); g_usleep (200);
if (!nm_platform_link_refresh (NM_PLATFORM_GET, ifindex)) if (!nm_platform_link_refresh (nm_device_get_platform (self), ifindex))
return FALSE; return FALSE;
device_is_up = nm_device_is_up (self); device_is_up = nm_device_is_up (self);
} while (!device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until); } while (!device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until);
@@ -10310,7 +10330,7 @@ nm_device_take_down (NMDevice *self, gboolean block)
return; return;
} }
if (!nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)) if (!nm_platform_link_set_down (nm_device_get_platform (self), ifindex))
return; return;
device_is_up = nm_device_is_up (self); device_is_up = nm_device_is_up (self);
@@ -10319,7 +10339,7 @@ nm_device_take_down (NMDevice *self, gboolean block)
do { do {
g_usleep (200); g_usleep (200);
if (!nm_platform_link_refresh (NM_PLATFORM_GET, ifindex)) if (!nm_platform_link_refresh (nm_device_get_platform (self), ifindex))
return; return;
device_is_up = nm_device_is_up (self); device_is_up = nm_device_is_up (self);
} while (device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until); } while (device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until);
@@ -10502,7 +10522,9 @@ update_ip4_config (NMDevice *self, gboolean initial)
/* IPv4 */ /* IPv4 */
g_clear_object (&priv->ext_ip4_config); g_clear_object (&priv->ext_ip4_config);
priv->ext_ip4_config = nm_ip4_config_capture (ifindex, capture_resolv_conf); priv->ext_ip4_config = nm_ip4_config_capture (nm_device_get_platform (self),
ifindex,
capture_resolv_conf);
if (priv->ext_ip4_config) { if (priv->ext_ip4_config) {
if (initial) { if (initial) {
g_clear_object (&priv->dev_ip4_config); g_clear_object (&priv->dev_ip4_config);
@@ -10594,7 +10616,7 @@ update_ip6_config (NMDevice *self, gboolean initial)
/* IPv6 */ /* IPv6 */
g_clear_object (&priv->ext_ip6_config); g_clear_object (&priv->ext_ip6_config);
g_clear_object (&priv->ext_ip6_config_captured); g_clear_object (&priv->ext_ip6_config_captured);
priv->ext_ip6_config_captured = nm_ip6_config_capture (ifindex, capture_resolv_conf, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_platform (self), ifindex, capture_resolv_conf, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
if (priv->ext_ip6_config_captured) { if (priv->ext_ip6_config_captured) {
priv->ext_ip6_config = nm_ip6_config_new_cloned (priv->ext_ip6_config_captured); priv->ext_ip6_config = nm_ip6_config_new_cloned (priv->ext_ip6_config_captured);
@@ -10692,7 +10714,7 @@ queued_ip6_config_change (gpointer user_data)
update_ip6_config (self, FALSE); update_ip6_config (self, FALSE);
if (priv->state < NM_DEVICE_STATE_DEACTIVATING if (priv->state < NM_DEVICE_STATE_DEACTIVATING
&& nm_platform_link_get (NM_PLATFORM_GET, priv->ifindex)) { && nm_platform_link_get (nm_device_get_platform (self), priv->ifindex)) {
/* Handle DAD failures */ /* Handle DAD failures */
for (iter = priv->dad6_failed_addrs; iter; iter = g_slist_next (iter)) { for (iter = priv->dad6_failed_addrs; iter; iter = g_slist_next (iter)) {
NMPlatformIP6Address *addr = iter->data; NMPlatformIP6Address *addr = iter->data;
@@ -11216,7 +11238,7 @@ nm_device_set_unmanaged_by_user_udev (NMDevice *self)
ifindex = self->_priv->ifindex; ifindex = self->_priv->ifindex;
if ( ifindex <= 0 if ( ifindex <= 0
|| !nm_platform_link_get_unmanaged (NM_PLATFORM_GET, ifindex, &platform_unmanaged)) || !nm_platform_link_get_unmanaged (nm_device_get_platform (self), ifindex, &platform_unmanaged))
return; return;
nm_device_set_unmanaged_by_flags (self, nm_device_set_unmanaged_by_flags (self,
@@ -11688,7 +11710,7 @@ cp_connection_removed (NMConnectionProvider *cp, NMConnection *connection, gpoin
gboolean gboolean
nm_device_supports_vlans (NMDevice *self) nm_device_supports_vlans (NMDevice *self)
{ {
return nm_platform_link_supports_vlans (NM_PLATFORM_GET, nm_device_get_ifindex (self)); return nm_platform_link_supports_vlans (nm_device_get_platform (self), nm_device_get_ifindex (self));
} }
/** /**
@@ -11968,14 +11990,14 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean
/* slave: mark no longer enslaved */ /* slave: mark no longer enslaved */
if ( priv->master if ( priv->master
&& nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) <= 0) && nm_platform_link_get_master (nm_device_get_platform (self), priv->ifindex) <= 0)
nm_device_master_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); nm_device_master_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
/* Take out any entries in the routing table and any IP address the device had. */ /* Take out any entries in the routing table and any IP address the device had. */
ifindex = nm_device_get_ip_ifindex (self); ifindex = nm_device_get_ip_ifindex (self);
if (ifindex > 0) { if (ifindex > 0) {
nm_route_manager_route_flush (nm_route_manager_get (), ifindex); nm_route_manager_route_flush (nm_netns_get_route_manager (priv->netns), ifindex);
nm_platform_address_flush (NM_PLATFORM_GET, ifindex); nm_platform_address_flush (nm_device_get_platform (self), ifindex);
} }
} }
@@ -12006,7 +12028,7 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean
_LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d", _LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d",
(guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex); (guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex);
if (priv->mtu_initial) if (priv->mtu_initial)
nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, priv->mtu_initial); nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, priv->mtu_initial);
if (priv->ip6_mtu_initial) { if (priv->ip6_mtu_initial) {
char sbuf[64]; char sbuf[64];
@@ -12805,7 +12827,7 @@ nm_device_update_hw_address (NMDevice *self)
if (priv->ifindex <= 0) if (priv->ifindex <= 0)
return FALSE; return FALSE;
hwaddr = nm_platform_link_get_address (NM_PLATFORM_GET, priv->ifindex, &hwaddrlen); hwaddr = nm_platform_link_get_address (nm_device_get_platform (self), priv->ifindex, &hwaddrlen);
if ( priv->type == NM_DEVICE_TYPE_ETHERNET if ( priv->type == NM_DEVICE_TYPE_ETHERNET
&& hwaddr && hwaddr
@@ -12899,7 +12921,7 @@ nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze)
/* the user is advised to configure stable MAC addresses for software devices via /* the user is advised to configure stable MAC addresses for software devices via
* UDEV. Thus, check whether the link is fully initialized. */ * UDEV. Thus, check whether the link is fully initialized. */
pllink = nm_platform_link_get (NM_PLATFORM_GET, ifindex); pllink = nm_platform_link_get (nm_device_get_platform (self), ifindex);
if ( !pllink if ( !pllink
|| !pllink->initialized) { || !pllink->initialized) {
if (!force_freeze) { if (!force_freeze) {
@@ -12908,7 +12930,7 @@ nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze)
return; return;
} }
/* try to refresh the link just to give UDEV a bit more time... */ /* try to refresh the link just to give UDEV a bit more time... */
nm_platform_link_refresh (NM_PLATFORM_GET, ifindex); nm_platform_link_refresh (nm_device_get_platform (self), ifindex);
/* maybe the MAC address changed... */ /* maybe the MAC address changed... */
nm_device_update_hw_address (self); nm_device_update_hw_address (self);
} else if (!priv->hw_addr_len) } else if (!priv->hw_addr_len)
@@ -12922,7 +12944,7 @@ nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze)
return; return;
} }
success_read = nm_platform_link_get_permanent_address (NM_PLATFORM_GET, ifindex, buf, &len); success_read = nm_platform_link_get_permanent_address (nm_device_get_platform (self), ifindex, buf, &len);
if (success_read && priv->hw_addr_len == len) { if (success_read && priv->hw_addr_len == len) {
priv->hw_addr_perm_fake = FALSE; priv->hw_addr_perm_fake = FALSE;
priv->hw_addr_perm = nm_utils_hwaddr_ntoa (buf, len); priv->hw_addr_perm = nm_utils_hwaddr_ntoa (buf, len);
@@ -13110,7 +13132,7 @@ _hw_addr_set (NMDevice *self,
nm_device_take_down (self, FALSE); nm_device_take_down (self, FALSE);
} }
plerr = nm_platform_link_set_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), addr_bytes, addr_len); plerr = nm_platform_link_set_address (nm_device_get_platform (self), nm_device_get_ip_ifindex (self), addr_bytes, addr_len);
success = (plerr == NM_PLATFORM_ERROR_SUCCESS); success = (plerr == NM_PLATFORM_ERROR_SUCCESS);
if (success) { if (success) {
/* MAC address succesfully changed; update the current MAC to match */ /* MAC address succesfully changed; update the current MAC to match */
@@ -13141,7 +13163,7 @@ _hw_addr_set (NMDevice *self,
poll_end = nm_utils_get_monotonic_timestamp_us () + (100 * 1000); poll_end = nm_utils_get_monotonic_timestamp_us () + (100 * 1000);
for (;;) { for (;;) {
if (!nm_platform_link_refresh (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self))) if (!nm_platform_link_refresh (nm_device_get_platform (self), nm_device_get_ip_ifindex (self)))
goto handle_fail; goto handle_fail;
if (!nm_device_update_hw_address (self)) if (!nm_device_update_hw_address (self))
goto handle_wait; goto handle_wait;
@@ -13542,6 +13564,8 @@ nm_device_init (NMDevice *self)
self->_priv = priv; self->_priv = priv;
priv->netns = g_object_ref (NM_NETNS_GET);
priv->type = NM_DEVICE_TYPE_UNKNOWN; priv->type = NM_DEVICE_TYPE_UNKNOWN;
priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED; priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED;
priv->state = NM_DEVICE_STATE_UNMANAGED; priv->state = NM_DEVICE_STATE_UNMANAGED;
@@ -13584,7 +13608,7 @@ constructor (GType type,
if ( priv->iface if ( priv->iface
&& G_LIKELY (!nm_utils_get_testing ())) { && G_LIKELY (!nm_utils_get_testing ())) {
pllink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, priv->iface); pllink = nm_platform_link_get_by_ifname (nm_device_get_platform (self), priv->iface);
if (pllink && link_type_compatible (self, pllink->type, NULL, NULL)) { if (pllink && link_type_compatible (self, pllink->type, NULL, NULL)) {
priv->ifindex = pllink->ifindex; priv->ifindex = pllink->ifindex;
@@ -13620,14 +13644,14 @@ constructed (GObject *object)
priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self); priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self);
/* Watch for external IP config changes */ /* Watch for external IP config changes */
platform = NM_PLATFORM_GET; platform = nm_device_get_platform (self);
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, G_CALLBACK (device_ipx_changed), self); g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, G_CALLBACK (device_ipx_changed), self);
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, G_CALLBACK (device_ipx_changed), self); g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, G_CALLBACK (device_ipx_changed), self);
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, G_CALLBACK (device_ipx_changed), self); g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, G_CALLBACK (device_ipx_changed), self);
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, G_CALLBACK (device_ipx_changed), self); g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, G_CALLBACK (device_ipx_changed), self);
g_signal_connect (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, G_CALLBACK (link_changed_cb), self); g_signal_connect (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, G_CALLBACK (link_changed_cb), self);
g_signal_connect (nm_route_manager_get (), NM_ROUTE_MANAGER_IP4_ROUTES_CHANGED, g_signal_connect (nm_netns_get_route_manager (priv->netns), NM_ROUTE_MANAGER_IP4_ROUTES_CHANGED,
G_CALLBACK (ip4_routes_changed_changed_cb), self); G_CALLBACK (ip4_routes_changed_changed_cb), self);
priv->settings = g_object_ref (NM_SETTINGS_GET); priv->settings = g_object_ref (NM_SETTINGS_GET);
@@ -13664,11 +13688,11 @@ dispose (GObject *object)
_parent_set_ifindex (self, 0, FALSE); _parent_set_ifindex (self, 0, FALSE);
platform = NM_PLATFORM_GET; platform = nm_device_get_platform (self);
g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (device_ipx_changed), self); g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (device_ipx_changed), self);
g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (link_changed_cb), self); g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (link_changed_cb), self);
g_signal_handlers_disconnect_by_func (nm_route_manager_get (), g_signal_handlers_disconnect_by_func (nm_netns_get_route_manager (priv->netns),
G_CALLBACK (ip4_routes_changed_changed_cb), self); G_CALLBACK (ip4_routes_changed_changed_cb), self);
g_slist_free_full (priv->arping.dad_list, (GDestroyNotify) nm_arping_manager_destroy); g_slist_free_full (priv->arping.dad_list, (GDestroyNotify) nm_arping_manager_destroy);
@@ -13775,6 +13799,8 @@ finalize (GObject *object)
* and thus @settings might be unset. */ * and thus @settings might be unset. */
if (priv->settings) if (priv->settings)
g_object_unref (priv->settings); g_object_unref (priv->settings);
g_object_unref (priv->netns);
} }
static void static void

View File

@@ -410,6 +410,9 @@ typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
GType nm_device_get_type (void); GType nm_device_get_type (void);
NMNetns *nm_device_get_netns (NMDevice *self);
NMPlatform *nm_device_get_platform (NMDevice *self);
const char * nm_device_get_udi (NMDevice *dev); const char * nm_device_get_udi (NMDevice *dev);
const char * nm_device_get_iface (NMDevice *dev); const char * nm_device_get_iface (NMDevice *dev);
int nm_device_get_ifindex (NMDevice *dev); int nm_device_get_ifindex (NMDevice *dev);

View File

@@ -33,6 +33,7 @@
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "devices/nm-device-private.h" #include "devices/nm-device-private.h"
#include "nm-route-manager.h" #include "nm-route-manager.h"
#include "nm-netns.h"
#include "nm-act-request.h" #include "nm-act-request.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "nm-ip6-config.h" #include "nm-ip6-config.h"
@@ -1068,7 +1069,8 @@ deactivate_cleanup (NMModem *self, NMDevice *device)
priv->ip6_method == NM_MODEM_IP_METHOD_AUTO) { priv->ip6_method == NM_MODEM_IP_METHOD_AUTO) {
ifindex = nm_device_get_ip_ifindex (device); ifindex = nm_device_get_ip_ifindex (device);
if (ifindex > 0) { if (ifindex > 0) {
nm_route_manager_route_flush (nm_route_manager_get (), ifindex); nm_route_manager_route_flush (nm_netns_get_route_manager (nm_device_get_netns (device)),
ifindex);
nm_platform_address_flush (NM_PLATFORM_GET, ifindex); nm_platform_address_flush (NM_PLATFORM_GET, ifindex);
nm_platform_link_set_down (NM_PLATFORM_GET, ifindex); nm_platform_link_set_down (NM_PLATFORM_GET, ifindex);
} }

View File

@@ -37,7 +37,6 @@ typedef struct _NMDefaultRouteManagerClass NMDefaultRouteManagerClass;
GType nm_default_route_manager_get_type (void); GType nm_default_route_manager_get_type (void);
NMDefaultRouteManager *nm_default_route_manager_get (void);
NMDefaultRouteManager *nm_default_route_manager_new (gboolean log_with_ptr, NMPlatform *platform); NMDefaultRouteManager *nm_default_route_manager_new (gboolean log_with_ptr, NMPlatform *platform);
gboolean nm_default_route_manager_ip4_update_default_route (NMDefaultRouteManager *manager, gpointer source); gboolean nm_default_route_manager_ip4_update_default_route (NMDefaultRouteManager *manager, gpointer source);

View File

@@ -98,7 +98,9 @@ static struct {
/*****************************************************************************/ /*****************************************************************************/
NM_DEFINE_SINGLETON_GETTER (NMRouteManager, nm_route_manager_get, NM_TYPE_ROUTE_MANAGER); NMRouteManager *route_manager_get (void);
NM_DEFINE_SINGLETON_GETTER (NMRouteManager, route_manager_get, NM_TYPE_ROUTE_MANAGER);
/*****************************************************************************/ /*****************************************************************************/
@@ -120,12 +122,12 @@ dhcp4_state_changed (NMDhcpClient *client,
switch (state) { switch (state) {
case NM_DHCP_STATE_BOUND: case NM_DHCP_STATE_BOUND:
g_assert (ip4_config); g_assert (ip4_config);
existing = nm_ip4_config_capture (gl.ifindex, FALSE); existing = nm_ip4_config_capture (NM_PLATFORM_GET, gl.ifindex, FALSE);
if (last_config) if (last_config)
nm_ip4_config_subtract (existing, last_config); nm_ip4_config_subtract (existing, last_config);
nm_ip4_config_merge (existing, ip4_config, NM_IP_CONFIG_MERGE_DEFAULT); nm_ip4_config_merge (existing, ip4_config, NM_IP_CONFIG_MERGE_DEFAULT);
if (!nm_ip4_config_commit (existing, gl.ifindex, TRUE, global_opt.priority_v4)) if (!nm_ip4_config_commit (existing, NM_PLATFORM_GET, route_manager_get (), gl.ifindex, TRUE, global_opt.priority_v4))
_LOGW (LOGD_DHCP4, "failed to apply DHCPv4 config"); _LOGW (LOGD_DHCP4, "failed to apply DHCPv4 config");
if (last_config) if (last_config)
@@ -175,7 +177,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
ifa_flags |= IFA_F_MANAGETEMPADDR; ifa_flags |= IFA_F_MANAGETEMPADDR;
} }
existing = nm_ip6_config_capture (gl.ifindex, FALSE, global_opt.tempaddr); existing = nm_ip6_config_capture (NM_PLATFORM_GET, gl.ifindex, FALSE, global_opt.tempaddr);
if (ndisc_config) if (ndisc_config)
nm_ip6_config_subtract (existing, ndisc_config); nm_ip6_config_subtract (existing, ndisc_config);
else else
@@ -250,7 +252,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
} }
nm_ip6_config_merge (existing, ndisc_config, NM_IP_CONFIG_MERGE_DEFAULT); nm_ip6_config_merge (existing, ndisc_config, NM_IP_CONFIG_MERGE_DEFAULT);
if (!nm_ip6_config_commit (existing, gl.ifindex, TRUE)) if (!nm_ip6_config_commit (existing, NM_PLATFORM_GET, route_manager_get (), gl.ifindex, TRUE))
_LOGW (LOGD_IP6, "failed to apply IPv6 config"); _LOGW (LOGD_IP6, "failed to apply IPv6 config");
} }

View File

@@ -249,7 +249,7 @@ notify_addresses (NMIP4Config *self)
} }
NMIP4Config * NMIP4Config *
nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) nm_ip4_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resolv_conf)
{ {
NMIP4Config *config; NMIP4Config *config;
NMIP4ConfigPrivate *priv; NMIP4ConfigPrivate *priv;
@@ -259,7 +259,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
gboolean old_has_gateway = FALSE; gboolean old_has_gateway = FALSE;
/* Slaves have no IP configuration */ /* Slaves have no IP configuration */
if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0) if (nm_platform_link_get_master (platform, ifindex) > 0)
return NULL; return NULL;
config = nm_ip4_config_new (ifindex); config = nm_ip4_config_new (ifindex);
@@ -268,8 +268,8 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
g_array_unref (priv->addresses); g_array_unref (priv->addresses);
g_array_unref (priv->routes); g_array_unref (priv->routes);
priv->addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex); priv->addresses = nm_platform_ip4_address_get_all (platform, ifindex);
priv->routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT); priv->routes = nm_platform_ip4_route_get_all (platform, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
/* Extract gateway from default route */ /* Extract gateway from default route */
old_gateway = priv->gateway; old_gateway = priv->gateway;
@@ -331,7 +331,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
} }
gboolean gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_full_sync, gint64 default_route_metric) nm_ip4_config_commit (const NMIP4Config *config, NMPlatform *platform, NMRouteManager *route_manager, int ifindex, gboolean routes_full_sync, gint64 default_route_metric)
{ {
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
gs_unref_ptrarray GPtrArray *added_addresses = NULL; gs_unref_ptrarray GPtrArray *added_addresses = NULL;
@@ -340,7 +340,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_fu
g_return_val_if_fail (config != NULL, FALSE); g_return_val_if_fail (config != NULL, FALSE);
/* Addresses */ /* Addresses */
nm_platform_ip4_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, nm_platform_ip4_address_sync (platform, ifindex, priv->addresses,
default_route_metric >= 0 ? &added_addresses : NULL); default_route_metric >= 0 ? &added_addresses : NULL);
/* Routes */ /* Routes */
@@ -401,9 +401,9 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_fu
g_array_append_vals (routes, route, 1); g_array_append_vals (routes, route, 1);
} }
nm_route_manager_ip4_route_register_device_route_purge_list (nm_route_manager_get (), device_route_purge_list); nm_route_manager_ip4_route_register_device_route_purge_list (route_manager, device_route_purge_list);
success = nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes, default_route_metric < 0, routes_full_sync); success = nm_route_manager_ip4_route_sync (route_manager, ifindex, routes, default_route_metric < 0, routes_full_sync);
g_array_unref (routes); g_array_unref (routes);
if (!success) if (!success)
return FALSE; return FALSE;

View File

@@ -59,8 +59,8 @@ NMIP4Config * nm_ip4_config_new (int ifindex);
int nm_ip4_config_get_ifindex (const NMIP4Config *config); int nm_ip4_config_get_ifindex (const NMIP4Config *config);
NMIP4Config *nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf); NMIP4Config *nm_ip4_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resolv_conf);
gboolean nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_full_sync, gint64 default_route_metric); gboolean nm_ip4_config_commit (const NMIP4Config *config, NMPlatform *platform, NMRouteManager *route_manager, int ifindex, gboolean routes_full_sync, gint64 default_route_metric);
void nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, guint32 default_route_metric); void nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, guint32 default_route_metric);
NMSetting *nm_ip4_config_create_setting (const NMIP4Config *config); NMSetting *nm_ip4_config_create_setting (const NMIP4Config *config);

View File

@@ -301,7 +301,7 @@ nm_ip6_config_addresses_sort (NMIP6Config *self)
} }
NMIP6Config * NMIP6Config *
nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary) nm_ip6_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary)
{ {
NMIP6Config *config; NMIP6Config *config;
NMIP6ConfigPrivate *priv; NMIP6ConfigPrivate *priv;
@@ -312,7 +312,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
gboolean notify_nameservers = FALSE; gboolean notify_nameservers = FALSE;
/* Slaves have no IP configuration */ /* Slaves have no IP configuration */
if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0) if (nm_platform_link_get_master (platform, ifindex) > 0)
return NULL; return NULL;
config = nm_ip6_config_new (ifindex); config = nm_ip6_config_new (ifindex);
@@ -321,8 +321,8 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
g_array_unref (priv->addresses); g_array_unref (priv->addresses);
g_array_unref (priv->routes); g_array_unref (priv->routes);
priv->addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex); priv->addresses = nm_platform_ip6_address_get_all (platform, ifindex);
priv->routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT); priv->routes = nm_platform_ip6_route_get_all (platform, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
/* Extract gateway from default route */ /* Extract gateway from default route */
old_gateway = priv->gateway; old_gateway = priv->gateway;
@@ -386,7 +386,11 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
} }
gboolean gboolean
nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_full_sync) nm_ip6_config_commit (const NMIP6Config *config,
NMPlatform *platform,
NMRouteManager *route_manager,
int ifindex,
gboolean routes_full_sync)
{ {
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
gboolean success; gboolean success;
@@ -395,7 +399,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_fu
g_return_val_if_fail (config != NULL, FALSE); g_return_val_if_fail (config != NULL, FALSE);
/* Addresses */ /* Addresses */
nm_platform_ip6_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, TRUE); nm_platform_ip6_address_sync (platform, ifindex, priv->addresses, TRUE);
/* Routes */ /* Routes */
{ {
@@ -409,7 +413,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_fu
g_array_append_vals (routes, route, 1); g_array_append_vals (routes, route, 1);
} }
success = nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes, TRUE, routes_full_sync); success = nm_route_manager_ip6_route_sync (route_manager, ifindex, routes, TRUE, routes_full_sync);
g_array_unref (routes); g_array_unref (routes);
} }

View File

@@ -61,8 +61,12 @@ NMIP6Config * nm_ip6_config_new_cloned (const NMIP6Config *src);
int nm_ip6_config_get_ifindex (const NMIP6Config *config); int nm_ip6_config_get_ifindex (const NMIP6Config *config);
NMIP6Config *nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary); NMIP6Config *nm_ip6_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary);
gboolean nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_full_sync); gboolean nm_ip6_config_commit (const NMIP6Config *config,
NMPlatform *platform,
NMRouteManager *route_manager,
int ifindex,
gboolean routes_full_sync);
void nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, guint32 default_route_metric); void nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, guint32 default_route_metric);
NMSetting *nm_ip6_config_create_setting (const NMIP6Config *config); NMSetting *nm_ip6_config_create_setting (const NMIP6Config *config);

View File

@@ -62,20 +62,6 @@ NM_DEFINE_SINGLETON_GETTER (NMNetns, nm_netns_get, NM_TYPE_NETNS);
/*****************************************************************************/ /*****************************************************************************/
NMRouteManager *
nm_route_manager_get (void)
{
return nm_netns_get_route_manager (NM_NETNS_GET);
}
NMDefaultRouteManager *
nm_default_route_manager_get (void)
{
return nm_netns_get_default_route_manager (NM_NETNS_GET);
}
/*****************************************************************************/
NMPNetns * NMPNetns *
nm_netns_get_platform_netns (NMNetns *self) nm_netns_get_platform_netns (NMNetns *self)
{ {

View File

@@ -48,6 +48,7 @@
#include "nm-dhcp4-config.h" #include "nm-dhcp4-config.h"
#include "nm-dhcp6-config.h" #include "nm-dhcp6-config.h"
#include "nm-config.h" #include "nm-config.h"
#include "nm-netns.h"
/*****************************************************************************/ /*****************************************************************************/
@@ -62,6 +63,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMPolicy,
typedef struct { typedef struct {
NMManager *manager; NMManager *manager;
NMNetns *netns;
NMFirewallManager *firewall_manager; NMFirewallManager *firewall_manager;
GSList *pending_activation_checks; GSList *pending_activation_checks;
@@ -373,7 +375,7 @@ get_best_ip4_device (NMPolicy *self, gboolean fully_activated)
{ {
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
return nm_default_route_manager_ip4_get_best_device (nm_default_route_manager_get (), return nm_default_route_manager_ip4_get_best_device (nm_netns_get_default_route_manager (priv->netns),
nm_manager_get_devices (priv->manager), nm_manager_get_devices (priv->manager),
fully_activated, fully_activated,
priv->default_device4); priv->default_device4);
@@ -384,7 +386,7 @@ get_best_ip6_device (NMPolicy *self, gboolean fully_activated)
{ {
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
return nm_default_route_manager_ip6_get_best_device (nm_default_route_manager_get (), return nm_default_route_manager_ip6_get_best_device (nm_netns_get_default_route_manager (priv->netns),
nm_manager_get_devices (priv->manager), nm_manager_get_devices (priv->manager),
fully_activated, fully_activated,
priv->default_device6); priv->default_device6);
@@ -793,7 +795,7 @@ get_best_ip4_config (NMPolicy *self,
NMDevice **out_device, NMDevice **out_device,
NMVpnConnection **out_vpn) NMVpnConnection **out_vpn)
{ {
return nm_default_route_manager_ip4_get_best_config (nm_default_route_manager_get (), return nm_default_route_manager_ip4_get_best_config (nm_netns_get_default_route_manager (NM_POLICY_GET_PRIVATE (self)->netns),
ignore_never_default, ignore_never_default,
out_ip_iface, out_ip_iface,
out_ac, out_ac,
@@ -888,7 +890,7 @@ get_best_ip6_config (NMPolicy *self,
NMDevice **out_device, NMDevice **out_device,
NMVpnConnection **out_vpn) NMVpnConnection **out_vpn)
{ {
return nm_default_route_manager_ip6_get_best_config (nm_default_route_manager_get (), return nm_default_route_manager_ip6_get_best_config (nm_netns_get_default_route_manager (NM_POLICY_GET_PRIVATE (self)->netns),
ignore_never_default, ignore_never_default,
out_ip_iface, out_ip_iface,
out_ac, out_ac,
@@ -2289,6 +2291,8 @@ nm_policy_init (NMPolicy *self)
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
const char *hostname_mode; const char *hostname_mode;
priv->netns = g_object_ref (nm_netns_get ());
hostname_mode = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG, hostname_mode = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_GROUP_MAIN,
NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE, NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE,
@@ -2446,6 +2450,8 @@ finalize (GObject *object)
g_hash_table_unref (priv->devices); g_hash_table_unref (priv->devices);
G_OBJECT_CLASS (nm_policy_parent_class)->finalize (object); G_OBJECT_CLASS (nm_policy_parent_class)->finalize (object);
g_object_unref (priv->netns);
} }
static void static void

View File

@@ -44,7 +44,6 @@ gboolean nm_route_manager_route_flush (NMRouteManager *self, int ifindex);
gboolean nm_route_manager_ip4_routes_shadowed (NMRouteManager *self, int ifindex); gboolean nm_route_manager_ip4_routes_shadowed (NMRouteManager *self, int ifindex);
void nm_route_manager_ip4_route_register_device_route_purge_list (NMRouteManager *self, GArray *device_route_purge_list); void nm_route_manager_ip4_route_register_device_route_purge_list (NMRouteManager *self, GArray *device_route_purge_list);
NMRouteManager *nm_route_manager_get (void);
NMRouteManager *nm_route_manager_new (gboolean log_with_ptr, NMPlatform *platform); NMRouteManager *nm_route_manager_new (gboolean log_with_ptr, NMPlatform *platform);
#endif /* __NM_ROUTE_MANAGER_H__ */ #endif /* __NM_ROUTE_MANAGER_H__ */

View File

@@ -33,6 +33,10 @@ typedef struct {
int ifindex0, ifindex1; int ifindex0, ifindex1;
} test_fixture; } test_fixture;
NMRouteManager *route_manager_get (void);
NM_DEFINE_SINGLETON_GETTER (NMRouteManager, route_manager_get, NM_TYPE_ROUTE_MANAGER);
/*****************************************************************************/ /*****************************************************************************/
static void static void
@@ -60,7 +64,7 @@ setup_dev0_ip4 (int ifindex, guint mss_of_first_route, guint32 metric_of_second_
route.mss = 0; route.mss = 0;
g_array_append_val (routes, route); g_array_append_val (routes, route);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes, TRUE, TRUE); nm_route_manager_ip4_route_sync (route_manager_get (), ifindex, routes, TRUE, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
} }
@@ -106,7 +110,7 @@ setup_dev1_ip4 (int ifindex)
route.metric = 22; route.metric = 22;
g_array_append_val (routes, route); g_array_append_val (routes, route);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes, TRUE, TRUE); nm_route_manager_ip4_route_sync (route_manager_get (), ifindex, routes, TRUE, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
} }
@@ -133,7 +137,7 @@ update_dev0_ip4 (int ifindex)
route.metric = 21; route.metric = 21;
g_array_append_val (routes, route); g_array_append_val (routes, route);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes, TRUE, TRUE); nm_route_manager_ip4_route_sync (route_manager_get (), ifindex, routes, TRUE, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
} }
@@ -345,7 +349,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, state2, routes->len, TRUE); nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, state2, routes->len, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
nm_route_manager_route_flush (nm_route_manager_get (), fixture->ifindex0); nm_route_manager_route_flush (route_manager_get (), fixture->ifindex0);
/* 6.6.6.0/24 is now on dev1 /* 6.6.6.0/24 is now on dev1
* 6.6.6.0/24 is also still on dev1 with bumped metric 21. * 6.6.6.0/24 is also still on dev1 with bumped metric 21.
@@ -357,7 +361,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, state3, routes->len, TRUE); nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, state3, routes->len, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
nm_route_manager_route_flush (nm_route_manager_get (), fixture->ifindex1); nm_route_manager_route_flush (route_manager_get (), fixture->ifindex1);
/* No routes left. */ /* No routes left. */
routes = ip4_routes (fixture); routes = ip4_routes (fixture);
@@ -408,7 +412,7 @@ setup_dev0_ip6 (int ifindex)
0); 0);
g_array_append_val (routes, *route); g_array_append_val (routes, *route);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes, TRUE, TRUE); nm_route_manager_ip6_route_sync (route_manager_get (), ifindex, routes, TRUE, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
} }
@@ -466,7 +470,7 @@ setup_dev1_ip6 (int ifindex)
0); 0);
g_array_append_val (routes, *route); g_array_append_val (routes, *route);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes, TRUE, TRUE); nm_route_manager_ip6_route_sync (route_manager_get (), ifindex, routes, TRUE, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
} }
@@ -513,7 +517,7 @@ update_dev0_ip6 (int ifindex)
0); 0);
g_array_append_val (routes, *route); g_array_append_val (routes, *route);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes, TRUE, TRUE); nm_route_manager_ip6_route_sync (route_manager_get (), ifindex, routes, TRUE, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
} }
@@ -759,7 +763,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
nmtst_platform_ip6_routes_equal ((NMPlatformIP6Route *) routes->data, state2, routes->len, TRUE); nmtst_platform_ip6_routes_equal ((NMPlatformIP6Route *) routes->data, state2, routes->len, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
nm_route_manager_route_flush (nm_route_manager_get (), fixture->ifindex0); nm_route_manager_route_flush (route_manager_get (), fixture->ifindex0);
/* 2001:db8:abad:c0de::/64 on dev1 is still there, went away from dev0 /* 2001:db8:abad:c0de::/64 on dev1 is still there, went away from dev0
* 2001:db8:8086::/48 is now on dev1 * 2001:db8:8086::/48 is now on dev1
@@ -771,7 +775,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
nmtst_platform_ip6_routes_equal ((NMPlatformIP6Route *) routes->data, state3, routes->len, TRUE); nmtst_platform_ip6_routes_equal ((NMPlatformIP6Route *) routes->data, state3, routes->len, TRUE);
g_array_free (routes, TRUE); g_array_free (routes, TRUE);
nm_route_manager_route_flush (nm_route_manager_get (), fixture->ifindex1); nm_route_manager_route_flush (route_manager_get (), fixture->ifindex1);
/* No routes left. */ /* No routes left. */
routes = ip6_routes (fixture); routes = ip6_routes (fixture);
@@ -835,7 +839,7 @@ test_ip4_full_sync (test_fixture *fixture, gconstpointer user_data)
g_array_set_size (routes, 2); g_array_set_size (routes, 2);
g_array_index (routes, NMPlatformIP4Route, 0) = r01; g_array_index (routes, NMPlatformIP4Route, 0) = r01;
g_array_index (routes, NMPlatformIP4Route, 1) = r02; g_array_index (routes, NMPlatformIP4Route, 1) = r02;
nm_route_manager_ip4_route_sync (nm_route_manager_get (), fixture->ifindex0, routes, TRUE, TRUE); nm_route_manager_ip4_route_sync (route_manager_get (), fixture->ifindex0, routes, TRUE, TRUE);
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r01); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r01);
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r02); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r02);
@@ -847,7 +851,7 @@ test_ip4_full_sync (test_fixture *fixture, gconstpointer user_data)
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r02); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r02);
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r03); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r03);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), fixture->ifindex0, routes, TRUE, FALSE); nm_route_manager_ip4_route_sync (route_manager_get (), fixture->ifindex0, routes, TRUE, FALSE);
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r01); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r01);
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r02); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r02);
@@ -855,13 +859,13 @@ test_ip4_full_sync (test_fixture *fixture, gconstpointer user_data)
g_array_set_size (routes, 1); g_array_set_size (routes, 1);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), fixture->ifindex0, routes, TRUE, FALSE); nm_route_manager_ip4_route_sync (route_manager_get (), fixture->ifindex0, routes, TRUE, FALSE);
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r01); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r01);
_assert_route_check (vtable, FALSE, (const NMPlatformIPXRoute *) &r02); _assert_route_check (vtable, FALSE, (const NMPlatformIPXRoute *) &r02);
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r03); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r03);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), fixture->ifindex0, routes, TRUE, TRUE); nm_route_manager_ip4_route_sync (route_manager_get (), fixture->ifindex0, routes, TRUE, TRUE);
_assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r01); _assert_route_check (vtable, TRUE, (const NMPlatformIPXRoute *) &r01);
_assert_route_check (vtable, FALSE, (const NMPlatformIPXRoute *) &r02); _assert_route_check (vtable, FALSE, (const NMPlatformIPXRoute *) &r02);

View File

@@ -40,6 +40,7 @@
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "nm-dispatcher.h" #include "nm-dispatcher.h"
#include "nm-netns.h"
#include "settings/nm-agent-manager.h" #include "settings/nm-agent-manager.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-pacrunner-manager.h" #include "nm-pacrunner-manager.h"
@@ -120,8 +121,8 @@ typedef struct {
/* Firewall */ /* Firewall */
NMFirewallManagerCallId fw_call; NMFirewallManagerCallId fw_call;
NMDefaultRouteManager *default_route_manager; NMNetns *netns;
NMRouteManager *route_manager;
GDBusProxy *proxy; GDBusProxy *proxy;
GCancellable *cancellable; GCancellable *cancellable;
GVariant *connect_hash; GVariant *connect_hash;
@@ -393,7 +394,7 @@ vpn_cleanup (NMVpnConnection *self, NMDevice *parent_dev)
if (priv->ip_ifindex) { if (priv->ip_ifindex) {
nm_platform_link_set_down (NM_PLATFORM_GET, priv->ip_ifindex); nm_platform_link_set_down (NM_PLATFORM_GET, priv->ip_ifindex);
nm_route_manager_route_flush (priv->route_manager, priv->ip_ifindex); nm_route_manager_route_flush (nm_netns_get_route_manager (priv->netns), priv->ip_ifindex);
nm_platform_address_flush (NM_PLATFORM_GET, priv->ip_ifindex); nm_platform_address_flush (NM_PLATFORM_GET, priv->ip_ifindex);
} }
@@ -495,8 +496,8 @@ _set_vpn_state (NMVpnConnection *self,
dispatcher_cleanup (self); dispatcher_cleanup (self);
nm_default_route_manager_ip4_update_default_route (priv->default_route_manager, self); nm_default_route_manager_ip4_update_default_route (nm_netns_get_default_route_manager (priv->netns), self);
nm_default_route_manager_ip6_update_default_route (priv->default_route_manager, self); nm_default_route_manager_ip6_update_default_route (nm_netns_get_default_route_manager (priv->netns), self);
/* The connection gets destroyed by the VPN manager when it enters the /* The connection gets destroyed by the VPN manager when it enters the
* disconnected/failed state, but we need to keep it around for a bit * disconnected/failed state, but we need to keep it around for a bit
@@ -1093,7 +1094,10 @@ nm_vpn_connection_apply_config (NMVpnConnection *self)
nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL); nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL);
if (priv->ip4_config) { if (priv->ip4_config) {
if (!nm_ip4_config_commit (priv->ip4_config, priv->ip_ifindex, if (!nm_ip4_config_commit (priv->ip4_config,
NM_PLATFORM_GET,
nm_netns_get_route_manager (priv->netns),
priv->ip_ifindex,
TRUE, TRUE,
nm_vpn_connection_get_ip4_route_metric (self))) nm_vpn_connection_get_ip4_route_metric (self)))
return FALSE; return FALSE;
@@ -1101,6 +1105,8 @@ nm_vpn_connection_apply_config (NMVpnConnection *self)
if (priv->ip6_config) { if (priv->ip6_config) {
if (!nm_ip6_config_commit (priv->ip6_config, if (!nm_ip6_config_commit (priv->ip6_config,
NM_PLATFORM_GET,
nm_netns_get_route_manager (priv->netns),
priv->ip_ifindex, priv->ip_ifindex,
TRUE)) TRUE))
return FALSE; return FALSE;
@@ -1112,8 +1118,8 @@ nm_vpn_connection_apply_config (NMVpnConnection *self)
apply_parent_device_config (self); apply_parent_device_config (self);
nm_default_route_manager_ip4_update_default_route (priv->default_route_manager, self); nm_default_route_manager_ip4_update_default_route (nm_netns_get_default_route_manager (priv->netns), self);
nm_default_route_manager_ip6_update_default_route (priv->default_route_manager, self); nm_default_route_manager_ip6_update_default_route (nm_netns_get_default_route_manager (priv->netns), self);
_LOGI ("VPN connection: (IP Config Get) complete"); _LOGI ("VPN connection: (IP Config Get) complete");
if (priv->vpn_state < STATE_PRE_UP) if (priv->vpn_state < STATE_PRE_UP)
@@ -2614,8 +2620,7 @@ nm_vpn_connection_init (NMVpnConnection *self)
priv->vpn_state = STATE_WAITING; priv->vpn_state = STATE_WAITING;
priv->secrets_idx = SECRETS_REQ_SYSTEM; priv->secrets_idx = SECRETS_REQ_SYSTEM;
priv->default_route_manager = g_object_ref (nm_default_route_manager_get ()); priv->netns = g_object_ref (nm_netns_get ());
priv->route_manager = g_object_ref (nm_route_manager_get ());
} }
static void static void
@@ -2646,8 +2651,7 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_vpn_connection_parent_class)->dispose (object); G_OBJECT_CLASS (nm_vpn_connection_parent_class)->dispose (object);
g_clear_object (&priv->default_route_manager); g_clear_object (&priv->netns);
g_clear_object (&priv->route_manager);
} }
static void static void