mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 11:30:15 +01:00
trivial: add nm_device_get_connection()
Shortcut to access the connection linked to the activation request of a device. The patch only replaces usage with nm_device_get_connection() if the existing code assumes that an activation request must be available. Signed-off-by: Thomas Graf <tgraf@redhat.com>
This commit is contained in:
parent
86d5a40677
commit
18088e0d07
7 changed files with 24 additions and 58 deletions
|
|
@ -844,15 +844,11 @@ static NMActStageReturn
|
|||
real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
||||
{
|
||||
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
|
||||
NMActRequest *req;
|
||||
NMDBusManager *dbus_mgr;
|
||||
DBusGConnection *g_connection;
|
||||
gboolean dun = FALSE;
|
||||
|
||||
req = nm_device_get_act_request (device);
|
||||
g_assert (req);
|
||||
|
||||
priv->bt_type = get_connection_bt_type (nm_act_request_get_connection (req));
|
||||
priv->bt_type = get_connection_bt_type (nm_device_get_connection (device));
|
||||
if (priv->bt_type == NM_BT_CAPABILITY_NONE) {
|
||||
// FIXME: set a reason code
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
|
|
|||
|
|
@ -873,7 +873,7 @@ build_supplicant_config (NMDeviceEthernet *self)
|
|||
NMSetting8021x *security;
|
||||
NMConnection *connection;
|
||||
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (NM_DEVICE (self)));
|
||||
connection = nm_device_get_connection (NM_DEVICE (self));
|
||||
g_return_val_if_fail (connection, NULL);
|
||||
con_path = nm_connection_get_path (connection);
|
||||
|
||||
|
|
@ -1148,7 +1148,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
|
|||
const char *iface;
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (NM_DEVICE (self)));
|
||||
connection = nm_device_get_connection (NM_DEVICE (self));
|
||||
security = nm_connection_get_setting_802_1x (connection);
|
||||
if (!security) {
|
||||
nm_log_err (LOGD_DEVICE, "Invalid or missing 802.1X security");
|
||||
|
|
@ -1319,7 +1319,7 @@ real_ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
|||
if (NM_DEVICE_ETHERNET_GET_PRIVATE (device)->ppp_manager)
|
||||
return;
|
||||
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (device));
|
||||
connection = nm_device_get_connection (device);
|
||||
g_assert (connection);
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
g_assert (s_wired);
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ real_ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
|
|||
NMSettingInfiniband *s_infiniband;
|
||||
guint32 mtu;
|
||||
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (self));
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
s_infiniband = nm_connection_get_setting_infiniband (connection);
|
||||
g_assert (s_infiniband);
|
||||
|
|
|
|||
|
|
@ -428,15 +428,11 @@ real_act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
|
||||
NMConnection *connection;
|
||||
NMSettingOlpcMesh *s_mesh;
|
||||
NMActRequest *req;
|
||||
guint32 channel;
|
||||
const GByteArray *anycast_addr_array;
|
||||
guint8 *anycast_addr = NULL;
|
||||
|
||||
req = nm_device_get_act_request (dev);
|
||||
g_assert (req);
|
||||
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (dev);
|
||||
g_assert (connection);
|
||||
|
||||
s_mesh = nm_connection_get_setting_olpc_mesh (connection);
|
||||
|
|
|
|||
|
|
@ -2690,7 +2690,7 @@ real_ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
|||
NMSettingWireless *s_wifi;
|
||||
guint32 mtu;
|
||||
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (device));
|
||||
connection = nm_device_get_connection (device);
|
||||
g_assert (connection);
|
||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
g_assert (s_wifi);
|
||||
|
|
@ -2780,15 +2780,12 @@ handle_ip_config_timeout (NMDeviceWifi *self,
|
|||
static NMActStageReturn
|
||||
real_act_stage4_ip4_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
|
||||
{
|
||||
NMActRequest *req;
|
||||
NMConnection *connection;
|
||||
NMSettingIP4Config *s_ip4;
|
||||
gboolean may_fail = FALSE, chain_up = FALSE;
|
||||
NMActStageReturn ret;
|
||||
|
||||
req = nm_device_get_act_request (dev);
|
||||
g_assert (req);
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (dev);
|
||||
g_assert (connection);
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
|
|
@ -2805,15 +2802,12 @@ real_act_stage4_ip4_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
static NMActStageReturn
|
||||
real_act_stage4_ip6_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
|
||||
{
|
||||
NMActRequest *req;
|
||||
NMConnection *connection;
|
||||
NMSettingIP6Config *s_ip6;
|
||||
gboolean may_fail = FALSE, chain_up = FALSE;
|
||||
NMActStageReturn ret;
|
||||
|
||||
req = nm_device_get_act_request (dev);
|
||||
g_assert (req);
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (dev);
|
||||
g_assert (connection);
|
||||
|
||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
|
|
@ -2902,13 +2896,9 @@ activation_failure_handler (NMDevice *dev)
|
|||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
NMAccessPoint *ap;
|
||||
const GByteArray * ssid;
|
||||
NMActRequest *req;
|
||||
NMConnection *connection;
|
||||
|
||||
req = nm_device_get_act_request (dev);
|
||||
g_assert (req);
|
||||
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (dev);
|
||||
g_assert (connection);
|
||||
|
||||
/* Clear wireless secrets tries on failure */
|
||||
|
|
|
|||
|
|
@ -826,16 +826,13 @@ activation_source_schedule (NMDevice *self, GSourceFunc func, int family)
|
|||
gboolean
|
||||
nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6)
|
||||
{
|
||||
NMActRequest *req;
|
||||
NMConnection *connection;
|
||||
NMSettingIP4Config *s_ip4;
|
||||
NMSettingIP6Config *s_ip6;
|
||||
|
||||
g_return_val_if_fail (self != NULL, TRUE);
|
||||
|
||||
req = nm_device_get_act_request (self);
|
||||
g_assert (req);
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
|
||||
/* Fail the connection if the failed IP method is required to complete */
|
||||
|
|
@ -1375,7 +1372,6 @@ static void
|
|||
dhcp4_lease_change (NMDevice *device, NMIP4Config *config)
|
||||
{
|
||||
NMConnection *connection;
|
||||
NMActRequest *req;
|
||||
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
||||
|
||||
if (config == NULL) {
|
||||
|
|
@ -1385,9 +1381,7 @@ dhcp4_lease_change (NMDevice *device, NMIP4Config *config)
|
|||
return;
|
||||
}
|
||||
|
||||
req = nm_device_get_act_request (device);
|
||||
g_assert (req);
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (device);
|
||||
g_assert (connection);
|
||||
|
||||
/* Merge with user overrides */
|
||||
|
|
@ -1533,7 +1527,6 @@ nm_device_dhcp4_renew (NMDevice *self, gboolean release)
|
|||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMActStageReturn ret;
|
||||
NMDeviceStateReason reason;
|
||||
NMActRequest *req;
|
||||
NMConnection *connection;
|
||||
|
||||
g_return_val_if_fail (priv->dhcp4_client != NULL, FALSE);
|
||||
|
|
@ -1544,9 +1537,7 @@ nm_device_dhcp4_renew (NMDevice *self, gboolean release)
|
|||
/* Terminate old DHCP instance and release the old lease */
|
||||
dhcp4_cleanup (self, TRUE, release);
|
||||
|
||||
req = nm_device_get_act_request (self);
|
||||
g_assert (req);
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
|
||||
/* Start DHCP again on the interface */
|
||||
|
|
@ -1624,14 +1615,13 @@ real_act_stage3_ip4_config_start (NMDevice *self,
|
|||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMConnection *connection;
|
||||
NMSettingIP4Config *s_ip4;
|
||||
NMActRequest *req;
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
||||
|
||||
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
req = nm_device_get_act_request (self);
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
|
||||
/* If we did not receive IP4 configuration information, default to DHCP */
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
|
|
@ -1720,8 +1710,7 @@ ip6_config_merge_and_apply (NMDevice *self,
|
|||
gboolean assumed, success;
|
||||
NMIP6Config *composite;
|
||||
|
||||
g_assert (priv->act_request);
|
||||
connection = nm_act_request_get_connection (priv->act_request);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
|
||||
/* If no config was passed in, create a new one */
|
||||
|
|
@ -1763,7 +1752,7 @@ dhcp6_lease_change (NMDevice *device)
|
|||
|
||||
g_assert (priv->dhcp6_client); /* sanity check */
|
||||
|
||||
connection = nm_act_request_get_connection (priv->act_request);
|
||||
connection = nm_device_get_connection (device);
|
||||
g_assert (connection);
|
||||
|
||||
/* Apply the updated config */
|
||||
|
|
@ -1875,8 +1864,7 @@ dhcp6_start (NMDevice *self,
|
|||
int err;
|
||||
|
||||
if (!connection) {
|
||||
g_assert (priv->act_request);
|
||||
connection = nm_act_request_get_connection (priv->act_request);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
}
|
||||
|
||||
|
|
@ -1954,7 +1942,7 @@ ip6_addrconf_complete (NMIP6Manager *ip6_manager,
|
|||
if (ifindex != nm_device_get_ip_ifindex (self))
|
||||
return;
|
||||
g_return_if_fail (priv->act_request != NULL);
|
||||
connection = nm_act_request_get_connection (priv->act_request);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
|
||||
if (!priv->ip6_waiting_for_config)
|
||||
|
|
@ -2048,8 +2036,7 @@ addrconf6_start (NMDevice *self)
|
|||
NMConnection *connection;
|
||||
gboolean success;
|
||||
|
||||
g_assert (priv->act_request);
|
||||
connection = nm_act_request_get_connection (priv->act_request);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
|
||||
g_warn_if_fail (priv->ac_ip6_config == NULL);
|
||||
|
|
@ -2121,14 +2108,11 @@ real_act_stage3_ip6_config_start (NMDevice *self,
|
|||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
const char *ip_iface;
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||
NMActRequest *req;
|
||||
NMConnection *connection;
|
||||
|
||||
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
req = nm_device_get_act_request (self);
|
||||
g_assert (req);
|
||||
connection = nm_act_request_get_connection (req);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
|
||||
ip_iface = nm_device_get_ip_iface (self);
|
||||
|
|
@ -2680,7 +2664,7 @@ fw_add_to_zone (NMDevice *self, gboolean ip4)
|
|||
}
|
||||
|
||||
/* Otherwise tell the firewall to add the interface to the specified zone */
|
||||
connection = nm_act_request_get_connection (priv->act_request);
|
||||
connection = nm_device_get_connection (self);
|
||||
g_assert (connection);
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
priv->fw_call = nm_firewall_manager_add_to_zone (priv->fw_manager,
|
||||
|
|
@ -3464,7 +3448,7 @@ dispose (GObject *object)
|
|||
NMSettingIP4Config *s_ip4 = NULL;
|
||||
const char *method = NULL;
|
||||
|
||||
connection = nm_act_request_get_connection (priv->act_request);
|
||||
connection = nm_device_get_connection (self);
|
||||
if (connection) {
|
||||
|
||||
/* Only static or DHCP IPv4 connections can be left up.
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||
iface = nm_device_get_iface (device);
|
||||
g_assert (iface);
|
||||
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (device));
|
||||
connection = nm_device_get_connection (device);
|
||||
g_assert (connection);
|
||||
|
||||
s_wimax = nm_connection_get_setting_wimax (connection);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue