summary refs log tree commit diff
path: root/src/devices/nm-device-bond.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/nm-device-bond.c')
-rw-r--r--src/devices/nm-device-bond.c64
1 files changed, 27 insertions, 37 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 50494526..c6ecb2e8 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -1,20 +1,6 @@
-/* NetworkManager -- Network link manager
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2018 Red Hat, Inc.
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2011 - 2018 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -213,10 +199,10 @@ set_simple_option (NMDevice *device,
 	set_bond_attr (device, mode, opt, value);
 }
 
-static NMActStageReturn
-apply_bonding_config (NMDevice *device)
+static gboolean
+apply_bonding_config (NMDeviceBond *self)
 {
-	NMDeviceBond *self = NM_DEVICE_BOND (device);
+	NMDevice *device = NM_DEVICE (self);
 	NMSettingBond *s_bond;
 	int ifindex = nm_device_get_ifindex (device);
 	const char *mode_str, *value;
@@ -239,7 +225,7 @@ apply_bonding_config (NMDevice *device)
 
 	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);
 	if (!mode_str)
@@ -248,7 +234,7 @@ apply_bonding_config (NMDevice *device)
 	mode = _nm_setting_bond_mode_from_string (mode_str);
 	if (mode == NM_BOND_MODE_UNKNOWN) {
 		_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
@@ -334,24 +320,26 @@ apply_bonding_config (NMDevice *device)
 	else
 		set_simple_option (device, mode, s_bond, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA);
 
-	return NM_ACT_STAGE_RETURN_SUCCESS;
+	return TRUE;
 }
 
 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;
 
-	ret = NM_DEVICE_CLASS (nm_device_bond_parent_class)->act_stage1_prepare (dev, out_failure_reason);
-	if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
-		return ret;
-
 	/* Interface must be down to set bond options */
-	nm_device_take_down (dev, TRUE);
-	ret = apply_bonding_config (dev);
-	if (ret != NM_ACT_STAGE_RETURN_FAILURE)
-		ret = nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE);
-	nm_device_bring_up (dev, TRUE, NULL);
+	nm_device_take_down (device, TRUE);
+	if (!apply_bonding_config (self))
+		ret = NM_ACT_STAGE_RETURN_FAILURE;
+	else {
+		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;
 }
@@ -416,10 +404,12 @@ release_slave (NMDevice *device,
 	int ifindex_slave;
 	int ifindex;
 
-	ifindex = nm_device_get_ifindex (device);
-	if (   ifindex <= 0
-	    || !nm_platform_link_get (nm_device_get_platform (device), ifindex))
-		configure = FALSE;
+	if (configure) {
+		ifindex = nm_device_get_ifindex (device);
+		if (   ifindex <= 0
+		    || !nm_platform_link_get (nm_device_get_platform (device), ifindex))
+			configure = FALSE;
+	}
 
 	ifindex_slave = nm_device_get_ip_ifindex (slave);