mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-19 19:30:40 +02:00
core,libnm: merge branch 'th/setting-hash'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/29
This commit is contained in:
commit
9edc4f0c2f
16 changed files with 128 additions and 83 deletions
|
|
@ -75,6 +75,22 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gpointer
|
||||
_gtype_to_hash_key (GType gtype)
|
||||
{
|
||||
#if NM_MORE_ASSERTS
|
||||
_nm_unused const gsize *const test_gtype_typedef = >ype;
|
||||
|
||||
nm_assert ((GType) (GPOINTER_TO_SIZE (GSIZE_TO_POINTER (gtype))) == gtype);
|
||||
G_STATIC_ASSERT_EXPR (sizeof (gpointer) >= sizeof (gsize));
|
||||
G_STATIC_ASSERT_EXPR (sizeof (gsize) == sizeof (GType));
|
||||
#endif
|
||||
|
||||
return GSIZE_TO_POINTER (gtype);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
setting_changed_cb (NMSetting *setting,
|
||||
GParamSpec *pspec,
|
||||
|
|
@ -94,18 +110,18 @@ static void
|
|||
_nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
|
||||
{
|
||||
NMConnectionPrivate *priv;
|
||||
const char *name;
|
||||
GType setting_type;
|
||||
NMSetting *s_old;
|
||||
|
||||
nm_assert (NM_IS_CONNECTION (connection));
|
||||
nm_assert (NM_IS_SETTING (setting));
|
||||
|
||||
priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||
name = G_OBJECT_TYPE_NAME (setting);
|
||||
setting_type = G_OBJECT_TYPE (setting);
|
||||
|
||||
if ((s_old = g_hash_table_lookup (priv->settings, (gpointer) name)))
|
||||
if ((s_old = g_hash_table_lookup (priv->settings, _gtype_to_hash_key (setting_type))))
|
||||
g_signal_handlers_disconnect_by_func (s_old, setting_changed_cb, connection);
|
||||
g_hash_table_insert (priv->settings, (gpointer) name, setting);
|
||||
g_hash_table_insert (priv->settings, _gtype_to_hash_key (setting_type), setting);
|
||||
/* Listen for property changes so we can emit the 'changed' signal */
|
||||
g_signal_connect (setting, "notify", (GCallback) setting_changed_cb, connection);
|
||||
}
|
||||
|
|
@ -135,17 +151,15 @@ _nm_connection_remove_setting (NMConnection *connection, GType setting_type)
|
|||
{
|
||||
NMConnectionPrivate *priv;
|
||||
NMSetting *setting;
|
||||
const char *setting_name;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
||||
g_return_val_if_fail (g_type_is_a (setting_type, NM_TYPE_SETTING), FALSE);
|
||||
|
||||
priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||
setting_name = g_type_name (setting_type);
|
||||
setting = g_hash_table_lookup (priv->settings, setting_name);
|
||||
setting = g_hash_table_lookup (priv->settings, _gtype_to_hash_key (setting_type));
|
||||
if (setting) {
|
||||
g_signal_handlers_disconnect_by_func (setting, setting_changed_cb, connection);
|
||||
g_hash_table_remove (priv->settings, setting_name);
|
||||
g_hash_table_remove (priv->settings, _gtype_to_hash_key (setting_type));
|
||||
g_signal_emit (connection, signals[CHANGED], 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -169,11 +183,15 @@ nm_connection_remove_setting (NMConnection *connection, GType setting_type)
|
|||
static gpointer
|
||||
_connection_get_setting (NMConnection *connection, GType setting_type)
|
||||
{
|
||||
NMSetting *setting;
|
||||
|
||||
nm_assert (NM_IS_CONNECTION (connection));
|
||||
nm_assert (g_type_is_a (setting_type, NM_TYPE_SETTING));
|
||||
|
||||
return g_hash_table_lookup (NM_CONNECTION_GET_PRIVATE (connection)->settings,
|
||||
g_type_name (setting_type));
|
||||
setting = g_hash_table_lookup (NM_CONNECTION_GET_PRIVATE (connection)->settings,
|
||||
_gtype_to_hash_key (setting_type));
|
||||
nm_assert (!setting || G_TYPE_CHECK_INSTANCE_TYPE (setting, setting_type));
|
||||
return setting;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
|
|
@ -1874,7 +1892,7 @@ nm_connection_to_dbus (NMConnection *connection,
|
|||
NMConnectionPrivate *priv;
|
||||
GVariantBuilder builder;
|
||||
GHashTableIter iter;
|
||||
gpointer key, data;
|
||||
gpointer data;
|
||||
GVariant *setting_dict, *ret;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
|
@ -1884,7 +1902,7 @@ nm_connection_to_dbus (NMConnection *connection,
|
|||
|
||||
/* Add each setting's hash to the main hash */
|
||||
g_hash_table_iter_init (&iter, priv->settings);
|
||||
while (g_hash_table_iter_next (&iter, &key, &data)) {
|
||||
while (g_hash_table_iter_next (&iter, NULL, &data)) {
|
||||
NMSetting *setting = NM_SETTING (data);
|
||||
|
||||
setting_dict = _nm_setting_to_dbus (setting, connection, flags);
|
||||
|
|
@ -2029,14 +2047,13 @@ nm_connection_dump (NMConnection *connection)
|
|||
{
|
||||
GHashTableIter iter;
|
||||
NMSetting *setting;
|
||||
const char *setting_name;
|
||||
char *str;
|
||||
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting)) {
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
|
||||
str = nm_setting_to_string (setting);
|
||||
g_print ("%s\n", str);
|
||||
g_free (str);
|
||||
|
|
@ -2910,7 +2927,10 @@ nm_connection_get_private (NMConnection *connection)
|
|||
priv, (GDestroyNotify) nm_connection_private_free);
|
||||
|
||||
priv->self = connection;
|
||||
priv->settings = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_object_unref);
|
||||
priv->settings = g_hash_table_new_full (nm_direct_hash,
|
||||
NULL,
|
||||
NULL,
|
||||
g_object_unref);
|
||||
}
|
||||
|
||||
return priv;
|
||||
|
|
|
|||
|
|
@ -259,8 +259,9 @@ pppoe_vcc_config (NMDeviceAdsl *self)
|
|||
NMDevice *device = NM_DEVICE (self);
|
||||
NMSettingAdsl *s_adsl;
|
||||
|
||||
s_adsl = nm_connection_get_setting_adsl (nm_device_get_applied_connection (device));
|
||||
g_assert (s_adsl);
|
||||
s_adsl = nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
|
||||
|
||||
g_return_val_if_fail (s_adsl, FALSE);
|
||||
|
||||
/* Set up the VCC */
|
||||
if (!br2684_assign_vcc (self, s_adsl))
|
||||
|
|
@ -389,7 +390,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
NMSettingAdsl *s_adsl;
|
||||
const char *protocol;
|
||||
|
||||
s_adsl = nm_connection_get_setting_adsl (nm_device_get_applied_connection (device));
|
||||
s_adsl = nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
|
||||
|
||||
g_return_val_if_fail (s_adsl, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
protocol = nm_setting_adsl_get_protocol (s_adsl);
|
||||
|
|
@ -465,8 +467,11 @@ act_stage3_ip4_config_start (NMDevice *device,
|
|||
const char *ppp_iface;
|
||||
|
||||
req = nm_device_get_act_request (device);
|
||||
|
||||
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
s_adsl = (NMSettingAdsl *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
|
||||
|
||||
s_adsl = nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
|
||||
|
||||
g_return_val_if_fail (s_adsl, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
/* PPPoE uses the NAS interface, not the ATM interface */
|
||||
|
|
|
|||
|
|
@ -220,7 +220,6 @@ static NMActStageReturn
|
|||
apply_bonding_config (NMDevice *device)
|
||||
{
|
||||
NMDeviceBond *self = NM_DEVICE_BOND (device);
|
||||
NMConnection *connection;
|
||||
NMSettingBond *s_bond;
|
||||
int ifindex = nm_device_get_ifindex (device);
|
||||
const char *mode_str, *value;
|
||||
|
|
@ -241,10 +240,9 @@ apply_bonding_config (NMDevice *device)
|
|||
* arp_interval doesn't require miimon to be 0
|
||||
*/
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
g_assert (connection);
|
||||
s_bond = nm_connection_get_setting_bond (connection);
|
||||
g_assert (s_bond);
|
||||
s_bond = nm_device_get_applied_setting (device, NM_TYPE_SETTING_BOND);
|
||||
|
||||
g_return_val_if_fail (s_bond, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
mode_str = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE);
|
||||
if (!mode_str)
|
||||
|
|
|
|||
|
|
@ -556,7 +556,9 @@ build_supplicant_config (NMDeviceEthernet *self,
|
|||
guint32 mtu;
|
||||
|
||||
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
||||
g_assert (connection);
|
||||
|
||||
g_return_val_if_fail (connection, NULL);
|
||||
|
||||
con_uuid = nm_connection_get_uuid (connection);
|
||||
mtu = nm_platform_link_get_mtu (nm_device_get_platform (NM_DEVICE (self)),
|
||||
nm_device_get_ifindex (NM_DEVICE (self)));
|
||||
|
|
@ -790,7 +792,7 @@ link_negotiation_set (NMDevice *device)
|
|||
guint32 speed = 0;
|
||||
guint32 link_speed;
|
||||
|
||||
s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
|
||||
s_wired = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
|
||||
if (s_wired) {
|
||||
autoneg = nm_setting_wired_get_auto_negotiate (s_wired);
|
||||
speed = nm_setting_wired_get_speed (s_wired);
|
||||
|
|
@ -880,8 +882,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
|
|||
delay);
|
||||
g_assert (!priv->pppoe_wait_id);
|
||||
priv->pppoe_wait_id = g_timeout_add_seconds (delay,
|
||||
pppoe_reconnect_delay,
|
||||
self);
|
||||
pppoe_reconnect_delay,
|
||||
self);
|
||||
return NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
priv->last_pppoe_time = 0;
|
||||
|
|
@ -900,6 +902,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *out_failure
|
|||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
||||
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
||||
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
security = nm_connection_get_setting_802_1x (connection);
|
||||
|
|
@ -995,10 +998,12 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *out_
|
|||
NMActRequest *req;
|
||||
GError *err = NULL;
|
||||
|
||||
req = nm_device_get_act_request (NM_DEVICE (self));
|
||||
req = nm_device_get_act_request (device);
|
||||
|
||||
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE);
|
||||
s_pppoe = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE);
|
||||
|
||||
g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
priv->ppp_manager = nm_ppp_manager_create (nm_device_get_iface (device),
|
||||
|
|
@ -1069,8 +1074,10 @@ dcb_configure (NMDevice *device)
|
|||
|
||||
nm_clear_g_source (&priv->dcb_timeout_id);
|
||||
|
||||
s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
|
||||
g_assert (s_dcb);
|
||||
s_dcb = nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
|
||||
|
||||
g_return_val_if_fail (s_dcb, FALSE);
|
||||
|
||||
if (!nm_dcb_setup (nm_device_get_iface (device), s_dcb, &error)) {
|
||||
_LOGW (LOGD_DCB, "Activation: (ethernet) failed to enable DCB/FCoE: %s",
|
||||
error->message);
|
||||
|
|
@ -1199,7 +1206,8 @@ wake_on_lan_enable (NMDevice *device)
|
|||
NMSettingWired *s_wired;
|
||||
const char *password = NULL;
|
||||
|
||||
s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
|
||||
s_wired = 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);
|
||||
|
|
@ -1240,8 +1248,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
NMSettingDcb *s_dcb;
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device,
|
||||
NM_TYPE_SETTING_CONNECTION));
|
||||
s_con = nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION);
|
||||
|
||||
g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
nm_clear_g_source (&priv->dcb_timeout_id);
|
||||
|
|
@ -1254,8 +1262,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
|
||||
NMSetting8021x *security;
|
||||
|
||||
security = (NMSetting8021x *) nm_device_get_applied_setting (device,
|
||||
NM_TYPE_SETTING_802_1X);
|
||||
security = 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, out_failure_reason);
|
||||
|
|
@ -1265,7 +1273,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
wake_on_lan_enable (device);
|
||||
|
||||
/* DCB and FCoE setup */
|
||||
s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
|
||||
s_dcb = 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_device_get_platform (device), nm_device_get_ifindex (device))) {
|
||||
|
|
@ -1288,7 +1296,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
NM_SETTING_PPPOE_SETTING_NAME)) {
|
||||
NMSettingPpp *s_ppp;
|
||||
|
||||
s_ppp = (NMSettingPpp *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP);
|
||||
s_ppp = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP);
|
||||
if (s_ppp) {
|
||||
guint32 mtu = 0, mru = 0, mxu;
|
||||
|
||||
|
|
@ -1316,7 +1324,8 @@ act_stage3_ip4_config_start (NMDevice *device,
|
|||
NMSettingConnection *s_con;
|
||||
const char *connection_type;
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION));
|
||||
s_con = nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION);
|
||||
|
||||
g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
connection_type = nm_setting_connection_get_connection_type (s_con);
|
||||
|
|
@ -1358,7 +1367,7 @@ deactivate (NMDevice *device)
|
|||
priv->dcb_handle_carrier_changes = FALSE;
|
||||
|
||||
/* Tear down DCB/FCoE if it was enabled */
|
||||
s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
|
||||
s_dcb = 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_PLATFORM, "failed to disable DCB/FCoE: %s",
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
|
||||
return ret;
|
||||
|
||||
s_infiniband = (NMSettingInfiniband *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_INFINIBAND);
|
||||
s_infiniband = nm_device_get_applied_setting (device, NM_TYPE_SETTING_INFINIBAND);
|
||||
|
||||
g_return_val_if_fail (s_infiniband, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband);
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ update_properties (NMDevice *device)
|
|||
static NMSupplicantConfig *
|
||||
build_supplicant_config (NMDeviceMacsec *self, GError **error)
|
||||
{
|
||||
NMSupplicantConfig *config = NULL;
|
||||
gs_unref_object NMSupplicantConfig *config = NULL;
|
||||
NMSettingMacsec *s_macsec;
|
||||
NMSetting8021x *s_8021x;
|
||||
NMConnection *connection;
|
||||
|
|
@ -218,19 +218,21 @@ build_supplicant_config (NMDeviceMacsec *self, GError **error)
|
|||
guint32 mtu;
|
||||
|
||||
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
||||
g_assert (connection);
|
||||
|
||||
g_return_val_if_fail (connection, NULL);
|
||||
|
||||
con_uuid = nm_connection_get_uuid (connection);
|
||||
mtu = nm_platform_link_get_mtu (nm_device_get_platform (NM_DEVICE (self)),
|
||||
nm_device_get_ifindex (NM_DEVICE (self)));
|
||||
|
||||
config = nm_supplicant_config_new (FALSE, FALSE);
|
||||
|
||||
s_macsec = (NMSettingMacsec *)
|
||||
nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_MACSEC);
|
||||
s_macsec = nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_MACSEC);
|
||||
|
||||
g_return_val_if_fail (s_macsec, NULL);
|
||||
|
||||
if (!nm_supplicant_config_add_setting_macsec (config, s_macsec, error)) {
|
||||
g_prefix_error (error, "macsec-setting: ");
|
||||
g_object_unref (config);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -238,11 +240,11 @@ build_supplicant_config (NMDeviceMacsec *self, GError **error)
|
|||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
if (!nm_supplicant_config_add_setting_8021x (config, s_8021x, con_uuid, mtu, TRUE, error)) {
|
||||
g_prefix_error (error, "802-1x-setting: ");
|
||||
g_clear_object (&config);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
return g_steal_pointer (&config);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -588,6 +590,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
const char *setting_name;
|
||||
|
||||
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
||||
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
if (!priv->supplicant.mgr)
|
||||
|
|
|
|||
|
|
@ -125,10 +125,12 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
NMActRequest *req;
|
||||
GError *error = NULL;
|
||||
|
||||
req = nm_device_get_act_request (NM_DEVICE (self));
|
||||
req = nm_device_get_act_request (device);
|
||||
|
||||
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE);
|
||||
s_pppoe = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE);
|
||||
|
||||
g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
g_clear_object (&priv->ip4_config);
|
||||
|
|
|
|||
|
|
@ -493,7 +493,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
parent_mtu_maybe_changed (parent_device, NULL, device);
|
||||
}
|
||||
|
||||
s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_VLAN);
|
||||
s_vlan = nm_device_get_applied_setting (device, NM_TYPE_SETTING_VLAN);
|
||||
if (s_vlan) {
|
||||
gs_free NMVlanQosMapping *ingress_map = NULL;
|
||||
gs_free NMVlanQosMapping *egress_map = NULL;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,6 @@ static NMActStageReturn
|
|||
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
NMDeviceWpan *self = NM_DEVICE_WPAN (device);
|
||||
NMConnection *connection;
|
||||
NMSettingWpan *s_wpan;
|
||||
NMPlatform *platform;
|
||||
guint16 pan_id;
|
||||
|
|
@ -139,12 +138,11 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
g_return_val_if_fail (platform, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
ifindex = nm_device_get_ifindex (device);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
s_wpan = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WPAN);
|
||||
|
||||
s_wpan = NM_SETTING_WPAN (nm_connection_get_setting (connection, NM_TYPE_SETTING_WPAN));
|
||||
g_return_val_if_fail (s_wpan, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
hwaddr = nm_platform_link_get_address (platform, ifindex, &hwaddr_len);
|
||||
|
|
|
|||
|
|
@ -1954,9 +1954,10 @@ nm_device_get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *iid, gboo
|
|||
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
||||
|
||||
if (!ignore_token) {
|
||||
s_ip6 = (NMSettingIP6Config *)
|
||||
nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
s_ip6 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
|
||||
g_return_val_if_fail (s_ip6, FALSE);
|
||||
|
||||
token = nm_setting_ip6_config_get_token (s_ip6);
|
||||
}
|
||||
if (token)
|
||||
|
|
@ -2418,7 +2419,7 @@ nm_device_has_unmodified_applied_connection (NMDevice *self, NMSettingCompareFla
|
|||
return nm_active_connection_has_unmodified_applied_connection ((NMActiveConnection *) priv->act_request.obj, compare_flags);
|
||||
}
|
||||
|
||||
NMSetting *
|
||||
gpointer
|
||||
nm_device_get_applied_setting (NMDevice *self, GType setting_type)
|
||||
{
|
||||
NMConnection *connection;
|
||||
|
|
@ -4933,12 +4934,12 @@ check_ip_state (NMDevice *self, gboolean may_fail, gboolean full_state_update)
|
|||
&& !priv->is_enslaved)
|
||||
return;
|
||||
|
||||
s_ip4 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
s_ip4 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
if (s_ip4 && nm_streq0 (nm_setting_ip_config_get_method (s_ip4),
|
||||
NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
|
||||
ip4_disabled = TRUE;
|
||||
|
||||
s_ip6 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
s_ip6 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
if (s_ip6 && nm_streq0 (nm_setting_ip_config_get_method (s_ip6),
|
||||
NM_SETTING_IP6_CONFIG_METHOD_IGNORE))
|
||||
ip6_ignore = TRUE;
|
||||
|
|
@ -6237,7 +6238,7 @@ act_stage1_prepare (NMDevice *self, NMDeviceStateReason *out_failure_reason)
|
|||
|
||||
if ( priv->ifindex > 0
|
||||
&& nm_device_has_capability (self, NM_DEVICE_CAP_SRIOV)
|
||||
&& (s_sriov = (NMSettingSriov *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_SRIOV))) {
|
||||
&& (s_sriov = nm_device_get_applied_setting (self, NM_TYPE_SETTING_SRIOV))) {
|
||||
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
|
||||
gs_free_error GError *error = NULL;
|
||||
NMSriovVF *vf;
|
||||
|
|
@ -9026,7 +9027,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
|||
if (mtu_desired && mtu_desired < 1280) {
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
||||
s_ip6 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
s_ip6 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
if ( s_ip6
|
||||
&& !NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6),
|
||||
NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
|
||||
|
|
@ -14375,7 +14376,8 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
|||
return;
|
||||
|
||||
connection = nm_device_get_applied_connection (self);
|
||||
g_assert (connection);
|
||||
|
||||
g_return_if_fail (connection);
|
||||
|
||||
argv = g_ptr_array_sized_new (10);
|
||||
g_ptr_array_set_free_func (argv, g_free);
|
||||
|
|
@ -15799,7 +15801,9 @@ nm_device_get_supplicant_timeout (NMDevice *self)
|
|||
g_return_val_if_fail (NM_IS_DEVICE (self), SUPPLICANT_DEFAULT_TIMEOUT);
|
||||
|
||||
connection = nm_device_get_applied_connection (self);
|
||||
|
||||
g_return_val_if_fail (connection, SUPPLICANT_DEFAULT_TIMEOUT);
|
||||
|
||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
if (s_8021x) {
|
||||
timeout = nm_setting_802_1x_get_auth_timeout (s_8021x);
|
||||
|
|
@ -15830,7 +15834,7 @@ nm_device_auth_retries_try_next (NMDevice *self)
|
|||
if (G_UNLIKELY (auth_retries == NM_DEVICE_AUTH_RETRIES_UNSET)) {
|
||||
auth_retries = -1;
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (self, NM_TYPE_SETTING_CONNECTION));
|
||||
s_con = nm_device_get_applied_setting (self, NM_TYPE_SETTING_CONNECTION);
|
||||
if (s_con)
|
||||
auth_retries = nm_setting_connection_get_auth_retries (s_con);
|
||||
|
||||
|
|
|
|||
|
|
@ -543,7 +543,9 @@ NMConnection * nm_device_get_settings_connection_get_connection (NMDevice *self
|
|||
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);
|
||||
|
||||
gpointer /* (NMSetting *) */ nm_device_get_applied_setting (NMDevice *dev,
|
||||
GType setting_type);
|
||||
|
||||
void nm_device_removed (NMDevice *self, gboolean unconfigure_ip_config);
|
||||
|
||||
|
|
|
|||
|
|
@ -121,12 +121,13 @@ link_changed (NMDevice *device,
|
|||
static gboolean
|
||||
_is_internal_interface (NMDevice *device)
|
||||
{
|
||||
NMConnection *connection = nm_device_get_applied_connection (device);
|
||||
NMSettingOvsInterface *s_ovs_iface = nm_connection_get_setting_ovs_interface (connection);
|
||||
NMSettingOvsInterface *s_ovs_iface;
|
||||
|
||||
s_ovs_iface = nm_device_get_applied_setting (device, NM_TYPE_SETTING_OVS_INTERFACE);
|
||||
|
||||
g_return_val_if_fail (s_ovs_iface, FALSE);
|
||||
|
||||
return strcmp (nm_setting_ovs_interface_get_interface_type (s_ovs_iface), "internal") == 0;
|
||||
return nm_streq (nm_setting_ovs_interface_get_interface_type (s_ovs_iface), "internal");
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
|
|
|
|||
|
|
@ -626,6 +626,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
s_team = nm_connection_get_setting_team (connection);
|
||||
g_return_val_if_fail (s_team, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
|
|
|
|||
|
|
@ -1518,7 +1518,7 @@ act_start_cb (GObject *source, GAsyncResult *res, gpointer user_data)
|
|||
|
||||
nm_assert (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG);
|
||||
|
||||
s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
|
||||
s_wireless = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
|
||||
if (!s_wireless)
|
||||
goto error;
|
||||
|
||||
|
|
|
|||
|
|
@ -181,16 +181,13 @@ static NMActStageReturn
|
|||
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
|
||||
NMConnection *connection;
|
||||
NMSettingOlpcMesh *s_mesh;
|
||||
guint32 channel;
|
||||
GBytes *ssid;
|
||||
const char *anycast_addr;
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
s_mesh = nm_device_get_applied_setting (device, NM_TYPE_SETTING_OLPC_MESH);
|
||||
|
||||
s_mesh = nm_connection_get_setting_olpc_mesh (connection);
|
||||
g_return_val_if_fail (s_mesh, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
channel = nm_setting_olpc_mesh_get_channel (s_mesh);
|
||||
|
|
|
|||
|
|
@ -1868,9 +1868,10 @@ need_new_8021x_secrets (NMDeviceWifi *self,
|
|||
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
||||
NMConnection *connection;
|
||||
|
||||
g_assert (setting_name != NULL);
|
||||
g_return_val_if_fail (setting_name, FALSE);
|
||||
|
||||
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
||||
|
||||
g_return_val_if_fail (connection != NULL, FALSE);
|
||||
|
||||
/* 802.1x stuff only happens in the supplicant's ASSOCIATED state when it's
|
||||
|
|
@ -1922,10 +1923,11 @@ need_new_wpa_psk (NMDeviceWifi *self,
|
|||
NMConnection *connection;
|
||||
const char *key_mgmt = NULL;
|
||||
|
||||
g_assert (setting_name != NULL);
|
||||
g_return_val_if_fail (setting_name, FALSE);
|
||||
|
||||
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
||||
g_return_val_if_fail (connection != NULL, FALSE);
|
||||
|
||||
g_return_val_if_fail (connection, FALSE);
|
||||
|
||||
/* A bad PSK will cause the supplicant to disconnect during the 4-way handshake */
|
||||
if (old_state != NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE)
|
||||
|
|
@ -2057,15 +2059,12 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|||
* schedule the next activation stage.
|
||||
*/
|
||||
if (devstate == NM_DEVICE_STATE_CONFIG) {
|
||||
NMConnection *connection;
|
||||
NMSettingWireless *s_wifi;
|
||||
GBytes *ssid;
|
||||
gs_free char *ssid_str = NULL;
|
||||
|
||||
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
||||
g_return_if_fail (connection);
|
||||
s_wifi = nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_WIRELESS);
|
||||
|
||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
g_return_if_fail (s_wifi);
|
||||
|
||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
|
|
@ -2486,7 +2485,7 @@ wake_on_wlan_enable (NMDeviceWifi *self)
|
|||
NMSettingWirelessWakeOnWLan wowl;
|
||||
NMSettingWireless *s_wireless;
|
||||
|
||||
s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_WIRELESS);
|
||||
s_wireless = nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_WIRELESS);
|
||||
if (s_wireless) {
|
||||
wowl = nm_setting_wireless_get_wake_on_wlan (s_wireless);
|
||||
if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT)
|
||||
|
|
@ -2663,7 +2662,8 @@ set_powersave (NMDevice *device)
|
|||
NMSettingWireless *s_wireless;
|
||||
NMSettingWirelessPowersave val;
|
||||
|
||||
s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
|
||||
s_wireless = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
|
||||
|
||||
g_return_if_fail (s_wireless);
|
||||
|
||||
val = nm_setting_wireless_get_powersave (s_wireless);
|
||||
|
|
@ -2813,6 +2813,7 @@ act_stage3_ip4_config_start (NMDevice *device,
|
|||
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
|
|
@ -2836,6 +2837,7 @@ act_stage3_ip6_config_start (NMDevice *device,
|
|||
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
|
|
@ -2935,6 +2937,7 @@ act_stage4_ip4_config_timeout (NMDevice *device, NMDeviceStateReason *out_failur
|
|||
NMActStageReturn ret;
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
|
|
@ -2956,6 +2959,7 @@ act_stage4_ip6_config_timeout (NMDevice *device, NMDeviceStateReason *out_failur
|
|||
NMActStageReturn ret;
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue