summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/devices/adsl/nm-device-adsl.c7
-rw-r--r--src/devices/nm-device-ethernet.c57
-rw-r--r--src/devices/nm-device-infiniband.c9
-rw-r--r--src/devices/nm-device-macvlan.c10
-rw-r--r--src/devices/nm-device-tun.c10
-rw-r--r--src/devices/nm-device-vlan.c12
-rw-r--r--src/devices/nm-device-vxlan.c10
-rw-r--r--src/devices/nm-device.c20
-rw-r--r--src/devices/nm-device.h1
-rw-r--r--src/devices/team/nm-device-team.c5
10 files changed, 44 insertions, 97 deletions
diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c
index dd9a1203c1..57afcf463d 100644
--- a/src/devices/adsl/nm-device-adsl.c
+++ b/src/devices/adsl/nm-device-adsl.c
@@ -449,7 +449,6 @@ act_stage3_ip4_config_start (NMDevice *device,
{
NMDeviceAdsl *self = NM_DEVICE_ADSL (device);
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self);
- NMConnection *connection;
NMSettingAdsl *s_adsl;
NMActRequest *req;
GError *err = NULL;
@@ -458,11 +457,7 @@ act_stage3_ip4_config_start (NMDevice *device,
req = nm_device_get_act_request (device);
g_assert (req);
-
- connection = nm_act_request_get_applied_connection (req);
- g_assert (req);
-
- s_adsl = nm_connection_get_setting_adsl (connection);
+ s_adsl = (NMSettingAdsl *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
g_assert (s_adsl);
/* PPPoE uses the NAS interface, not the ATM interface */
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 91fd0f7396..6f8718a555 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -64,8 +64,6 @@ G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE)
#define PPPOE_RECONNECT_DELAY 7
#define PPPOE_ENCAP_OVERHEAD 8 /* 2 bytes for PPP, 6 for PPPoE */
-static NMSetting *device_get_setting (NMDevice *device, GType setting_type);
-
typedef struct Supplicant {
NMSupplicantManager *mgr;
NMSupplicantInterface *iface;
@@ -429,26 +427,6 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
return TRUE;
}
-/* FIXME: Move it to nm-device.c and then get rid of all foo_device_get_setting() all around.
- It's here now to keep the patch short. */
-static NMSetting *
-device_get_setting (NMDevice *device, GType setting_type)
-{
- NMActRequest *req;
- NMSetting *setting = NULL;
-
- req = nm_device_get_act_request (device);
- if (req) {
- NMConnection *connection;
-
- connection = nm_act_request_get_applied_connection (req);
- if (connection)
- setting = nm_connection_get_setting (connection, setting_type);
- }
-
- return setting;
-}
-
/*****************************************************************************/
/* 802.1X */
@@ -830,7 +808,6 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
{
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
- NMActRequest *req;
NMSettingWired *s_wired;
const char *cloned_mac;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
@@ -839,10 +816,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, reason);
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
- req = nm_device_get_act_request (NM_DEVICE (self));
- g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- s_wired = (NMSettingWired *) device_get_setting (dev, NM_TYPE_SETTING_WIRED);
+ s_wired = (NMSettingWired *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_WIRED);
if (s_wired) {
/* Set device MAC address if the connection wants to change it */
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
@@ -858,7 +832,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
if (priv->last_pppoe_time) {
gint32 delay = nm_utils_get_monotonic_timestamp_s () - priv->last_pppoe_time;
- if (delay < PPPOE_RECONNECT_DELAY && device_get_setting (dev, NM_TYPE_SETTING_PPPOE)) {
+ if ( delay < PPPOE_RECONNECT_DELAY
+ && nm_device_get_applied_setting (dev, NM_TYPE_SETTING_PPPOE)) {
_LOGI (LOGD_DEVICE, "delaying PPPoE reconnect for %d seconds to ensure peer is ready...",
delay);
g_assert (!priv->pppoe_wait_id);
@@ -960,7 +935,6 @@ static NMActStageReturn
pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reason)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
- NMConnection *connection;
NMSettingPppoe *s_pppoe;
NMActRequest *req;
GError *err = NULL;
@@ -969,10 +943,7 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas
req = nm_device_get_act_request (NM_DEVICE (self));
g_assert (req);
- connection = nm_act_request_get_applied_connection (req);
- g_assert (req);
-
- s_pppoe = nm_connection_get_setting_pppoe (connection);
+ s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_PPPOE);
g_assert (s_pppoe);
priv->ppp_manager = nm_ppp_manager_new (nm_device_get_iface (NM_DEVICE (self)));
@@ -1044,7 +1015,7 @@ dcb_configure (NMDevice *device)
dcb_timeout_cleanup (device);
- s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB);
+ s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
g_assert (s_dcb);
if (!nm_dcb_setup (nm_device_get_iface (device), s_dcb, &error)) {
_LOGW (LOGD_DCB, "Activation: (ethernet) failed to enable DCB/FCoE: %s",
@@ -1190,7 +1161,7 @@ wake_on_lan_enable (NMDevice *device)
const char *password = NULL;
gs_free char *value = NULL;
- s_wired = (NMSettingWired *) device_get_setting (device, NM_TYPE_SETTING_WIRED);
+ s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
if (s_wired) {
wol = nm_setting_wired_get_wake_on_lan (s_wired);
password = nm_setting_wired_get_wake_on_lan_password (s_wired);
@@ -1235,7 +1206,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
- s_con = NM_SETTING_CONNECTION (device_get_setting (device, NM_TYPE_SETTING_CONNECTION));
+ s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device,
+ NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
dcb_timeout_cleanup (device);
@@ -1248,7 +1220,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
NMSetting8021x *security;
- security = (NMSetting8021x *) device_get_setting (device, NM_TYPE_SETTING_802_1X);
+ security = (NMSetting8021x *) nm_device_get_applied_setting (device,
+ NM_TYPE_SETTING_802_1X);
if (security) {
/* FIXME: for now 802.1x is mutually exclusive with DCB */
return nm_8021x_stage2_config (self, reason);
@@ -1258,7 +1231,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
wake_on_lan_enable (device);
/* DCB and FCoE setup */
- s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB);
+ s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
if (s_dcb) {
/* lldpad really really wants the carrier to be up */
if (nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device))) {
@@ -1287,7 +1260,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
NM_SETTING_PPPOE_SETTING_NAME)) {
NMSettingPpp *s_ppp;
- s_ppp = (NMSettingPpp *) device_get_setting (device, NM_TYPE_SETTING_PPP);
+ s_ppp = (NMSettingPpp *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP);
if (s_ppp) {
guint32 mtu = 0, mru = 0, mxu;
@@ -1317,7 +1290,7 @@ act_stage3_ip4_config_start (NMDevice *device,
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
- s_con = NM_SETTING_CONNECTION (device_get_setting (device, NM_TYPE_SETTING_CONNECTION));
+ s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
connection_type = nm_setting_connection_get_connection_type (s_con);
@@ -1376,7 +1349,7 @@ deactivate (NMDevice *device)
dcb_carrier_cleanup (device);
/* Tear down DCB/FCoE if it was enabled */
- s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB);
+ s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
if (s_dcb) {
if (!nm_dcb_cleanup (nm_device_get_iface (device), &error)) {
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to disable DCB/FCoE: %s",
@@ -1386,7 +1359,7 @@ deactivate (NMDevice *device)
}
/* Set last PPPoE connection time */
- if (device_get_setting (device, NM_TYPE_SETTING_PPPOE))
+ if (nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE))
NM_DEVICE_ETHERNET_GET_PRIVATE (device)->last_pppoe_time = nm_utils_get_monotonic_timestamp_s ();
/* Reset MAC address back to initial address */
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index 789cf5f39f..c5e73c9920 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -69,8 +69,6 @@ static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
{
NMActStageReturn ret;
- NMActRequest *req;
- NMConnection *connection;
NMSettingInfiniband *s_infiniband;
const char *transport_mode;
char *mode_path;
@@ -82,12 +80,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
- req = nm_device_get_act_request (dev);
- g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- connection = nm_act_request_get_applied_connection (req);
- g_assert (connection);
- s_infiniband = nm_connection_get_setting_infiniband (connection);
+ s_infiniband = (NMSettingInfiniband *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_INFINIBAND);
g_assert (s_infiniband);
transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband);
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c
index 01e5b6ab6b..e8d8b4e193 100644
--- a/src/devices/nm-device-macvlan.c
+++ b/src/devices/nm-device-macvlan.c
@@ -502,8 +502,6 @@ update_connection (NMDevice *device, NMConnection *connection)
static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
{
- NMActRequest *req;
- NMConnection *connection;
NMSettingWired *s_wired;
const char *cloned_mac;
NMActStageReturn ret;
@@ -514,13 +512,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
- req = nm_device_get_act_request (dev);
- g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- connection = nm_act_request_get_applied_connection (req);
- g_return_val_if_fail (connection != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- s_wired = nm_connection_get_setting_wired (connection);
+ s_wired = (NMSettingWired *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_WIRED);
if (s_wired) {
/* Set device MAC address if the connection wants to change it */
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c
index 011cac0022..863ee2eff8 100644
--- a/src/devices/nm-device-tun.c
+++ b/src/devices/nm-device-tun.c
@@ -285,8 +285,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
{
NMDeviceTun *self = NM_DEVICE_TUN (device);
NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self);
- NMActRequest *req;
- NMConnection *connection;
NMSettingWired *s_wired;
const char *cloned_mac;
NMActStageReturn ret;
@@ -301,13 +299,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
if (g_strcmp0 (priv->mode, "tap"))
return NM_ACT_STAGE_RETURN_SUCCESS;
- req = nm_device_get_act_request (device);
- g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- connection = nm_act_request_get_applied_connection (req);
- g_return_val_if_fail (connection != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- s_wired = nm_connection_get_setting_wired (connection);
+ s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
if (s_wired) {
/* Set device MAC address if the connection wants to change it */
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index dfd7a8addf..2c48f5b2f7 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -546,8 +546,6 @@ update_connection (NMDevice *device, NMConnection *connection)
static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
{
- NMActRequest *req;
- NMConnection *connection;
NMSettingVlan *s_vlan;
NMSettingWired *s_wired;
const char *cloned_mac;
@@ -559,13 +557,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
- req = nm_device_get_act_request (dev);
- g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- connection = nm_act_request_get_applied_connection (req);
- g_return_val_if_fail (connection != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- s_wired = nm_connection_get_setting_wired (connection);
+ s_wired = (NMSettingWired *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_WIRED);
if (s_wired) {
/* Set device MAC address if the connection wants to change it */
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
@@ -573,7 +565,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_VLAN);
}
- s_vlan = nm_connection_get_setting_vlan (connection);
+ s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_VLAN);
if (s_vlan) {
gs_free NMVlanQosMapping *ingress_map = NULL;
gs_free NMVlanQosMapping *egress_map = NULL;
diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c
index 4e5e48f9ea..08f0f69881 100644
--- a/src/devices/nm-device-vxlan.c
+++ b/src/devices/nm-device-vxlan.c
@@ -510,8 +510,6 @@ update_connection (NMDevice *device, NMConnection *connection)
static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
{
- NMActRequest *req;
- NMConnection *connection;
NMSettingWired *s_wired;
const char *cloned_mac;
NMActStageReturn ret;
@@ -522,13 +520,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
- req = nm_device_get_act_request (device);
- g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- connection = nm_act_request_get_applied_connection (req);
- g_return_val_if_fail (connection != NULL, NM_ACT_STAGE_RETURN_FAILURE);
-
- s_wired = nm_connection_get_setting_wired (connection);
+ s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
if (s_wired) {
/* Set device MAC address if the connection wants to change it */
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index dd25c4b1a0..cb575a763f 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -996,6 +996,26 @@ nm_device_has_unmodified_applied_connection (NMDevice *self, NMSettingCompareFla
return nm_active_connection_has_unmodified_applied_connection ((NMActiveConnection *) priv->act_request, compare_flags);
}
+NMSetting *
+nm_device_get_applied_setting (NMDevice *device, GType setting_type)
+{
+ NMActRequest *req;
+ NMSetting *setting = NULL;
+
+ g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
+
+ req = nm_device_get_act_request (device);
+ if (req) {
+ NMConnection *connection;
+
+ connection = nm_act_request_get_applied_connection (req);
+ if (connection)
+ setting = nm_connection_get_setting (connection, setting_type);
+ }
+
+ return setting;
+}
+
RfKillType
nm_device_get_rfkill_type (NMDevice *self)
{
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index c56dfde8ba..2d168f6df9 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -377,6 +377,7 @@ NMSettingsConnection * nm_device_get_settings_connection (NMDevice *dev);
NMConnection * nm_device_get_applied_connection (NMDevice *dev);
gboolean nm_device_has_unmodified_applied_connection (NMDevice *self,
NMSettingCompareFlags compare_flags);
+NMSetting * nm_device_get_applied_setting (NMDevice *dev, GType setting_type);
void nm_device_removed (NMDevice *dev);
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 97b9065f58..0fc3164313 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -502,7 +502,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
gs_free_error GError *error = NULL;
- NMConnection *connection;
NMSettingTeam *s_team;
const char *cfg;
@@ -512,9 +511,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
- connection = nm_device_get_applied_connection (device);
- g_assert (connection);
- s_team = nm_connection_get_setting_team (connection);
+ s_team = (NMSettingTeam *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_TEAM);
g_assert (s_team);
if (priv->tdc) {