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

@@ -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)
{