diff options
Diffstat (limited to 'src/platform/nm-platform.c')
-rw-r--r-- | src/platform/nm-platform.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index d82b096a2c..633b968126 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -37,6 +37,7 @@ #include "nm-platform.h" #include "nm-platform-utils.h" #include "nmp-object.h" +#include "nmp-netns-utils.h" #include "NetworkManagerUtils.h" #include "nm-enum-types.h" #include "nm-core-internal.h" @@ -2127,6 +2128,10 @@ nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_pe /* Pre-4.1 kernel did not expose the peer_ifindex as IFA_LINK. Lookup via ethtool. */ if (out_peer_ifindex) { + nm_auto_pop_netns NMPNetns *netns = NULL; + + if (!nm_platform_netns_push (self, &netns)) + return FALSE; peer_ifindex = nmp_utils_ethtool_get_peer_ifindex (plink->name); if (peer_ifindex <= 0) return FALSE; @@ -2372,16 +2377,24 @@ _to_string_dev (NMPlatform *self, int ifindex, char *buf, size_t size) gboolean nm_platform_ethtool_set_wake_on_lan (NMPlatform *self, const char *ifname, NMSettingWiredWakeOnLan wol, const char *wol_password) { + nm_auto_pop_netns NMPNetns *netns = NULL; _CHECK_SELF (self, klass, FALSE); + if (!nm_platform_netns_push (self, &netns)) + return FALSE; + return nmp_utils_ethtool_set_wake_on_lan (ifname, wol, wol_password); } gboolean nm_platform_ethtool_get_link_speed (NMPlatform *self, const char *ifname, guint32 *out_speed) { + nm_auto_pop_netns NMPNetns *netns = NULL; _CHECK_SELF (self, klass, FALSE); + if (!nm_platform_netns_push (self, &netns)) + return FALSE; + return nmp_utils_ethtool_get_link_speed (ifname, out_speed); } @@ -3997,6 +4010,30 @@ log_ip6_route (NMPlatform *self, NMPObjectType obj_type, int ifindex, NMPlatform /******************************************************************/ +NMPNetns * +nm_platform_netns_get (NMPlatform *self) +{ + _CHECK_SELF (self, klass, NULL); + + return self->_netns; +} + +gboolean +nm_platform_netns_push (NMPlatform *platform, NMPNetns **netns) +{ + g_return_val_if_fail (NM_IS_PLATFORM (platform), FALSE); + g_return_val_if_fail (!netns || !*netns, FALSE); + + if ( platform->_netns + && !nmp_netns_push (platform->_netns)) + return FALSE; + + NM_SET_OUT (netns, platform->_netns); + return TRUE; +} + +/******************************************************************/ + static gboolean _vtr_v4_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, gint64 metric) { @@ -4124,6 +4161,20 @@ constructed (GObject *object) static void nm_platform_init (NMPlatform *object) { + NMPlatform *self = NM_PLATFORM (object); + NMPNetns *netns; + + netns = nmp_netns_get_current (); + if (netns) + self->_netns = nmp_netns_ref (netns); +} + +static void +finalize (GObject *object) +{ + NMPlatform *self = NM_PLATFORM (object); + + nmp_netns_unref (self->_netns); } static void @@ -4135,6 +4186,7 @@ nm_platform_class_init (NMPlatformClass *platform_class) object_class->set_property = set_property; object_class->constructed = constructed; + object_class->finalize = finalize; platform_class->wifi_set_powersave = wifi_set_powersave; |