2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-09-25 13:13:40 +02:00
|
|
|
/*
|
2012-02-03 14:53:09 -06:00
|
|
|
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
2008-03-26 13:43:01 +00:00
|
|
|
*/
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#ifndef __NETWORKMANAGER_ACTIVE_CONNECTION_H__
|
|
|
|
|
#define __NETWORKMANAGER_ACTIVE_CONNECTION_H__
|
2008-03-26 13:43:01 +00:00
|
|
|
|
2018-04-06 16:40:23 +02:00
|
|
|
#include "c-list/src/c-list.h"
|
core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API
Previously, we used the generated GDBusInterfaceSkeleton types and glued
them via the NMExportedObject base class to our NM types. We also used
GDBusObjectManagerServer.
Don't do that anymore. The resulting code was more complicated despite (or
because?) using generated classes. It was hard to understand, complex, had
ordering-issues, and had a runtime and memory overhead.
This patch refactors this entirely and uses the lower layer API GDBusConnection
directly. It replaces the generated code, GDBusInterfaceSkeleton, and
GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager
and static descriptor instances of type GDBusInterfaceInfo.
This adds a net plus of more then 1300 lines of hand written code. I claim
that this implementation is easier to understand. Note that previously we
also required extensive and complex glue code to bind our objects to the
generated skeleton objects. Instead, now glue our objects directly to
GDBusConnection. The result is more immediate and gets rid of layers of
code in between.
Now that the D-Bus glue us more under our control, we can address issus and
bottlenecks better, instead of adding code to bend the generated skeletons
to our needs.
Note that the current implementation now only supports one D-Bus connection.
That was effectively the case already, although there were places (and still are)
where the code pretends it could also support connections from a private socket.
We dropped private socket support mainly because it was unused, untested and
buggy, but also because GDBusObjectManagerServer could not export the same
objects on multiple connections. Now, it would be rather straight forward to
fix that and re-introduce ObjectManager on each private connection. But this
commit doesn't do that yet, and the new code intentionally supports only one
D-Bus connection.
Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start()
succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to
connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough
for the moment. It could be easily extended later, for example with polling whether the
system bus appears (like was done previously). Also, restart of D-Bus daemon isn't
supported either -- just like before.
Note how NMDBusManager now implements the ObjectManager D-Bus interface
directly.
Also, this fixes race issues in the server, by no longer delaying
PropertiesChanged signals. NMExportedObject would collect changed
properties and send the signal out in idle_emit_properties_changed()
on idle. This messes up the ordering of change events w.r.t. other
signals and events on the bus. Note that not only NMExportedObject
messed up the ordering. Also the generated code would hook into
notify() and process change events in and idle handle, exhibiting the
same ordering issue too.
No longer do that. PropertiesChanged signals will be sent right away
by hooking into dispatch_properties_changed(). This means, changing
a property in quick succession will no longer be combined and is
guaranteed to emit signals for each individual state. Quite possibly
we emit now more PropertiesChanged signals then before.
However, we are now able to group a set of changes by using standard
g_object_freeze_notify()/g_object_thaw_notify(). We probably should
make more use of that.
Also, now that our signals are all handled in the right order, we
might find places where we still emit them in the wrong order. But that
is then due to the order in which our GObjects emit signals, not due
to an ill behavior of the D-Bus glue. Possibly we need to identify
such ordering issues and fix them.
Numbers (for contrib/rpm --without debug on x86_64):
- the patch changes the code size of NetworkManager by
- 2809360 bytes
+ 2537528 bytes (-9.7%)
- Runtime measurements are harder because there is a large variance
during testing. In other words, the numbers are not reproducible.
Currently, the implementation performs no caching of GVariants at all,
but it would be rather simple to add it, if that turns out to be
useful.
Anyway, without strong claim, it seems that the new form tends to
perform slightly better. That would be no surprise.
$ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .; done)
- real 1m39.355s
+ real 1m37.432s
$ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done)
- real 0m26.843s
+ real 0m25.281s
- Regarding RSS size, just looking at the processes in similar
conditions, doesn't give a large difference. On my system they
consume about 19MB RSS. It seems that the new version has a
slightly smaller RSS size.
- 19356 RSS
+ 18660 RSS
2018-02-26 13:51:52 +01:00
|
|
|
#include "nm-connection.h"
|
|
|
|
|
#include "nm-dbus-object.h"
|
2017-11-23 21:30:09 +01:00
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_TYPE_ACTIVE_CONNECTION (nm_active_connection_get_type())
|
|
|
|
|
#define NM_ACTIVE_CONNECTION(obj) \
|
2022-12-14 16:21:48 +01:00
|
|
|
(_NM_G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnection))
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_ACTIVE_CONNECTION_CLASS(klass) \
|
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
|
|
|
|
|
#define NM_IS_ACTIVE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_ACTIVE_CONNECTION))
|
2012-07-27 13:15:54 +02:00
|
|
|
#define NM_IS_ACTIVE_CONNECTION_CLASS(klass) \
|
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_ACTIVE_CONNECTION))
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_ACTIVE_CONNECTION_GET_CLASS(obj) \
|
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
/* D-Bus Exported Properties */
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_ACTIVE_CONNECTION_CONNECTION "connection"
|
2014-03-03 15:01:36 +01:00
|
|
|
#define NM_ACTIVE_CONNECTION_ID "id"
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_ACTIVE_CONNECTION_UUID "uuid"
|
2014-03-03 15:01:36 +01:00
|
|
|
#define NM_ACTIVE_CONNECTION_TYPE "type"
|
2008-03-26 13:43:01 +00:00
|
|
|
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_STATE "state"
|
2017-09-25 19:06:02 +02:00
|
|
|
#define NM_ACTIVE_CONNECTION_STATE_FLAGS "state-flags"
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
|
2013-12-18 08:46:43 -05:00
|
|
|
#define NM_ACTIVE_CONNECTION_IP4_CONFIG "ip4-config"
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_DHCP4_CONFIG "dhcp4-config"
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
|
2013-12-18 08:46:43 -05:00
|
|
|
#define NM_ACTIVE_CONNECTION_IP6_CONFIG "ip6-config"
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_DHCP6_CONFIG "dhcp6-config"
|
2012-02-03 14:53:09 -06:00
|
|
|
#define NM_ACTIVE_CONNECTION_VPN "vpn"
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_MASTER "master"
|
2023-01-17 10:22:04 -05:00
|
|
|
#define NM_ACTIVE_CONNECTION_CONTROLLER "controller"
|
2012-02-03 14:53:09 -06:00
|
|
|
|
2013-09-16 17:43:31 -05:00
|
|
|
/* Internal non-exported properties */
|
2015-07-14 16:53:24 +02:00
|
|
|
#define NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION "int-settings-connection"
|
2016-09-07 17:47:26 +02:00
|
|
|
#define NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION "int-applied-connection"
|
2018-03-28 17:18:04 +02:00
|
|
|
#define NM_ACTIVE_CONNECTION_INT_DEVICE "int-device"
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_INT_SUBJECT "int-subject"
|
2024-03-11 12:13:57 +01:00
|
|
|
#define NM_ACTIVE_CONNECTION_INT_CONTROLLER "int-controller"
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_INT_CONTROLLER_READY "int-controller-ready"
|
2018-03-28 17:18:04 +02:00
|
|
|
#define NM_ACTIVE_CONNECTION_INT_ACTIVATION_TYPE "int-activation-type"
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_INT_ACTIVATION_REASON "int-activation-reason"
|
2012-08-22 09:38:01 -05:00
|
|
|
|
2017-03-05 15:30:24 +01:00
|
|
|
/* Signals */
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_STATE_CHANGED "state-changed"
|
|
|
|
|
|
2014-10-23 17:04:49 -05:00
|
|
|
/* Internal signals*/
|
2015-06-03 09:15:24 +02:00
|
|
|
#define NM_ACTIVE_CONNECTION_DEVICE_CHANGED "device-changed"
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED "device-metered-changed"
|
2016-03-23 14:47:02 +01:00
|
|
|
#define NM_ACTIVE_CONNECTION_PARENT_ACTIVE "parent-active"
|
2014-10-23 17:04:49 -05:00
|
|
|
|
2016-09-28 15:58:24 +02:00
|
|
|
struct _NMActiveConnectionPrivate;
|
|
|
|
|
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMActiveConnection {
|
core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API
Previously, we used the generated GDBusInterfaceSkeleton types and glued
them via the NMExportedObject base class to our NM types. We also used
GDBusObjectManagerServer.
Don't do that anymore. The resulting code was more complicated despite (or
because?) using generated classes. It was hard to understand, complex, had
ordering-issues, and had a runtime and memory overhead.
This patch refactors this entirely and uses the lower layer API GDBusConnection
directly. It replaces the generated code, GDBusInterfaceSkeleton, and
GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager
and static descriptor instances of type GDBusInterfaceInfo.
This adds a net plus of more then 1300 lines of hand written code. I claim
that this implementation is easier to understand. Note that previously we
also required extensive and complex glue code to bind our objects to the
generated skeleton objects. Instead, now glue our objects directly to
GDBusConnection. The result is more immediate and gets rid of layers of
code in between.
Now that the D-Bus glue us more under our control, we can address issus and
bottlenecks better, instead of adding code to bend the generated skeletons
to our needs.
Note that the current implementation now only supports one D-Bus connection.
That was effectively the case already, although there were places (and still are)
where the code pretends it could also support connections from a private socket.
We dropped private socket support mainly because it was unused, untested and
buggy, but also because GDBusObjectManagerServer could not export the same
objects on multiple connections. Now, it would be rather straight forward to
fix that and re-introduce ObjectManager on each private connection. But this
commit doesn't do that yet, and the new code intentionally supports only one
D-Bus connection.
Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start()
succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to
connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough
for the moment. It could be easily extended later, for example with polling whether the
system bus appears (like was done previously). Also, restart of D-Bus daemon isn't
supported either -- just like before.
Note how NMDBusManager now implements the ObjectManager D-Bus interface
directly.
Also, this fixes race issues in the server, by no longer delaying
PropertiesChanged signals. NMExportedObject would collect changed
properties and send the signal out in idle_emit_properties_changed()
on idle. This messes up the ordering of change events w.r.t. other
signals and events on the bus. Note that not only NMExportedObject
messed up the ordering. Also the generated code would hook into
notify() and process change events in and idle handle, exhibiting the
same ordering issue too.
No longer do that. PropertiesChanged signals will be sent right away
by hooking into dispatch_properties_changed(). This means, changing
a property in quick succession will no longer be combined and is
guaranteed to emit signals for each individual state. Quite possibly
we emit now more PropertiesChanged signals then before.
However, we are now able to group a set of changes by using standard
g_object_freeze_notify()/g_object_thaw_notify(). We probably should
make more use of that.
Also, now that our signals are all handled in the right order, we
might find places where we still emit them in the wrong order. But that
is then due to the order in which our GObjects emit signals, not due
to an ill behavior of the D-Bus glue. Possibly we need to identify
such ordering issues and fix them.
Numbers (for contrib/rpm --without debug on x86_64):
- the patch changes the code size of NetworkManager by
- 2809360 bytes
+ 2537528 bytes (-9.7%)
- Runtime measurements are harder because there is a large variance
during testing. In other words, the numbers are not reproducible.
Currently, the implementation performs no caching of GVariants at all,
but it would be rather simple to add it, if that turns out to be
useful.
Anyway, without strong claim, it seems that the new form tends to
perform slightly better. That would be no surprise.
$ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .; done)
- real 1m39.355s
+ real 1m37.432s
$ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done)
- real 0m26.843s
+ real 0m25.281s
- Regarding RSS size, just looking at the processes in similar
conditions, doesn't give a large difference. On my system they
consume about 19MB RSS. It seems that the new version has a
slightly smaller RSS size.
- 19356 RSS
+ 18660 RSS
2018-02-26 13:51:52 +01:00
|
|
|
NMDBusObject parent;
|
2016-09-28 15:58:24 +02:00
|
|
|
struct _NMActiveConnectionPrivate *_priv;
|
2017-11-23 21:30:09 +01:00
|
|
|
|
|
|
|
|
/* active connection can be tracked in a list by NMManager. This is
|
|
|
|
|
* the list node. */
|
|
|
|
|
CList active_connections_lst;
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2012-02-03 14:53:09 -06:00
|
|
|
|
|
|
|
|
typedef struct {
|
core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API
Previously, we used the generated GDBusInterfaceSkeleton types and glued
them via the NMExportedObject base class to our NM types. We also used
GDBusObjectManagerServer.
Don't do that anymore. The resulting code was more complicated despite (or
because?) using generated classes. It was hard to understand, complex, had
ordering-issues, and had a runtime and memory overhead.
This patch refactors this entirely and uses the lower layer API GDBusConnection
directly. It replaces the generated code, GDBusInterfaceSkeleton, and
GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager
and static descriptor instances of type GDBusInterfaceInfo.
This adds a net plus of more then 1300 lines of hand written code. I claim
that this implementation is easier to understand. Note that previously we
also required extensive and complex glue code to bind our objects to the
generated skeleton objects. Instead, now glue our objects directly to
GDBusConnection. The result is more immediate and gets rid of layers of
code in between.
Now that the D-Bus glue us more under our control, we can address issus and
bottlenecks better, instead of adding code to bend the generated skeletons
to our needs.
Note that the current implementation now only supports one D-Bus connection.
That was effectively the case already, although there were places (and still are)
where the code pretends it could also support connections from a private socket.
We dropped private socket support mainly because it was unused, untested and
buggy, but also because GDBusObjectManagerServer could not export the same
objects on multiple connections. Now, it would be rather straight forward to
fix that and re-introduce ObjectManager on each private connection. But this
commit doesn't do that yet, and the new code intentionally supports only one
D-Bus connection.
Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start()
succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to
connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough
for the moment. It could be easily extended later, for example with polling whether the
system bus appears (like was done previously). Also, restart of D-Bus daemon isn't
supported either -- just like before.
Note how NMDBusManager now implements the ObjectManager D-Bus interface
directly.
Also, this fixes race issues in the server, by no longer delaying
PropertiesChanged signals. NMExportedObject would collect changed
properties and send the signal out in idle_emit_properties_changed()
on idle. This messes up the ordering of change events w.r.t. other
signals and events on the bus. Note that not only NMExportedObject
messed up the ordering. Also the generated code would hook into
notify() and process change events in and idle handle, exhibiting the
same ordering issue too.
No longer do that. PropertiesChanged signals will be sent right away
by hooking into dispatch_properties_changed(). This means, changing
a property in quick succession will no longer be combined and is
guaranteed to emit signals for each individual state. Quite possibly
we emit now more PropertiesChanged signals then before.
However, we are now able to group a set of changes by using standard
g_object_freeze_notify()/g_object_thaw_notify(). We probably should
make more use of that.
Also, now that our signals are all handled in the right order, we
might find places where we still emit them in the wrong order. But that
is then due to the order in which our GObjects emit signals, not due
to an ill behavior of the D-Bus glue. Possibly we need to identify
such ordering issues and fix them.
Numbers (for contrib/rpm --without debug on x86_64):
- the patch changes the code size of NetworkManager by
- 2809360 bytes
+ 2537528 bytes (-9.7%)
- Runtime measurements are harder because there is a large variance
during testing. In other words, the numbers are not reproducible.
Currently, the implementation performs no caching of GVariants at all,
but it would be rather simple to add it, if that turns out to be
useful.
Anyway, without strong claim, it seems that the new form tends to
perform slightly better. That would be no surprise.
$ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .; done)
- real 1m39.355s
+ real 1m37.432s
$ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done)
- real 0m26.843s
+ real 0m25.281s
- Regarding RSS size, just looking at the processes in similar
conditions, doesn't give a large difference. On my system they
consume about 19MB RSS. It seems that the new version has a
slightly smaller RSS size.
- 19356 RSS
+ 18660 RSS
2018-02-26 13:51:52 +01:00
|
|
|
NMDBusObjectClass parent;
|
2013-08-28 09:08:43 -05:00
|
|
|
|
2013-09-27 14:40:18 -05:00
|
|
|
/* re-emits device state changes as a convenience for subclasses for
|
|
|
|
|
* device states >= DISCONNECTED.
|
|
|
|
|
*/
|
|
|
|
|
void (*device_state_changed)(NMActiveConnection *connection,
|
2021-11-09 13:28:54 +01:00
|
|
|
NMDevice *device,
|
2013-09-27 14:40:18 -05:00
|
|
|
NMDeviceState new_state,
|
2023-10-21 22:22:15 +02:00
|
|
|
NMDeviceState old_state,
|
|
|
|
|
NMDeviceStateReason reason);
|
2024-05-27 17:58:08 +02:00
|
|
|
void (*controller_failed)(NMActiveConnection *connection);
|
2014-10-23 17:04:49 -05:00
|
|
|
|
|
|
|
|
void (*device_changed)(NMActiveConnection *connection,
|
2021-11-09 13:28:54 +01:00
|
|
|
NMDevice *new_device,
|
|
|
|
|
NMDevice *old_device);
|
2015-06-03 09:15:24 +02:00
|
|
|
|
|
|
|
|
void (*device_metered_changed)(NMActiveConnection *connection, NMMetered new_value);
|
2016-03-23 14:47:02 +01:00
|
|
|
|
|
|
|
|
void (*parent_active)(NMActiveConnection *connection);
|
2012-02-03 14:53:09 -06:00
|
|
|
} NMActiveConnectionClass;
|
|
|
|
|
|
2016-02-11 08:36:39 +01:00
|
|
|
guint64 nm_active_connection_version_id_get(NMActiveConnection *self);
|
|
|
|
|
guint64 nm_active_connection_version_id_bump(NMActiveConnection *self);
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
GType nm_active_connection_get_type(void);
|
|
|
|
|
|
2012-09-17 10:53:41 -05:00
|
|
|
typedef void (*NMActiveConnectionAuthResultFunc)(NMActiveConnection *self,
|
|
|
|
|
gboolean success,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *error_desc,
|
2018-04-17 14:59:27 +02:00
|
|
|
gpointer user_data);
|
2012-09-17 10:53:41 -05:00
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void nm_active_connection_authorize(NMActiveConnection *self,
|
|
|
|
|
NMConnection *initial_connection,
|
2012-09-17 10:53:41 -05:00
|
|
|
NMActiveConnectionAuthResultFunc result_func,
|
2018-04-17 14:59:27 +02:00
|
|
|
gpointer user_data);
|
2012-09-17 10:53:41 -05:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
NMSettingsConnection *nm_active_connection_get_settings_connection(NMActiveConnection *self);
|
2021-11-09 13:28:54 +01:00
|
|
|
NMConnection *nm_active_connection_get_applied_connection(NMActiveConnection *self);
|
2012-09-17 10:53:41 -05:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
NMSettingsConnection *_nm_active_connection_get_settings_connection(NMActiveConnection *self);
|
2013-08-28 11:43:50 -05:00
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void nm_active_connection_set_settings_connection(NMActiveConnection *self,
|
2015-07-14 16:53:24 +02:00
|
|
|
NMSettingsConnection *connection);
|
2012-02-03 14:53:09 -06:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
gboolean
|
2021-11-09 13:28:54 +01:00
|
|
|
nm_active_connection_has_unmodified_applied_connection(NMActiveConnection *self,
|
2015-07-14 16:53:24 +02:00
|
|
|
NMSettingCompareFlags compare_flags);
|
2014-03-03 15:01:36 +01:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
const char *nm_active_connection_get_settings_connection_id(NMActiveConnection *self);
|
2014-03-03 15:01:36 +01:00
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
const char *nm_active_connection_get_specific_object(NMActiveConnection *self);
|
|
|
|
|
|
|
|
|
|
void nm_active_connection_set_specific_object(NMActiveConnection *self,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *specific_object);
|
2012-02-03 14:53:09 -06:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_active_connection_set_default(NMActiveConnection *self, int addr_family, gboolean is_default);
|
|
|
|
|
|
2017-11-23 21:53:04 +01:00
|
|
|
gboolean nm_active_connection_get_default(NMActiveConnection *self, int addr_family);
|
2012-02-03 14:53:09 -06:00
|
|
|
|
2012-02-26 17:38:41 -06:00
|
|
|
NMActiveConnectionState nm_active_connection_get_state(NMActiveConnection *self);
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void nm_active_connection_set_state(NMActiveConnection *self,
|
2017-03-05 15:30:24 +01:00
|
|
|
NMActiveConnectionState state,
|
|
|
|
|
NMActiveConnectionStateReason reason);
|
2008-03-26 13:43:01 +00:00
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void nm_active_connection_set_state_fail(NMActiveConnection *active,
|
2018-02-05 16:36:24 +01:00
|
|
|
NMActiveConnectionStateReason reason,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *error_desc);
|
2018-02-05 16:36:24 +01:00
|
|
|
|
2021-08-06 15:17:05 +02:00
|
|
|
#define NM_ACTIVATION_STATE_FLAG_IP_READY_X(IS_IPv4) \
|
|
|
|
|
((IS_IPv4) ? NM_ACTIVATION_STATE_FLAG_IP4_READY : NM_ACTIVATION_STATE_FLAG_IP6_READY)
|
|
|
|
|
|
2017-09-25 19:06:02 +02:00
|
|
|
NMActivationStateFlags nm_active_connection_get_state_flags(NMActiveConnection *self);
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void nm_active_connection_set_state_flags_full(NMActiveConnection *self,
|
2017-09-25 19:06:02 +02:00
|
|
|
NMActivationStateFlags state_flags,
|
|
|
|
|
NMActivationStateFlags mask);
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
nm_active_connection_set_state_flags(NMActiveConnection *self, NMActivationStateFlags state_flags)
|
|
|
|
|
{
|
|
|
|
|
nm_active_connection_set_state_flags_full(self, state_flags, state_flags);
|
|
|
|
|
}
|
|
|
|
|
|
core: improve and fix keeping connection active based on "connection.permissions"
By setting "connection.permissions", a profile is restricted to a
particular user.
That means for example, that another user cannot see, modify, delete,
activate or deactivate the profile. It also means, that the profile
will only autoconnect when the user is logged in (has a session).
Note that root is always able to activate the profile. Likewise, the
user is also allowed to manually activate the own profile, even if no
session currently exists (which can easily happen with `sudo`).
When the user logs out (the session goes away), we want do disconnect
the profile, however there are conflicting goals here:
1) if the profile was activate by root user, then logging out the user
should not disconnect the profile. The patch fixes that by not
binding the activation to the connection, if the activation is done
by the root user.
2) if the profile was activated by the owner when it had no session,
then it should stay alive until the user logs in (once) and logs
out again. This is already handled by the previous commit.
Yes, this point is odd. If you first do
$ sudo -u $OTHER_USER nmcli connection up $PROFILE
the profile activates despite not having a session. If you then
$ ssh guest@localhost nmcli device
you'll still see the profile active. However, the moment the SSH session
ends, a session closes and the profile disconnects. It's unclear, how to
solve that any better. I think, a user who cares about this, should not
activate the profile without having a session in the first place.
There are quite some special cases, in particular with internal
activations. In those cases we need to decide whether to bind the
activation to the profile's visibility.
Also, expose the "bind" setting in the D-Bus API. Note, that in the future
this flag may be modified via D-Bus API. Like we may also add related API
that allows to tweak the lifetime of the activation.
Also, I think we broke handling of connection visiblity with 37e8c53eeed
"core: Introduce helper class to track connection keep alive". This
should be fixed now too, with improved behavior.
Fixes: 37e8c53eeed579fe34a68819cd12f3295d581394
https://bugzilla.redhat.com/show_bug.cgi?id=1530977
2018-11-21 13:30:16 +01:00
|
|
|
static inline void
|
2021-11-09 13:28:54 +01:00
|
|
|
nm_active_connection_set_state_flags_clear(NMActiveConnection *self,
|
core: improve and fix keeping connection active based on "connection.permissions"
By setting "connection.permissions", a profile is restricted to a
particular user.
That means for example, that another user cannot see, modify, delete,
activate or deactivate the profile. It also means, that the profile
will only autoconnect when the user is logged in (has a session).
Note that root is always able to activate the profile. Likewise, the
user is also allowed to manually activate the own profile, even if no
session currently exists (which can easily happen with `sudo`).
When the user logs out (the session goes away), we want do disconnect
the profile, however there are conflicting goals here:
1) if the profile was activate by root user, then logging out the user
should not disconnect the profile. The patch fixes that by not
binding the activation to the connection, if the activation is done
by the root user.
2) if the profile was activated by the owner when it had no session,
then it should stay alive until the user logs in (once) and logs
out again. This is already handled by the previous commit.
Yes, this point is odd. If you first do
$ sudo -u $OTHER_USER nmcli connection up $PROFILE
the profile activates despite not having a session. If you then
$ ssh guest@localhost nmcli device
you'll still see the profile active. However, the moment the SSH session
ends, a session closes and the profile disconnects. It's unclear, how to
solve that any better. I think, a user who cares about this, should not
activate the profile without having a session in the first place.
There are quite some special cases, in particular with internal
activations. In those cases we need to decide whether to bind the
activation to the profile's visibility.
Also, expose the "bind" setting in the D-Bus API. Note, that in the future
this flag may be modified via D-Bus API. Like we may also add related API
that allows to tweak the lifetime of the activation.
Also, I think we broke handling of connection visiblity with 37e8c53eeed
"core: Introduce helper class to track connection keep alive". This
should be fixed now too, with improved behavior.
Fixes: 37e8c53eeed579fe34a68819cd12f3295d581394
https://bugzilla.redhat.com/show_bug.cgi?id=1530977
2018-11-21 13:30:16 +01:00
|
|
|
NMActivationStateFlags state_flags)
|
|
|
|
|
{
|
|
|
|
|
nm_active_connection_set_state_flags_full(self, NM_ACTIVATION_STATE_FLAG_NONE, state_flags);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
NMDevice *nm_active_connection_get_device(NMActiveConnection *self);
|
|
|
|
|
|
2013-09-16 17:43:31 -05:00
|
|
|
gboolean nm_active_connection_set_device(NMActiveConnection *self, NMDevice *device);
|
|
|
|
|
|
2013-07-29 13:11:47 -05:00
|
|
|
NMAuthSubject *nm_active_connection_get_subject(NMActiveConnection *self);
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
gboolean nm_active_connection_get_user_requested(NMActiveConnection *self);
|
|
|
|
|
|
2024-03-11 12:13:57 +01:00
|
|
|
NMActiveConnection *nm_active_connection_get_controller(NMActiveConnection *self);
|
2012-08-22 09:38:01 -05:00
|
|
|
|
2024-03-11 12:13:57 +01:00
|
|
|
gboolean nm_active_connection_get_controller_ready(NMActiveConnection *self);
|
2013-09-27 17:13:43 -05:00
|
|
|
|
2024-03-11 12:13:57 +01:00
|
|
|
void nm_active_connection_set_controller(NMActiveConnection *self, NMActiveConnection *controller);
|
2024-05-14 11:39:21 +08:00
|
|
|
void nm_active_connection_set_controller_dev(NMActiveConnection *self, NMDevice *controller_dev);
|
2013-07-29 16:26:09 -05:00
|
|
|
|
2016-03-23 14:47:02 +01:00
|
|
|
void nm_active_connection_set_parent(NMActiveConnection *self, NMActiveConnection *parent);
|
|
|
|
|
|
2017-03-07 11:04:36 +01:00
|
|
|
NMActivationType nm_active_connection_get_activation_type(NMActiveConnection *self);
|
|
|
|
|
|
2018-03-28 17:18:04 +02:00
|
|
|
NMActivationReason nm_active_connection_get_activation_reason(NMActiveConnection *self);
|
|
|
|
|
|
2018-11-20 14:51:22 +01:00
|
|
|
NMKeepAlive *nm_active_connection_get_keep_alive(NMActiveConnection *self);
|
2018-10-10 17:10:01 +02:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
void nm_active_connection_clear_secrets(NMActiveConnection *self);
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#endif /* __NETWORKMANAGER_ACTIVE_CONNECTION_H__ */
|