summaryrefslogtreecommitdiff
path: root/src/platform/nm-linux-platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/nm-linux-platform.c')
-rw-r--r--src/platform/nm-linux-platform.c83
1 files changed, 41 insertions, 42 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index cedc220a75..9a22f02910 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -62,11 +62,11 @@
/* nm-internal error codes for libnl. Make sure they don't overlap. */
#define _NLE_NM_NOBUFS 500
-/*********************************************************************************************/
+/*****************************************************************************/
#define IFQDISCSIZ 32
-/*********************************************************************************************/
+/*****************************************************************************/
#ifndef IFLA_PROMISCUITY
#define IFLA_PROMISCUITY 30
@@ -114,7 +114,7 @@
#define IP6_FLOWINFO_TCLASS_SHIFT 20
#define IP6_FLOWINFO_FLOWLABEL_MASK 0x000FFFFF
-/*********************************************************************************************/
+/*****************************************************************************/
#define _NMLOG_PREFIX_NAME "platform-linux"
#define _NMLOG_DOMAIN LOGD_PLATFORM
@@ -550,7 +550,7 @@ _addrtime_get_lifetimes (guint32 timestamp,
*out_preferred = preferred;
}
-/******************************************************************/
+/*****************************************************************************/
static const NMPObject *
_lookup_cached_link (const NMPCache *cache, int ifindex, gboolean *completed_from_cache, const NMPObject **link_cached)
@@ -571,7 +571,7 @@ _lookup_cached_link (const NMPCache *cache, int ifindex, gboolean *completed_fro
return *link_cached;
}
-/******************************************************************/
+/*****************************************************************************/
#define DEVTYPE_PREFIX "DEVTYPE="
@@ -1975,7 +1975,7 @@ nmp_object_new_from_nl (NMPlatform *platform, const NMPCache *cache, struct nl_m
}
}
-/******************************************************************/
+/*****************************************************************************/
static gboolean
_nl_msg_new_link_set_afspec (struct nl_msg *msg,
@@ -2352,7 +2352,7 @@ nla_put_failure:
g_return_val_if_reached (NULL);
}
-/******************************************************************/
+/*****************************************************************************/
static int _support_kernel_extended_ifa_flags = -1;
@@ -2404,9 +2404,7 @@ typedef struct {
gint *out_refresh_all_in_progess;
} DelayedActionWaitForNlResponseData;
-typedef struct _NMLinuxPlatformPrivate NMLinuxPlatformPrivate;
-
-struct _NMLinuxPlatformPrivate {
+typedef struct {
struct nl_sock *nlh;
guint32 nlh_seq_next;
#ifdef NM_MORE_LOGGING
@@ -2441,18 +2439,27 @@ struct _NMLinuxPlatformPrivate {
GHashTable *prune_candidates;
GHashTable *wifi_data;
+} NMLinuxPlatformPrivate;
+
+struct _NMLinuxPlatform {
+ NMPlatform parent;
+ NMLinuxPlatformPrivate _priv;
};
+struct _NMLinuxPlatformClass {
+ NMPlatformClass parent;
+};
+
+G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM)
+
static inline NMLinuxPlatformPrivate *
NM_LINUX_PLATFORM_GET_PRIVATE (const void *self)
{
nm_assert (NM_IS_LINUX_PLATFORM (self));
- return ((NMLinuxPlatform *) self)->priv;
+ return &(((NMLinuxPlatform *) self)->_priv);
}
-G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM)
-
NMPlatform *
nm_linux_platform_new (gboolean netns_support)
{
@@ -2471,7 +2478,7 @@ nm_linux_platform_setup (void)
NULL);
}
-/******************************************************************/
+/*****************************************************************************/
static void
_assert_netns_current (NMPlatform *platform)
@@ -2703,7 +2710,7 @@ sysctl_get (NMPlatform *platform, const char *path)
return contents;
}
-/******************************************************************/
+/*****************************************************************************/
static gboolean
check_support_kernel_extended_ifa_flags (NMPlatform *platform)
@@ -2727,14 +2734,14 @@ process_events (NMPlatform *platform)
delayed_action_handle_all (platform, TRUE);
}
-/******************************************************************/
+/*****************************************************************************/
#define cache_lookup_all_objects(type, platform, obj_type, visible_only) \
((const type *const*) nmp_cache_lookup_multi (NM_LINUX_PLATFORM_GET_PRIVATE ((platform))->cache, \
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, (obj_type), (visible_only)), \
NULL))
-/******************************************************************/
+/*****************************************************************************/
static void
do_emit_signal (NMPlatform *platform, const NMPObject *obj, NMPCacheOpsType cache_op, gboolean was_visible)
@@ -2804,7 +2811,7 @@ do_emit_signal (NMPlatform *platform, const NMPObject *obj, NMPCacheOpsType cach
(NMPlatformSignalChangeType) cache_op);
}
-/******************************************************************/
+/*****************************************************************************/
_NM_UTILS_LOOKUP_DEFINE (static, delayed_action_refresh_from_object_type, NMPObjectType, DelayedActionType,
NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT (DELAYED_ACTION_TYPE_NONE),
@@ -3163,7 +3170,7 @@ delayed_action_schedule_WAIT_FOR_NL_RESPONSE (NMPlatform *platform,
&data);
}
-/******************************************************************/
+/*****************************************************************************/
static void
cache_prune_candidates_record_all (NMPlatform *platform, NMPObjectType obj_type)
@@ -3509,7 +3516,7 @@ cache_post (NMPlatform *platform,
}
}
-/******************************************************************/
+/*****************************************************************************/
static int
_nl_send_auto_with_seq (NMPlatform *platform,
@@ -3771,7 +3778,7 @@ event_valid_msg (NMPlatform *platform, struct nl_msg *msg, gboolean handle_event
cache_prune_candidates_drop (platform, obj_cache);
}
-/******************************************************************/
+/*****************************************************************************/
static const NMPObject *
cache_lookup_link (NMPlatform *platform, int ifindex)
@@ -5224,7 +5231,7 @@ link_release (NMPlatform *platform, int master, int slave)
return link_enslave (platform, 0, slave);
}
-/******************************************************************/
+/*****************************************************************************/
static gboolean
_infiniband_partition_action (NMPlatform *platform,
@@ -5290,7 +5297,7 @@ infiniband_partition_delete (NMPlatform *platform, int parent, int p_key)
return _infiniband_partition_action (platform, INFINIBAND_ACTION_DELETE_CHILD, parent, p_key, NULL);
}
-/******************************************************************/
+/*****************************************************************************/
static WifiData *
wifi_get_wifi_data (NMPlatform *platform, int ifindex)
@@ -5421,7 +5428,7 @@ wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean ru
wifi_utils_indicate_addressing_running (wifi_data, running);
}
-/******************************************************************/
+/*****************************************************************************/
static gboolean
link_can_assume (NMPlatform *platform, int ifindex)
@@ -5464,7 +5471,7 @@ link_can_assume (NMPlatform *platform, int ifindex)
return FALSE;
}
-/******************************************************************/
+/*****************************************************************************/
static guint32
mesh_get_channel (NMPlatform *platform, int ifindex)
@@ -5487,7 +5494,7 @@ mesh_set_ssid (NMPlatform *platform, int ifindex, const guint8 *ssid, gsize len)
return wifi_utils_set_mesh_ssid (wifi_data, ssid, len);
}
-/******************************************************************/
+/*****************************************************************************/
static gboolean
link_get_wake_on_lan (NMPlatform *platform, int ifindex)
@@ -5529,7 +5536,7 @@ link_get_driver_info (NMPlatform *platform,
out_fw_version);
}
-/******************************************************************/
+/*****************************************************************************/
static GArray *
ipx_address_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type)
@@ -5694,7 +5701,7 @@ ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8
return NULL;
}
-/******************************************************************/
+/*****************************************************************************/
static GArray *
ipx_route_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type, NMPlatformGetRouteFlags flags)
@@ -5909,7 +5916,7 @@ ip6_route_get (NMPlatform *platform, int ifindex, struct in6_addr network, guint
return NULL;
}
-/******************************************************************/
+/*****************************************************************************/
#define EVENT_CONDITIONS ((GIOCondition) (G_IO_IN | G_IO_PRI))
#define ERROR_CONDITIONS ((GIOCondition) (G_IO_ERR | G_IO_NVAL))
@@ -6236,7 +6243,7 @@ after_read:
}
}
-/******************************************************************/
+/*****************************************************************************/
static void
cache_update_link_udev (NMPlatform *platform, int ifindex, GUdevDevice *udev_device)
@@ -6352,19 +6359,17 @@ handle_udev_event (GUdevClient *client,
udev_device_removed (platform, udev_device);
}
-/******************************************************************/
+/*****************************************************************************/
static void
nm_linux_platform_init (NMLinuxPlatform *self)
{
- NMLinuxPlatformPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_LINUX_PLATFORM, NMLinuxPlatformPrivate);
+ NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (self);
gboolean use_udev;
use_udev = nmp_netns_is_initial ()
&& access ("/sys", W_OK) == 0;
- self->priv = priv;
-
priv->nlh_seq_next = 1;
priv->cache = nmp_cache_new (use_udev);
priv->delayed_action.list_master_connected = g_ptr_array_new ();
@@ -6496,7 +6501,7 @@ dispose (GObject *object)
}
static void
-nm_linux_platform_finalize (GObject *object)
+finalize (GObject *object)
{
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (object);
@@ -6506,7 +6511,6 @@ nm_linux_platform_finalize (GObject *object)
g_ptr_array_unref (priv->delayed_action.list_refresh_link);
g_array_unref (priv->delayed_action.list_wait_for_nl_response);
- /* Free netlink resources */
g_source_remove (priv->event_id);
g_io_channel_unref (priv->event_channel);
nl_socket_free (priv->nlh);
@@ -6521,20 +6525,15 @@ nm_linux_platform_finalize (GObject *object)
G_OBJECT_CLASS (nm_linux_platform_parent_class)->finalize (object);
}
-#define OVERRIDE(function) platform_class->function = function
-
static void
nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMPlatformClass *platform_class = NM_PLATFORM_CLASS (klass);
- g_type_class_add_private (klass, sizeof (NMLinuxPlatformPrivate));
-
- /* virtual methods */
object_class->constructed = constructed;
object_class->dispose = dispose;
- object_class->finalize = nm_linux_platform_finalize;
+ object_class->finalize = finalize;
platform_class->sysctl_set = sysctl_set;
platform_class->sysctl_get = sysctl_get;