|
Packit Service |
87a54e |
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2011 - 2018 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-default.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-device-bond.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include <stdlib.h>
|
|
Packit |
5756e2 |
#include <net/if.h>
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "NetworkManagerUtils.h"
|
|
Packit |
5756e2 |
#include "nm-device-private.h"
|
|
Packit |
5756e2 |
#include "platform/nm-platform.h"
|
|
Packit |
5756e2 |
#include "nm-device-factory.h"
|
|
Packit |
5756e2 |
#include "nm-core-internal.h"
|
|
Packit |
5756e2 |
#include "nm-ip4-config.h"
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define _NMLOG_DEVICE_TYPE NMDeviceBond
|
|
Packit |
5756e2 |
#include "nm-device-logging.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define OPTIONS_APPLY_SUBSET \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_MIIMON, NM_SETTING_BOND_OPTION_UPDELAY, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_ARP_INTERVAL, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_ARP_VALIDATE, NM_SETTING_BOND_OPTION_PRIMARY, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM, NM_SETTING_BOND_OPTION_AD_ACTOR_SYS_PRIO, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_AD_SELECT, NM_SETTING_BOND_OPTION_AD_USER_PORT_KEY, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_ALL_SLAVES_ACTIVE, NM_SETTING_BOND_OPTION_ARP_ALL_TARGETS, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, NM_SETTING_BOND_OPTION_LACP_RATE, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_LP_INTERVAL, NM_SETTING_BOND_OPTION_MIN_LINKS, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE, NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_RESEND_IGMP, NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_USE_CARRIER, NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
#define OPTIONS_REAPPLY_SUBSET \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_MIIMON, NM_SETTING_BOND_OPTION_UPDELAY, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_ARP_INTERVAL, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_ARP_VALIDATE, NM_SETTING_BOND_OPTION_PRIMARY, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM, NM_SETTING_BOND_OPTION_AD_ACTOR_SYS_PRIO, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_ALL_SLAVES_ACTIVE, NM_SETTING_BOND_OPTION_ARP_ALL_TARGETS, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, NM_SETTING_BOND_OPTION_LP_INTERVAL, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_MIN_LINKS, NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, NM_SETTING_BOND_OPTION_RESEND_IGMP, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_USE_CARRIER, NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
#define OPTIONS_REAPPLY_FULL \
|
|
Packit Service |
a1bd4f |
OPTIONS_REAPPLY_SUBSET, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE, \
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_ARP_IP_TARGET
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMDeviceBond {
|
|
Packit Service |
a1bd4f |
NMDevice parent;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMDeviceBondClass {
|
|
Packit Service |
a1bd4f |
NMDeviceClass parent;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
G_DEFINE_TYPE(NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static NMDeviceCapabilities
|
|
Packit Service |
a1bd4f |
get_generic_capabilities(NMDevice *dev)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
complete_connection(NMDevice * device,
|
|
Packit Service |
a1bd4f |
NMConnection * connection,
|
|
Packit Service |
a1bd4f |
const char * specific_object,
|
|
Packit Service |
a1bd4f |
NMConnection *const *existing_connections,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMSettingBond *s_bond;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_utils_complete_generic(nm_device_get_platform(device),
|
|
Packit Service |
a1bd4f |
connection,
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
existing_connections,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
_("Bond connection"),
|
|
Packit Service |
a1bd4f |
"bond",
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
s_bond = nm_connection_get_setting_bond(connection);
|
|
Packit Service |
a1bd4f |
if (!s_bond) {
|
|
Packit Service |
a1bd4f |
s_bond = (NMSettingBond *) nm_setting_bond_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_bond));
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
_set_bond_attr(NMDevice *device, const char *attr, const char *value)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceBond *self = NM_DEVICE_BOND(device);
|
|
Packit Service |
a1bd4f |
int ifindex = nm_device_get_ifindex(device);
|
|
Packit Service |
a1bd4f |
gboolean ret;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
ret =
|
|
Packit Service |
a1bd4f |
nm_platform_sysctl_master_set_option(nm_device_get_platform(device), ifindex, attr, value);
|
|
Packit Service |
a1bd4f |
if (!ret)
|
|
Packit Service |
a1bd4f |
_LOGW(LOGD_PLATFORM, "failed to set bonding attribute '%s' to '%s'", attr, value);
|
|
Packit Service |
a1bd4f |
return ret;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define _set_bond_attr_take(device, attr, value) \
|
|
Packit Service |
a1bd4f |
G_STMT_START \
|
|
Packit Service |
a1bd4f |
{ \
|
|
Packit Service |
a1bd4f |
gs_free char *_tmp = (value); \
|
|
Packit Service |
a1bd4f |
\
|
|
Packit Service |
a1bd4f |
_set_bond_attr(device, NM_SETTING_BOND_OPTION_ARP_IP_TARGET, _tmp); \
|
|
Packit Service |
a1bd4f |
} \
|
|
Packit Service |
a1bd4f |
G_STMT_END
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#define _set_bond_attr_printf(device, attr, fmt, ...) \
|
|
Packit Service |
a1bd4f |
_set_bond_attr_take((device), (attr), g_strdup_printf(fmt, __VA_ARGS__))
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
ignore_option(NMSettingBond *s_bond, const char *option, const char *value)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
const char *defvalue;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (nm_streq0(option, NM_SETTING_BOND_OPTION_MIIMON)) {
|
|
Packit Service |
a1bd4f |
/* The default value for miimon, when missing in the setting, is
|
|
Packit Service |
a1bd4f |
* 0 if arp_interval is != 0, and 100 otherwise. So, let's ignore
|
|
Packit Service |
a1bd4f |
* miimon=0 (which means that miimon is disabled) and accept any
|
|
Packit Service |
a1bd4f |
* other value. Adding miimon=100 does not cause any harm.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
defvalue = "0";
|
|
Packit Service |
a1bd4f |
} else
|
|
Packit Service |
a1bd4f |
defvalue = nm_setting_bond_get_option_default(s_bond, option);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return nm_streq0(value, defvalue);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
update_connection(NMDevice *device, NMConnection *connection)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceBond * self = NM_DEVICE_BOND(device);
|
|
Packit Service |
a1bd4f |
NMSettingBond *s_bond = nm_connection_get_setting_bond(connection);
|
|
Packit Service |
a1bd4f |
int ifindex = nm_device_get_ifindex(device);
|
|
Packit Service |
a1bd4f |
NMBondMode mode = NM_BOND_MODE_UNKNOWN;
|
|
Packit Service |
a1bd4f |
const char ** options;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!s_bond) {
|
|
Packit Service |
a1bd4f |
s_bond = (NMSettingBond *) nm_setting_bond_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, (NMSetting *) s_bond);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Read bond options from sysfs and update the Bond setting to match */
|
|
Packit Service |
a1bd4f |
options = nm_setting_bond_get_valid_options(NULL);
|
|
Packit Service |
a1bd4f |
for (; options[0]; options++) {
|
|
Packit Service |
a1bd4f |
const char * option = options[0];
|
|
Packit Service |
a1bd4f |
gs_free char *value = NULL;
|
|
Packit Service |
a1bd4f |
char * p;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (NM_IN_STRSET(option, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE))
|
|
Packit Service |
a1bd4f |
continue;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
value =
|
|
Packit Service |
a1bd4f |
nm_platform_sysctl_master_get_option(nm_device_get_platform(device), ifindex, option);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (value && _nm_setting_bond_get_option_type(s_bond, option) == NM_BOND_OPTION_TYPE_BOTH) {
|
|
Packit Service |
a1bd4f |
p = strchr(value, ' ');
|
|
Packit Service |
a1bd4f |
if (p)
|
|
Packit Service |
a1bd4f |
*p = '\0';
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (mode == NM_BOND_MODE_UNKNOWN) {
|
|
Packit Service |
a1bd4f |
if (value && nm_streq(option, NM_SETTING_BOND_OPTION_MODE))
|
|
Packit Service |
a1bd4f |
mode = _nm_setting_bond_mode_from_string(value);
|
|
Packit Service |
a1bd4f |
if (mode == NM_BOND_MODE_UNKNOWN)
|
|
Packit Service |
a1bd4f |
continue;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!_nm_setting_bond_option_supported(option, mode))
|
|
Packit Service |
a1bd4f |
continue;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (value && value[0] && !ignore_option(s_bond, option, value)) {
|
|
Packit Service |
a1bd4f |
/* Replace " " with "," for arp_ip_targets from the kernel */
|
|
Packit Service |
a1bd4f |
if (nm_streq(option, NM_SETTING_BOND_OPTION_ARP_IP_TARGET)) {
|
|
Packit Service |
a1bd4f |
for (p = value; *p; p++) {
|
|
Packit Service |
a1bd4f |
if (*p == ' ')
|
|
Packit Service |
a1bd4f |
*p = ',';
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!_nm_setting_bond_validate_option(option, value, NULL))
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_BOND, "cannot set invalid bond option '%s' = '%s'", option, value);
|
|
Packit Service |
a1bd4f |
else
|
|
Packit Service |
a1bd4f |
nm_setting_bond_add_option(s_bond, option, value);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
master_update_slave_connection(NMDevice * self,
|
|
Packit Service |
a1bd4f |
NMDevice * slave,
|
|
Packit Service |
a1bd4f |
NMConnection *connection,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_object_set(nm_connection_get_setting_connection(connection),
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_MASTER,
|
|
Packit Service |
a1bd4f |
nm_device_get_iface(self),
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_SLAVE_TYPE,
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
set_arp_targets(NMDevice *device, const char *cur_arp_ip_target, const char *new_arp_ip_target)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
gs_unref_ptrarray GPtrArray *free_list = NULL;
|
|
Packit Service |
a1bd4f |
gs_free const char ** cur_strv = NULL;
|
|
Packit Service |
a1bd4f |
gs_free const char ** new_strv = NULL;
|
|
Packit Service |
a1bd4f |
gsize cur_len;
|
|
Packit Service |
a1bd4f |
gsize new_len;
|
|
Packit Service |
a1bd4f |
gsize i;
|
|
Packit Service |
a1bd4f |
gsize j;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
cur_strv = nm_utils_strsplit_set_full(cur_arp_ip_target,
|
|
Packit Service |
a1bd4f |
NM_ASCII_SPACES,
|
|
Packit Service |
a1bd4f |
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
|
Packit Service |
a1bd4f |
new_strv = nm_utils_bond_option_arp_ip_targets_split(new_arp_ip_target);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
cur_len = NM_PTRARRAY_LEN(cur_strv);
|
|
Packit Service |
a1bd4f |
new_len = NM_PTRARRAY_LEN(new_strv);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (new_len > 0) {
|
|
Packit Service |
a1bd4f |
for (j = 0, i = 0; i < new_len; i++) {
|
|
Packit Service |
a1bd4f |
const char *s;
|
|
Packit Service |
a1bd4f |
in_addr_t a4;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
s = new_strv[i];
|
|
Packit Service |
a1bd4f |
if (nm_utils_parse_inaddr_bin(AF_INET, s, NULL, &a4)) {
|
|
Packit Service |
a1bd4f |
char sbuf[INET_ADDRSTRLEN];
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_nm_utils_inet4_ntop(a4, sbuf);
|
|
Packit Service |
a1bd4f |
if (!nm_streq(s, sbuf)) {
|
|
Packit Service |
a1bd4f |
if (!free_list)
|
|
Packit Service |
a1bd4f |
free_list = g_ptr_array_new_with_free_func(g_free);
|
|
Packit Service |
a1bd4f |
s = g_strdup(sbuf);
|
|
Packit Service |
a1bd4f |
g_ptr_array_add(free_list, (gpointer) s);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (nm_utils_strv_find_first((char **) new_strv, i, s) < 0)
|
|
Packit Service |
a1bd4f |
new_strv[j++] = s;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
new_strv[j] = NULL;
|
|
Packit Service |
a1bd4f |
new_len = j;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (cur_len == 0 && new_len == 0)
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (nm_utils_strv_equal(cur_strv, new_strv))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
for (i = 0; i < cur_len; i++)
|
|
Packit Service |
a1bd4f |
_set_bond_attr_printf(device, NM_SETTING_BOND_OPTION_ARP_IP_TARGET, "-%s", cur_strv[i]);
|
|
Packit Service |
a1bd4f |
for (i = 0; i < new_len; i++)
|
|
Packit Service |
a1bd4f |
_set_bond_attr_printf(device, NM_SETTING_BOND_OPTION_ARP_IP_TARGET, "+%s", new_strv[i]);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Sets bond attribute stored in the option hashtable or
|
|
Packit |
5756e2 |
* the default value if no value was set.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
set_bond_attr_or_default(NMDevice *device, NMSettingBond *s_bond, const char *opt)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceBond *self = NM_DEVICE_BOND(device);
|
|
Packit Service |
a1bd4f |
const char * value;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
value = nm_setting_bond_get_option_or_default(s_bond, opt);
|
|
Packit Service |
a1bd4f |
if (!value) {
|
|
Packit Service |
a1bd4f |
if (_LOGT_ENABLED(LOGD_BOND) && nm_setting_bond_get_option_by_name(s_bond, opt))
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_BOND, "bond option '%s' not set as it conflicts with other options", opt);
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_set_bond_attr(device, opt, value);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
set_bond_attrs_or_default(NMDevice *device, NMSettingBond *s_bond, const char *const *attr_v)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nm_assert(NM_IS_DEVICE(device));
|
|
Packit Service |
a1bd4f |
nm_assert(s_bond);
|
|
Packit Service |
a1bd4f |
nm_assert(attr_v);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
for (; *attr_v; ++attr_v)
|
|
Packit Service |
a1bd4f |
set_bond_attr_or_default(device, s_bond, *attr_v);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
set_bond_arp_ip_targets(NMDevice *device, NMSettingBond *s_bond)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
int ifindex = nm_device_get_ifindex(device);
|
|
Packit Service |
a1bd4f |
gs_free char *cur_arp_ip_target = NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* ARP targets: clear and initialize the list */
|
|
Packit Service |
a1bd4f |
cur_arp_ip_target = nm_platform_sysctl_master_get_option(nm_device_get_platform(device),
|
|
Packit Service |
a1bd4f |
ifindex,
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
|
|
Packit Service |
a1bd4f |
set_arp_targets(
|
|
Packit Service |
a1bd4f |
device,
|
|
Packit Service |
a1bd4f |
cur_arp_ip_target,
|
|
Packit Service |
a1bd4f |
nm_setting_bond_get_option_or_default(s_bond, NM_SETTING_BOND_OPTION_ARP_IP_TARGET));
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
apply_bonding_config(NMDeviceBond *self)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDevice * device = NM_DEVICE(self);
|
|
Packit Service |
a1bd4f |
NMSettingBond *s_bond;
|
|
Packit Service |
a1bd4f |
NMBondMode mode;
|
|
Packit Service |
a1bd4f |
const char * mode_str;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
s_bond = nm_device_get_applied_setting(device, NM_TYPE_SETTING_BOND);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(s_bond, FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
mode_str = nm_setting_bond_get_option_or_default(s_bond, NM_SETTING_BOND_OPTION_MODE);
|
|
Packit Service |
a1bd4f |
mode = _nm_setting_bond_mode_from_string(mode_str);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(mode != NM_BOND_MODE_UNKNOWN, FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Set mode first, as some other options (e.g. arp_interval) are valid
|
|
Packit Service |
a1bd4f |
* only for certain modes.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
set_bond_attr_or_default(device, s_bond, NM_SETTING_BOND_OPTION_MODE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
set_bond_arp_ip_targets(device, s_bond);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
set_bond_attrs_or_default(device, s_bond, NM_MAKE_STRV(OPTIONS_APPLY_SUBSET));
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static NMActStageReturn
|
|
Packit Service |
a1bd4f |
act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceBond * self = NM_DEVICE_BOND(device);
|
|
Packit Service |
a1bd4f |
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Interface must be down to set bond options */
|
|
Packit Service |
a1bd4f |
nm_device_take_down(device, TRUE);
|
|
Packit Service |
a1bd4f |
if (!apply_bonding_config(self))
|
|
Packit Service |
a1bd4f |
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
Packit Service |
a1bd4f |
else {
|
|
Packit Service |
a1bd4f |
if (!nm_device_hw_addr_set_cloned(device, nm_device_get_applied_connection(device), FALSE))
|
|
Packit Service |
a1bd4f |
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
nm_device_bring_up(device, TRUE, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return ret;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceBond *self = NM_DEVICE_BOND(device);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
nm_device_master_check_slave_physical_port(device, slave, LOGD_BOND);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
if (configure) {
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
nm_device_take_down(slave, TRUE);
|
|
Packit Service |
a1bd4f |
success = nm_platform_link_enslave(nm_device_get_platform(device),
|
|
Packit Service |
a1bd4f |
nm_device_get_ip_ifindex(device),
|
|
Packit Service |
a1bd4f |
nm_device_get_ip_ifindex(slave));
|
|
Packit Service |
a1bd4f |
nm_device_bring_up(slave, TRUE, NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
if (!success) {
|
|
Packit Service |
a1bd4f |
_LOGI(LOGD_BOND, "enslaved bond slave %s: failed", nm_device_get_ip_iface(slave));
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
_LOGI(LOGD_BOND, "enslaved bond slave %s", nm_device_get_ip_iface(slave));
|
|
Packit Service |
a1bd4f |
} else
|
|
Packit Service |
a1bd4f |
_LOGI(LOGD_BOND, "bond slave %s was enslaved", nm_device_get_ip_iface(slave));
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceBond *self = NM_DEVICE_BOND(device);
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
gs_free char *address = NULL;
|
|
Packit Service |
a1bd4f |
int ifindex_slave;
|
|
Packit Service |
a1bd4f |
int ifindex;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (configure) {
|
|
Packit Service |
a1bd4f |
ifindex = nm_device_get_ifindex(device);
|
|
Packit Service |
a1bd4f |
if (ifindex <= 0 || !nm_platform_link_get(nm_device_get_platform(device), ifindex))
|
|
Packit Service |
a1bd4f |
configure = FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
ifindex_slave = nm_device_get_ip_ifindex(slave);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (ifindex_slave <= 0)
|
|
Packit Service |
a1bd4f |
_LOGD(LOGD_BOND, "bond slave %s is already released", nm_device_get_ip_iface(slave));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (configure) {
|
|
Packit Service |
a1bd4f |
/* When the last slave is released the bond MAC will be set to a random
|
|
Packit Service |
a1bd4f |
* value by kernel; remember the current one and restore it afterwards.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
address = g_strdup(nm_device_get_hw_address(device));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (ifindex_slave > 0) {
|
|
Packit Service |
a1bd4f |
success = nm_platform_link_release(nm_device_get_platform(device),
|
|
Packit Service |
a1bd4f |
nm_device_get_ip_ifindex(device),
|
|
Packit Service |
a1bd4f |
ifindex_slave);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (success) {
|
|
Packit Service |
a1bd4f |
_LOGI(LOGD_BOND, "released bond slave %s", nm_device_get_ip_iface(slave));
|
|
Packit Service |
a1bd4f |
} else {
|
|
Packit Service |
a1bd4f |
_LOGW(LOGD_BOND, "failed to release bond slave %s", nm_device_get_ip_iface(slave));
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_platform_process_events(nm_device_get_platform(device));
|
|
Packit Service |
a1bd4f |
if (nm_device_update_hw_address(device))
|
|
Packit Service |
a1bd4f |
nm_device_hw_addr_set(device, address, "restore", FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Kernel bonding code "closes" the slave when releasing it, (which clears
|
|
Packit Service |
a1bd4f |
* IFF_UP), so we must bring it back up here to ensure carrier changes and
|
|
Packit Service |
a1bd4f |
* other state is noticed by the now-released slave.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
if (ifindex_slave > 0) {
|
|
Packit Service |
a1bd4f |
if (!nm_device_bring_up(slave, TRUE, NULL))
|
|
Packit Service |
a1bd4f |
_LOGW(LOGD_BOND, "released bond slave could not be brought up.");
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
} else {
|
|
Packit Service |
a1bd4f |
if (ifindex_slave > 0) {
|
|
Packit Service |
a1bd4f |
_LOGI(LOGD_BOND, "bond slave %s was released", nm_device_get_ip_iface(slave));
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
create_and_realize(NMDevice * device,
|
|
Packit Service |
a1bd4f |
NMConnection * connection,
|
|
Packit Service |
a1bd4f |
NMDevice * parent,
|
|
Packit Service |
a1bd4f |
const NMPlatformLink **out_plink,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
const char *iface = nm_device_get_iface(device);
|
|
Packit Service |
a1bd4f |
int r;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(iface);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
r = nm_platform_link_bond_add(nm_device_get_platform(device), iface, out_plink);
|
|
Packit Service |
a1bd4f |
if (r < 0) {
|
|
Packit Service |
a1bd4f |
g_set_error(error,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR_CREATION_FAILED,
|
|
Packit Service |
a1bd4f |
"Failed to create bond interface '%s' for '%s': %s",
|
|
Packit Service |
a1bd4f |
iface,
|
|
Packit Service |
a1bd4f |
nm_connection_get_id(connection),
|
|
Packit Service |
a1bd4f |
nm_strerror(r));
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
can_reapply_change(NMDevice * device,
|
|
Packit Service |
a1bd4f |
const char *setting_name,
|
|
Packit Service |
a1bd4f |
NMSetting * s_old,
|
|
Packit Service |
a1bd4f |
NMSetting * s_new,
|
|
Packit Service |
a1bd4f |
GHashTable *diffs,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceClass *device_class;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Only handle bond setting here, delegate other settings to parent class */
|
|
Packit Service |
a1bd4f |
if (nm_streq(setting_name, NM_SETTING_BOND_SETTING_NAME)) {
|
|
Packit Service |
a1bd4f |
NMSettingBond *s_a = NM_SETTING_BOND(s_old);
|
|
Packit Service |
a1bd4f |
NMSettingBond *s_b = NM_SETTING_BOND(s_new);
|
|
Packit Service |
a1bd4f |
const char ** option_list;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!nm_device_hash_check_invalid_keys(diffs,
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
error,
|
|
Packit Service |
a1bd4f |
NM_SETTING_BOND_OPTIONS))
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
option_list = nm_setting_bond_get_valid_options(NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
for (; *option_list; ++option_list) {
|
|
Packit Service |
a1bd4f |
const char *name = *option_list;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* We support changes to these */
|
|
Packit Service |
a1bd4f |
if (NM_IN_STRSET(name, OPTIONS_REAPPLY_FULL))
|
|
Packit Service |
a1bd4f |
continue;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Reject any other changes */
|
|
Packit Service |
a1bd4f |
if (!nm_streq0(nm_setting_bond_get_option_normalized(s_a, name),
|
|
Packit Service |
a1bd4f |
nm_setting_bond_get_option_normalized(s_b, name))) {
|
|
Packit Service |
a1bd4f |
g_set_error(error,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
|
Packit Service |
a1bd4f |
"Can't reapply '%s' bond option",
|
|
Packit Service |
a1bd4f |
name);
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device_class = NM_DEVICE_CLASS(nm_device_bond_parent_class);
|
|
Packit Service |
a1bd4f |
return device_class->can_reapply_change(device, setting_name, s_old, s_new, diffs, error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_new)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceBond * self = NM_DEVICE_BOND(device);
|
|
Packit Service |
a1bd4f |
NMSettingBond *s_bond;
|
|
Packit Service |
a1bd4f |
const char * value;
|
|
Packit Service |
a1bd4f |
NMBondMode mode;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NM_DEVICE_CLASS(nm_device_bond_parent_class)->reapply_connection(device, con_old, con_new);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
_LOGD(LOGD_BOND, "reapplying bond settings");
|
|
Packit Service |
a1bd4f |
s_bond = nm_connection_get_setting_bond(con_new);
|
|
Packit Service |
a1bd4f |
g_return_if_fail(s_bond);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
value = nm_setting_bond_get_option_or_default(s_bond, NM_SETTING_BOND_OPTION_MODE);
|
|
Packit Service |
a1bd4f |
mode = _nm_setting_bond_mode_from_string(value);
|
|
Packit Service |
a1bd4f |
g_return_if_fail(mode != NM_BOND_MODE_UNKNOWN);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Below we set only the bond options that kernel allows to modify
|
|
Packit Service |
a1bd4f |
* while keeping the bond interface up */
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
set_bond_arp_ip_targets(device, s_bond);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
set_bond_attrs_or_default(device, s_bond, NM_MAKE_STRV(OPTIONS_REAPPLY_SUBSET));
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_device_bond_init(NMDeviceBond *self)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nm_assert(nm_device_is_master(NM_DEVICE(self)));
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static const NMDBusInterfaceInfoExtended interface_info_device_bond = {
|
|
Packit Service |
a1bd4f |
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT(
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_DEVICE_BOND,
|
|
Packit Service |
a1bd4f |
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS(&nm_signal_info_property_changed_legacy, ),
|
|
Packit Service |
a1bd4f |
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS(
|
|
Packit Service |
a1bd4f |
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L("HwAddress",
|
|
Packit Service |
a1bd4f |
"s",
|
|
Packit Service |
a1bd4f |
NM_DEVICE_HW_ADDRESS),
|
|
Packit Service |
a1bd4f |
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L("Carrier", "b", NM_DEVICE_CARRIER),
|
|
Packit Service |
a1bd4f |
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L("Slaves",
|
|
Packit Service |
a1bd4f |
"ao",
|
|
Packit Service |
a1bd4f |
NM_DEVICE_SLAVES), ), ),
|
|
Packit Service |
a1bd4f |
.legacy_property_changed = TRUE,
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_device_bond_class_init(NMDeviceBondClass *klass)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass);
|
|
Packit Service |
a1bd4f |
NMDeviceClass * device_class = NM_DEVICE_CLASS(klass);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_bond);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
device_class->connection_type_supported = NM_SETTING_BOND_SETTING_NAME;
|
|
Packit Service |
a1bd4f |
device_class->connection_type_check_compatible = NM_SETTING_BOND_SETTING_NAME;
|
|
Packit Service |
a1bd4f |
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_BOND);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
device_class->is_master = TRUE;
|
|
Packit Service |
a1bd4f |
device_class->get_generic_capabilities = get_generic_capabilities;
|
|
Packit Service |
a1bd4f |
device_class->complete_connection = complete_connection;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
device_class->update_connection = update_connection;
|
|
Packit Service |
a1bd4f |
device_class->master_update_slave_connection = master_update_slave_connection;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
device_class->create_and_realize = create_and_realize;
|
|
Packit Service |
a1bd4f |
device_class->act_stage1_prepare = act_stage1_prepare;
|
|
Packit Service |
a1bd4f |
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
|
Packit Service |
a1bd4f |
device_class->enslave_slave = enslave_slave;
|
|
Packit Service |
a1bd4f |
device_class->release_slave = release_slave;
|
|
Packit Service |
a1bd4f |
device_class->can_reapply_change = can_reapply_change;
|
|
Packit Service |
a1bd4f |
device_class->reapply_connection = reapply_connection;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define NM_TYPE_BOND_DEVICE_FACTORY (nm_bond_device_factory_get_type())
|
|
Packit Service |
a1bd4f |
#define NM_BOND_DEVICE_FACTORY(obj) \
|
|
Packit Service |
a1bd4f |
(G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_BOND_DEVICE_FACTORY, NMBondDeviceFactory))
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static NMDevice *
|
|
Packit Service |
a1bd4f |
create_device(NMDeviceFactory * factory,
|
|
Packit Service |
a1bd4f |
const char * iface,
|
|
Packit Service |
a1bd4f |
const NMPlatformLink *plink,
|
|
Packit Service |
a1bd4f |
NMConnection * connection,
|
|
Packit Service |
a1bd4f |
gboolean * out_ignore)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return g_object_new(NM_TYPE_DEVICE_BOND,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_IFACE,
|
|
Packit Service |
a1bd4f |
iface,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_DRIVER,
|
|
Packit Service |
a1bd4f |
"bonding",
|
|
Packit Service |
a1bd4f |
NM_DEVICE_TYPE_DESC,
|
|
Packit Service |
a1bd4f |
"Bond",
|
|
Packit Service |
a1bd4f |
NM_DEVICE_DEVICE_TYPE,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_TYPE_BOND,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_LINK_TYPE,
|
|
Packit Service |
a1bd4f |
NM_LINK_TYPE_BOND,
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
|
Packit Service |
a1bd4f |
BOND,
|
|
Packit Service |
a1bd4f |
Bond,
|
|
Packit Service |
a1bd4f |
bond,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(NM_LINK_TYPE_BOND)
|
|
Packit Service |
a1bd4f |
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_BOND_SETTING_NAME),
|
|
Packit Service |
a1bd4f |
factory_class->create_device = create_device;);
|