static void release_slave (NMDevice *device, NMDevice *slave, gboolean configure) { NMDeviceBond *self = NM_DEVICE_BOND (device); gboolean success, no_firmware = FALSE; if (configure) { success = nm_platform_link_release (nm_device_get_platform (device), nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); if (success) { _LOGI (LOGD_BOND, "released bond slave %s", nm_device_get_ip_iface (slave)); } else { _LOGW (LOGD_BOND, "failed to release bond slave %s", nm_device_get_ip_iface (slave)); } /* Kernel bonding code "closes" the slave when releasing it, (which clears * IFF_UP), so we must bring it back up here to ensure carrier changes and * other state is noticed by the now-released slave. */ if (!nm_device_bring_up (slave, TRUE, &no_firmware)) _LOGW (LOGD_BOND, "released bond slave could not be brought up."); } else { _LOGI (LOGD_BOND, "bond slave %s was released", nm_device_get_ip_iface (slave)); } }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMDeviceBond *device = NM_DEVICE_BOND (object); _nm_object_ensure_inited (NM_OBJECT (object)); switch (prop_id) { case PROP_HW_ADDRESS: g_value_set_string (value, nm_device_bond_get_hw_address (device)); break; case PROP_CARRIER: g_value_set_boolean (value, nm_device_bond_get_carrier (device)); break; case PROP_SLAVES: g_value_set_boxed (value, nm_device_bond_get_slaves (device)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static gboolean enslave_slave (NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure) { NMDeviceBond *self = NM_DEVICE_BOND (device); gboolean success = TRUE, no_firmware = FALSE; const char *slave_iface = nm_device_get_ip_iface (slave); nm_device_master_check_slave_physical_port (device, slave, LOGD_BOND); if (configure) { nm_device_take_down (slave, TRUE); success = nm_platform_link_enslave (nm_device_get_platform (device), nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); nm_device_bring_up (slave, TRUE, &no_firmware); if (!success) return FALSE; _LOGI (LOGD_BOND, "enslaved bond slave %s", slave_iface); } else _LOGI (LOGD_BOND, "bond slave %s was enslaved", slave_iface); return TRUE; }
static void constructed (GObject *object) { NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_bond_parent_class)->constructed (object); priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BOND); register_properties (NM_DEVICE_BOND (object)); }
static gboolean set_bond_attr (NMDevice *device, const char *attr, const char *value) { NMDeviceBond *self = NM_DEVICE_BOND (device); gboolean ret; int ifindex = nm_device_get_ifindex (device); ret = nm_platform_sysctl_master_set_option (nm_device_get_platform(device), ifindex, attr, value); if (!ret) _LOGW (LOGD_HW, "failed to set bonding attribute '%s' to '%s'", attr, value); return ret; }
static void constructed (GObject *object) { NMDeviceBondPrivate *priv; G_OBJECT_CLASS (nm_device_bond_parent_class)->constructed (object); priv = NM_DEVICE_BOND_GET_PRIVATE (object); priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), NM_DBUS_SERVICE, nm_object_get_path (NM_OBJECT (object)), NM_DBUS_INTERFACE_DEVICE_BOND); register_properties (NM_DEVICE_BOND (object)); }
static const char * get_hw_address (NMDevice *device) { return nm_device_bond_get_hw_address (NM_DEVICE_BOND (device)); }