core: add NMNetns to bundle platform and route managers

System Internals / NetworkManager - Thomas Haller [redhat.com] - 18 April 2017 09:49 EDT

NMPlatform, NMRouteManager and NMDefaultRouteManager are singletons instances. Users of those are for example NMDevice, which registers to GObject signals of both NMPlatform and NMRouteManager.

Hence, as NMDevice:dispose() disconnects the signal handlers, it must ensure that those singleton instances live longer then the NMDevice instance. That is usually accomplished by having users of singleton instances own a reference to those instances. For NMDevice that effectively means that it shall own a reference to several singletons.

NMPlatform, NMRouteManager, and NMDefaultRouteManager are all per-namespace. In general it doesn't make sense to have more then one instances of these per name space. Nnote that currently we don't support multiple namespaces yet. If we will ever support multiple namespaces, then a NMDevice would have a reference to all of these manager instances. Hence, introduce a new class NMNetns which bundles them together.

0af2f5c core: add NMNetns to bundle platform and route managers
Makefile.am | 2 +
src/main.c | 10 +-
src/nm-default-route-manager.c | 28 ++++--
src/nm-default-route-manager.h | 5 +-
src/nm-iface-helper.c | 5 +
src/nm-netns.c | 190 ++++++++++++++++++++++++++++++++++++++
src/nm-netns.h | 47 ++++++++++
src/nm-route-manager.c | 23 +++--
src/nm-route-manager.h | 5 +-
src/nm-types.h | 1 +
src/platform/nm-fake-platform.c | 8 +-
src/platform/nm-linux-platform.c | 13 +--
src/platform/nm-linux-platform.h | 2 +-
src/platform/nm-platform.c | 43 ++++-----
src/platform/nm-platform.h | 5 +-
src/platform/tests/test-general.c | 4 +-
src/platform/tests/test-link.c | 12 +--
17 files changed, 333 insertions(+), 70 deletions(-)

Upstream: cgit.freedesktop.org


  • Share