device/bond: cleanup act-stage return values in NMDeviceBond's act_stage1_prepare()

This commit is contained in:
Thomas Haller 2019-08-21 16:57:55 +02:00
parent 0d0d4eaf93
commit aef9594fa6

View file

@ -213,10 +213,10 @@ set_simple_option (NMDevice *device,
set_bond_attr (device, mode, opt, value); set_bond_attr (device, mode, opt, value);
} }
static NMActStageReturn static gboolean
apply_bonding_config (NMDevice *device) apply_bonding_config (NMDeviceBond *self)
{ {
NMDeviceBond *self = NM_DEVICE_BOND (device); NMDevice *device = NM_DEVICE (self);
NMSettingBond *s_bond; NMSettingBond *s_bond;
int ifindex = nm_device_get_ifindex (device); int ifindex = nm_device_get_ifindex (device);
const char *mode_str, *value; const char *mode_str, *value;
@ -239,7 +239,7 @@ apply_bonding_config (NMDevice *device)
s_bond = nm_device_get_applied_setting (device, NM_TYPE_SETTING_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); g_return_val_if_fail (s_bond, FALSE);
mode_str = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE); mode_str = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE);
if (!mode_str) if (!mode_str)
@ -248,7 +248,7 @@ apply_bonding_config (NMDevice *device)
mode = _nm_setting_bond_mode_from_string (mode_str); mode = _nm_setting_bond_mode_from_string (mode_str);
if (mode == NM_BOND_MODE_UNKNOWN) { if (mode == NM_BOND_MODE_UNKNOWN) {
_LOGW (LOGD_BOND, "unknown bond mode '%s'", mode_str); _LOGW (LOGD_BOND, "unknown bond mode '%s'", mode_str);
return NM_ACT_STAGE_RETURN_FAILURE; return FALSE;
} }
/* Set mode first, as some other options (e.g. arp_interval) are valid /* Set mode first, as some other options (e.g. arp_interval) are valid
@ -334,24 +334,30 @@ apply_bonding_config (NMDevice *device)
else else
set_simple_option (device, mode, s_bond, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA); set_simple_option (device, mode, s_bond, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA);
return NM_ACT_STAGE_RETURN_SUCCESS; return TRUE;
} }
static NMActStageReturn static NMActStageReturn
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason) act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceBond *self = NM_DEVICE_BOND (device);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
ret = NM_DEVICE_CLASS (nm_device_bond_parent_class)->act_stage1_prepare (dev, out_failure_reason); ret = NM_DEVICE_CLASS (nm_device_bond_parent_class)->act_stage1_prepare (device, out_failure_reason);
if (ret != NM_ACT_STAGE_RETURN_SUCCESS) if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret; return ret;
/* Interface must be down to set bond options */ /* Interface must be down to set bond options */
nm_device_take_down (dev, TRUE); nm_device_take_down (device, TRUE);
ret = apply_bonding_config (dev); if (!apply_bonding_config (self))
if (ret != NM_ACT_STAGE_RETURN_FAILURE) ret = NM_ACT_STAGE_RETURN_FAILURE;
ret = nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE); else {
nm_device_bring_up (dev, TRUE, NULL); if (!nm_device_hw_addr_set_cloned (device,
nm_device_get_applied_connection (device),
FALSE))
ret = NM_ACT_STAGE_RETURN_FAILURE;
}
nm_device_bring_up (device, TRUE, NULL);
return ret; return ret;
} }