Commit c48a19b7 authored by Thomas Haller's avatar Thomas Haller

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
parent 0af2f5c2
This diff is collapsed.
......@@ -410,6 +410,9 @@ typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
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_iface (NMDevice *dev);
int nm_device_get_ifindex (NMDevice *dev);
......
......@@ -33,6 +33,7 @@
#include "NetworkManagerUtils.h"
#include "devices/nm-device-private.h"
#include "nm-route-manager.h"
#include "nm-netns.h"
#include "nm-act-request.h"
#include "nm-ip4-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) {
ifindex = nm_device_get_ip_ifindex (device);
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_link_set_down (NM_PLATFORM_GET, ifindex);
}
......
......@@ -37,7 +37,6 @@ typedef struct _NMDefaultRouteManagerClass NMDefaultRouteManagerClass;
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);
gboolean nm_default_route_manager_ip4_update_default_route (NMDefaultRouteManager *manager, gpointer source);
......
......@@ -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) {
case NM_DHCP_STATE_BOUND:
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)
nm_ip4_config_subtract (existing, last_config);
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");
if (last_config)
......@@ -175,7 +177,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
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)
nm_ip6_config_subtract (existing, ndisc_config);
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);
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");
}
......
......@@ -249,7 +249,7 @@ notify_addresses (NMIP4Config *self)
}
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;
NMIP4ConfigPrivate *priv;
......@@ -259,7 +259,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
gboolean old_has_gateway = FALSE;
/* 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;
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->routes);
priv->addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, 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->addresses = nm_platform_ip4_address_get_all (platform, ifindex);
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 */
old_gateway = priv->gateway;
......@@ -331,7 +331,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
}
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);
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);
/* 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);
/* Routes */
......@@ -401,9 +401,9 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_fu
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);
if (!success)
return FALSE;
......
......@@ -59,8 +59,8 @@ NMIP4Config * nm_ip4_config_new (int ifindex);
int nm_ip4_config_get_ifindex (const NMIP4Config *config);
NMIP4Config *nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf);
gboolean nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_full_sync, gint64 default_route_metric);
NMIP4Config *nm_ip4_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resolv_conf);
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);
NMSetting *nm_ip4_config_create_setting (const NMIP4Config *config);
......
......@@ -301,7 +301,7 @@ nm_ip6_config_addresses_sort (NMIP6Config *self)
}
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;
NMIP6ConfigPrivate *priv;
......@@ -312,7 +312,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
gboolean notify_nameservers = FALSE;
/* 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;
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->routes);
priv->addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, 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->addresses = nm_platform_ip6_address_get_all (platform, ifindex);
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 */
old_gateway = priv->gateway;
......@@ -386,7 +386,11 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
}
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);
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);
/* Addresses */
nm_platform_ip6_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, TRUE);
nm_platform_ip6_address_sync (platform, ifindex, priv->addresses, TRUE);
/* Routes */
{
......@@ -409,7 +413,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_fu
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);
}
......
......@@ -61,8 +61,12 @@ NMIP6Config * nm_ip6_config_new_cloned (const NMIP6Config *src);
int nm_ip6_config_get_ifindex (const NMIP6Config *config);
NMIP6Config *nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary);
gboolean nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_full_sync);
NMIP6Config *nm_ip6_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary);
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);
NMSetting *nm_ip6_config_create_setting (const NMIP6Config *config);
......
......@@ -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 *
nm_netns_get_platform_netns (NMNetns *self)
{
......
......@@ -48,6 +48,7 @@
#include "nm-dhcp4-config.h"
#include "nm-dhcp6-config.h"
#include "nm-config.h"
#include "nm-netns.h"
/*****************************************************************************/
......@@ -62,6 +63,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMPolicy,
typedef struct {
NMManager *manager;
NMNetns *netns;
NMFirewallManager *firewall_manager;
GSList *pending_activation_checks;
......@@ -373,7 +375,7 @@ get_best_ip4_device (NMPolicy *self, gboolean fully_activated)
{
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),
fully_activated,
priv->default_device4);
......@@ -384,7 +386,7 @@ get_best_ip6_device (NMPolicy *self, gboolean fully_activated)
{
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),
fully_activated,
priv->default_device6);
......@@ -793,7 +795,7 @@ get_best_ip4_config (NMPolicy *self,
NMDevice **out_device,
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,
out_ip_iface,
out_ac,
......@@ -888,7 +890,7 @@ get_best_ip6_config (NMPolicy *self,
NMDevice **out_device,
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,
out_ip_iface,
out_ac,
......@@ -2289,6 +2291,8 @@ nm_policy_init (NMPolicy *self)
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
const char *hostname_mode;
priv->netns = g_object_ref (nm_netns_get ());
hostname_mode = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
NM_CONFIG_KEYFILE_GROUP_MAIN,
NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE,
......@@ -2446,6 +2450,8 @@ finalize (GObject *object)
g_hash_table_unref (priv->devices);
G_OBJECT_CLASS (nm_policy_parent_class)->finalize (object);
g_object_unref (priv->netns);
}
static void
......
......@@ -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);
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);
#endif /* __NM_ROUTE_MANAGER_H__ */
......@@ -33,6 +33,10 @@ typedef struct {
int ifindex0, ifindex1;
} test_fixture;
NMRouteManager *route_manager_get (void);
NM_DEFINE_SINGLETON_GETTER (NMRouteManager, route_manager_get, NM_TYPE_ROUTE_MANAGER);
/*****************************************************************************/
static void
......@@ -60,7 +64,7 @@ setup_dev0_ip4 (int ifindex, guint mss_of_first_route, guint32 metric_of_second_
route.mss = 0;
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);
}
......@@ -106,7 +110,7 @@ setup_dev1_ip4 (int ifindex)
route.metric = 22;
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);
}
......@@ -133,7 +137,7 @@ update_dev0_ip4 (int ifindex)
route.metric = 21;
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);
}
......@@ -345,7 +349,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, state2, routes->len, 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 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);
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. */
routes = ip4_routes (fixture);
......@@ -408,7 +412,7 @@ setup_dev0_ip6 (int ifindex)
0);
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);
}
......@@ -466,7 +470,7 @@ setup_dev1_ip6 (int ifindex)
0);
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);
}
......@@ -513,7 +517,7 @@ update_dev0_ip6 (int ifindex)
0);
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);
}
......@@ -759,7 +763,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
nmtst_platform_ip6_routes_equal ((NMPlatformIP6Route *) routes->data, state2, routes->len, 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: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);
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. */
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_index (routes, NMPlatformIP4Route, 0) = r01;
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 *) &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 *) &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 *) &r02);
......@@ -855,13 +859,13 @@ test_ip4_full_sync (test_fixture *fixture, gconstpointer user_data)
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, FALSE, (const NMPlatformIPXRoute *) &r02);
_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, FALSE, (const NMPlatformIPXRoute *) &r02);
......
......@@ -40,6 +40,7 @@
#include "NetworkManagerUtils.h"
#include "settings/nm-settings-connection.h"
#include "nm-dispatcher.h"
#include "nm-netns.h"
#include "settings/nm-agent-manager.h"
#include "nm-core-internal.h"
#include "nm-pacrunner-manager.h"
......@@ -120,8 +121,8 @@ typedef struct {
/* Firewall */
NMFirewallManagerCallId fw_call;
NMDefaultRouteManager *default_route_manager;
NMRouteManager *route_manager;
NMNetns *netns;
GDBusProxy *proxy;
GCancellable *cancellable;
GVariant *connect_hash;
......@@ -393,7 +394,7 @@ vpn_cleanup (NMVpnConnection *self, NMDevice *parent_dev)
if (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);
}
......@@ -495,8 +496,8 @@ _set_vpn_state (NMVpnConnection *self,
dispatcher_cleanup (self);
nm_default_route_manager_ip4_update_default_route (priv->default_route_manager, self);
nm_default_route_manager_ip6_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 (nm_netns_get_default_route_manager (priv->netns), self);
/* 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
......@@ -1093,7 +1094,10 @@ nm_vpn_connection_apply_config (NMVpnConnection *self)
nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL);
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,
nm_vpn_connection_get_ip4_route_metric (self)))
return FALSE;
......@@ -1101,6 +1105,8 @@ nm_vpn_connection_apply_config (NMVpnConnection *self)
if (priv->ip6_config) {
if (!nm_ip6_config_commit (priv->ip6_config,
NM_PLATFORM_GET,
nm_netns_get_route_manager (priv->netns),
priv->ip_ifindex,
TRUE))
return FALSE;
......@@ -1112,8 +1118,8 @@ nm_vpn_connection_apply_config (NMVpnConnection *self)
apply_parent_device_config (self);
nm_default_route_manager_ip4_update_default_route (priv->default_route_manager, self);
nm_default_route_manager_ip6_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 (nm_netns_get_default_route_manager (priv->netns), self);
_LOGI ("VPN connection: (IP Config Get) complete");
if (priv->vpn_state < STATE_PRE_UP)
......@@ -2614,8 +2620,7 @@ nm_vpn_connection_init (NMVpnConnection *self)
priv->vpn_state = STATE_WAITING;
priv->secrets_idx = SECRETS_REQ_SYSTEM;
priv->default_route_manager = g_object_ref (nm_default_route_manager_get ());
priv->route_manager = g_object_ref (nm_route_manager_get ());
priv->netns = g_object_ref (nm_netns_get ());
}
static void
......@@ -2646,8 +2651,7 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_vpn_connection_parent_class)->dispose (object);
g_clear_object (&priv->default_route_manager);
g_clear_object (&priv->route_manager);
g_clear_object (&priv->netns);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment