mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 17:40:08 +01:00
platform: merge branch 'th/platform-api-cleanup-bgo759261' into master
https://bugzilla.gnome.org/show_bug.cgi?id=759261
This commit is contained in:
commit
9bc7b295a4
24 changed files with 351 additions and 466 deletions
|
|
@ -130,7 +130,7 @@ set_bond_attr (NMDevice *device, const char *attr, const char *value)
|
|||
gboolean ret;
|
||||
int ifindex = nm_device_get_ifindex (device);
|
||||
|
||||
ret = nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, attr, value);
|
||||
ret = nm_platform_sysctl_master_set_option (NM_PLATFORM_GET, ifindex, attr, value);
|
||||
if (!ret)
|
||||
_LOGW (LOGD_HW, "failed to set bonding attribute '%s' to '%s'", attr, value);
|
||||
return ret;
|
||||
|
|
@ -164,7 +164,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
/* Read bond options from sysfs and update the Bond setting to match */
|
||||
options = nm_setting_bond_get_valid_options (s_bond);
|
||||
while (options && *options) {
|
||||
gs_free char *value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, *options);
|
||||
gs_free char *value = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, *options);
|
||||
const char *defvalue = nm_setting_bond_get_option_default (s_bond, *options);
|
||||
|
||||
if (value && !ignore_if_zero (*options, value) && (g_strcmp0 (value, defvalue) != 0)) {
|
||||
|
|
@ -320,7 +320,7 @@ apply_bonding_config (NMDevice *device)
|
|||
}
|
||||
|
||||
/* Clear ARP targets */
|
||||
contents = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "arp_ip_target");
|
||||
contents = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, "arp_ip_target");
|
||||
set_arp_targets (device, contents, " \n", "-");
|
||||
g_free (contents);
|
||||
|
||||
|
|
@ -448,16 +448,15 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
const char *iface = nm_device_get_iface (device);
|
||||
NMPlatformError plerr;
|
||||
|
||||
g_assert (iface);
|
||||
g_assert (out_plink);
|
||||
|
||||
plerr = nm_platform_bond_add (NM_PLATFORM_GET, iface, out_plink);
|
||||
plerr = nm_platform_link_bond_add (NM_PLATFORM_GET, iface, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create bond interface '%s' for '%s': %s",
|
||||
|
|
|
|||
|
|
@ -199,9 +199,9 @@ commit_option (NMDevice *device, NMSetting *setting, const Option *option, gbool
|
|||
|
||||
value = g_strdup_printf ("%u", uval);
|
||||
if (slave)
|
||||
nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value);
|
||||
nm_platform_sysctl_slave_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value);
|
||||
else
|
||||
nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value);
|
||||
nm_platform_sysctl_master_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -245,7 +245,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
}
|
||||
|
||||
for (option = master_options; option->name; option++) {
|
||||
gs_free char *str = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, option->sysname);
|
||||
gs_free char *str = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, option->sysname);
|
||||
int value;
|
||||
|
||||
if (str) {
|
||||
|
|
@ -284,7 +284,7 @@ master_update_slave_connection (NMDevice *device,
|
|||
}
|
||||
|
||||
for (option = slave_options; option->name; option++) {
|
||||
gs_free char *str = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex_slave, option->sysname);
|
||||
gs_free char *str = nm_platform_sysctl_slave_get_option (NM_PLATFORM_GET, ifindex_slave, option->sysname);
|
||||
int value;
|
||||
|
||||
if (str) {
|
||||
|
|
@ -377,7 +377,7 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingBridge *s_bridge;
|
||||
|
|
@ -387,7 +387,6 @@ create_and_realize (NMDevice *device,
|
|||
NMPlatformError plerr;
|
||||
|
||||
g_assert (iface);
|
||||
g_assert (out_plink);
|
||||
|
||||
s_bridge = nm_connection_get_setting_bridge (connection);
|
||||
g_assert (s_bridge);
|
||||
|
|
@ -401,11 +400,11 @@ create_and_realize (NMDevice *device,
|
|||
}
|
||||
}
|
||||
|
||||
plerr = nm_platform_bridge_add (NM_PLATFORM_GET,
|
||||
iface,
|
||||
hwaddr ? mac_address : NULL,
|
||||
hwaddr ? ETH_ALEN : 0,
|
||||
out_plink);
|
||||
plerr = nm_platform_link_bridge_add (NM_PLATFORM_GET,
|
||||
iface,
|
||||
hwaddr ? mac_address : NULL,
|
||||
hwaddr ? ETH_ALEN : 0,
|
||||
out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create bridge interface '%s' for '%s': %s",
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ nm_device_ethernet_init (NMDeviceEthernet *self)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->setup_start (device, plink);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ get_type_description (NMDevice *device)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NMDeviceGeneric *self = NM_DEVICE_GENERIC (device);
|
||||
NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self);
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
|
||||
ifindex = nm_device_get_ifindex (device);
|
||||
if (ifindex > 0) {
|
||||
if (!nm_platform_infiniband_get_properties (NM_PLATFORM_GET, ifindex, NULL, NULL, &transport_mode))
|
||||
if (!nm_platform_link_infiniband_get_properties (NM_PLATFORM_GET, ifindex, NULL, NULL, &transport_mode))
|
||||
transport_mode = "datagram";
|
||||
}
|
||||
g_object_set (G_OBJECT (s_infiniband), NM_SETTING_INFINIBAND_TRANSPORT_MODE, transport_mode, NULL);
|
||||
|
|
@ -236,15 +236,13 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingInfiniband *s_infiniband;
|
||||
int parent_ifindex, p_key;
|
||||
NMPlatformError plerr;
|
||||
|
||||
g_assert (out_plink);
|
||||
|
||||
if (!NM_IS_DEVICE_INFINIBAND (parent)) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Parent interface %s must be an InfiniBand interface",
|
||||
|
|
@ -270,7 +268,7 @@ create_and_realize (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
plerr = nm_platform_infiniband_partition_add (NM_PLATFORM_GET, parent_ifindex, p_key, out_plink);
|
||||
plerr = nm_platform_link_infiniband_add (NM_PLATFORM_GET, parent_ifindex, p_key, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create InfiniBand P_Key interface '%s' for '%s': %s",
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
const char *iface = nm_device_get_iface (device);
|
||||
|
|
@ -628,7 +628,6 @@ create_and_realize (NMDevice *device,
|
|||
|
||||
s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection);
|
||||
g_assert (s_ip_tunnel);
|
||||
g_assert (out_plink);
|
||||
|
||||
switch (nm_setting_ip_tunnel_get_mode (s_ip_tunnel)) {
|
||||
case NM_IP_TUNNEL_MODE_GRE:
|
||||
|
|
@ -771,7 +770,7 @@ create_and_realize (NMDevice *device,
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->setup_start (device, plink);
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
const char *iface = nm_device_get_iface (device);
|
||||
|
|
@ -231,7 +231,6 @@ create_and_realize (NMDevice *device,
|
|||
|
||||
s_macvlan = nm_connection_get_setting_macvlan (connection);
|
||||
g_assert (s_macvlan);
|
||||
g_assert (out_plink);
|
||||
|
||||
parent_ifindex = nm_device_get_ifindex (parent);
|
||||
g_warn_if_fail (parent_ifindex > 0);
|
||||
|
|
@ -559,7 +558,7 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->setup_start (device, plink);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ reload_tun_properties (NMDeviceTun *self)
|
|||
|
||||
ifindex = nm_device_get_ifindex (NM_DEVICE (self));
|
||||
if (ifindex > 0) {
|
||||
if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, ifindex, &props)) {
|
||||
if (!nm_platform_link_tun_get_properties (NM_PLATFORM_GET, ifindex, &props)) {
|
||||
_LOGD (LOGD_DEVICE, "tun-properties: cannot loading tun properties from platform for ifindex %d", ifindex);
|
||||
ifindex = 0;
|
||||
} else if (g_strcmp0 (priv->mode, props.mode) != 0) {
|
||||
|
|
@ -162,7 +162,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
nm_connection_add_setting (connection, (NMSetting *) s_tun);
|
||||
}
|
||||
|
||||
if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
|
||||
if (!nm_platform_link_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
|
||||
_LOGW (LOGD_HW, "failed to get TUN interface info while updating connection.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
const char *iface = nm_device_get_iface (device);
|
||||
|
|
@ -209,18 +209,17 @@ create_and_realize (NMDevice *device,
|
|||
|
||||
s_tun = nm_connection_get_setting_tun (connection);
|
||||
g_assert (s_tun);
|
||||
g_assert (out_plink);
|
||||
|
||||
user = _nm_utils_ascii_str_to_int64 (nm_setting_tun_get_owner (s_tun), 10, 0, G_MAXINT32, -1);
|
||||
group = _nm_utils_ascii_str_to_int64 (nm_setting_tun_get_group (s_tun), 10, 0, G_MAXINT32, -1);
|
||||
|
||||
plerr = nm_platform_tun_add (NM_PLATFORM_GET, iface,
|
||||
nm_setting_tun_get_mode (s_tun) == NM_SETTING_TUN_MODE_TAP,
|
||||
user, group,
|
||||
nm_setting_tun_get_pi (s_tun),
|
||||
nm_setting_tun_get_vnet_hdr (s_tun),
|
||||
nm_setting_tun_get_multi_queue (s_tun),
|
||||
out_plink);
|
||||
plerr = nm_platform_link_tun_add (NM_PLATFORM_GET, iface,
|
||||
nm_setting_tun_get_mode (s_tun) == NM_SETTING_TUN_MODE_TAP,
|
||||
user, group,
|
||||
nm_setting_tun_get_pi (s_tun),
|
||||
nm_setting_tun_get_vnet_hdr (s_tun),
|
||||
nm_setting_tun_get_multi_queue (s_tun),
|
||||
out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create TUN/TAP interface '%s' for '%s': %s",
|
||||
|
|
@ -241,7 +240,7 @@ realize (NMDevice *device, NMPlatformLink *plink, GError **error)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_tun_parent_class)->setup_start (device, plink);
|
||||
reload_tun_properties (device);
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ get_peer (NMDeviceVeth *self)
|
|||
if (priv->ever_had_peer)
|
||||
return priv->peer;
|
||||
|
||||
if (!nm_platform_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &peer_ifindex)) {
|
||||
if (!nm_platform_link_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &peer_ifindex)) {
|
||||
_LOGW (LOGD_HW, "could not read veth properties");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
|
||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
||||
|
|
@ -207,7 +207,7 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
|
||||
|
|
@ -216,8 +216,6 @@ create_and_realize (NMDevice *device,
|
|||
int parent_ifindex, vlan_id;
|
||||
NMPlatformError plerr;
|
||||
|
||||
g_assert (out_plink);
|
||||
|
||||
s_vlan = nm_connection_get_setting_vlan (connection);
|
||||
g_assert (s_vlan);
|
||||
|
||||
|
|
@ -234,12 +232,12 @@ create_and_realize (NMDevice *device,
|
|||
|
||||
vlan_id = nm_setting_vlan_get_id (s_vlan);
|
||||
|
||||
plerr = nm_platform_vlan_add (NM_PLATFORM_GET,
|
||||
iface,
|
||||
parent_ifindex,
|
||||
vlan_id,
|
||||
nm_setting_vlan_get_flags (s_vlan),
|
||||
out_plink);
|
||||
plerr = nm_platform_link_vlan_add (NM_PLATFORM_GET,
|
||||
iface,
|
||||
parent_ifindex,
|
||||
vlan_id,
|
||||
nm_setting_vlan_get_flags (s_vlan),
|
||||
out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create VLAN interface '%s' for '%s': %s",
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ link_changed (NMDevice *device, NMPlatformLink *info)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
g_assert (plink->type == NM_LINK_TYPE_VXLAN);
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
const char *iface = nm_device_get_iface (device);
|
||||
|
|
@ -186,7 +186,6 @@ create_and_realize (NMDevice *device,
|
|||
|
||||
s_vxlan = nm_connection_get_setting_vxlan (connection);
|
||||
g_assert (s_vxlan);
|
||||
g_assert (out_plink);
|
||||
|
||||
if (parent)
|
||||
props.parent_ifindex = nm_device_get_ifindex (parent);
|
||||
|
|
|
|||
|
|
@ -1761,7 +1761,8 @@ nm_device_create_and_realize (NMDevice *self,
|
|||
GError **error)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMPlatformLink plink = { .type = NM_LINK_TYPE_UNKNOWN };
|
||||
NMPlatformLink plink_copy;
|
||||
const NMPlatformLink *plink = NULL;
|
||||
|
||||
/* Must be set before device is realized */
|
||||
priv->is_nm_owned = !nm_platform_link_get_by_ifname (NM_PLATFORM_GET, priv->iface);
|
||||
|
|
@ -1770,17 +1771,19 @@ nm_device_create_and_realize (NMDevice *self,
|
|||
if (NM_DEVICE_GET_CLASS (self)->create_and_realize) {
|
||||
if (!NM_DEVICE_GET_CLASS (self)->create_and_realize (self, connection, parent, &plink, error))
|
||||
return FALSE;
|
||||
plink_copy = *plink;
|
||||
plink = &plink_copy;
|
||||
}
|
||||
|
||||
NM_DEVICE_GET_CLASS (self)->setup_start (self, (plink.type != NM_LINK_TYPE_UNKNOWN) ? &plink : NULL);
|
||||
nm_device_setup_finish (self, (plink.type != NM_LINK_TYPE_UNKNOWN) ? &plink : NULL);
|
||||
NM_DEVICE_GET_CLASS (self)->setup_start (self, plink);
|
||||
nm_device_setup_finish (self, plink);
|
||||
|
||||
g_return_val_if_fail (nm_device_check_connection_compatible (self, connection), TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_device_from_platform_link (NMDevice *self, NMPlatformLink *plink)
|
||||
update_device_from_platform_link (NMDevice *self, const NMPlatformLink *plink)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
const char *udi;
|
||||
|
|
@ -1836,7 +1839,7 @@ check_carrier (NMDevice *self)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *self, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *self, const NMPlatformLink *plink)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
static guint32 id = 0;
|
||||
|
|
@ -1943,7 +1946,7 @@ setup_start (NMDevice *self, NMPlatformLink *plink)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_finish (NMDevice *self, NMPlatformLink *plink)
|
||||
setup_finish (NMDevice *self, const NMPlatformLink *plink)
|
||||
{
|
||||
if (plink) {
|
||||
update_device_from_platform_link (self, plink);
|
||||
|
|
@ -1952,7 +1955,7 @@ setup_finish (NMDevice *self, NMPlatformLink *plink)
|
|||
}
|
||||
|
||||
void
|
||||
nm_device_setup_finish (NMDevice *self, NMPlatformLink *plink)
|
||||
nm_device_setup_finish (NMDevice *self, const NMPlatformLink *plink)
|
||||
{
|
||||
g_return_if_fail (!plink || link_type_compatible (self, plink->type, NULL, NULL));
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,9 @@ typedef struct {
|
|||
* @self: the #NMDevice
|
||||
* @connection: the #NMConnection being activated
|
||||
* @parent: the parent #NMDevice, if any
|
||||
* @out_plink: on success, a backing kernel network device if one exists
|
||||
* @out_plink: on success, a backing kernel network device if one exists.
|
||||
* The returned pointer is owned by platform and only valid until the
|
||||
* next platform operation.
|
||||
* @error: location to store error, or %NULL
|
||||
*
|
||||
* Create any backing resources (kernel devices, etc) required for this
|
||||
|
|
@ -183,7 +185,7 @@ typedef struct {
|
|||
gboolean (*create_and_realize) (NMDevice *self,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error);
|
||||
|
||||
/**
|
||||
|
|
@ -197,7 +199,7 @@ typedef struct {
|
|||
* any tasks that affect other interfaces (like master/slave or parent/child
|
||||
* stuff).
|
||||
*/
|
||||
void (*setup_start) (NMDevice *self, NMPlatformLink *plink);
|
||||
void (*setup_start) (NMDevice *self, const NMPlatformLink *plink);
|
||||
|
||||
/**
|
||||
* setup_finish():
|
||||
|
|
@ -208,7 +210,7 @@ typedef struct {
|
|||
* backing resource properties. After this function finishes, the device
|
||||
* is ready for network connectivity.
|
||||
*/
|
||||
void (*setup_finish) (NMDevice *self, NMPlatformLink *plink);
|
||||
void (*setup_finish) (NMDevice *self, const NMPlatformLink *plink);
|
||||
|
||||
/**
|
||||
* unrealize():
|
||||
|
|
@ -509,7 +511,7 @@ gboolean nm_device_create_and_realize (NMDevice *self,
|
|||
NMDevice *parent,
|
||||
GError **error);
|
||||
void nm_device_setup_finish (NMDevice *self,
|
||||
NMPlatformLink *plink);
|
||||
const NMPlatformLink *plink);
|
||||
gboolean nm_device_unrealize (NMDevice *device,
|
||||
gboolean remove_resources,
|
||||
GError **error);
|
||||
|
|
|
|||
|
|
@ -673,13 +673,13 @@ static gboolean
|
|||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
NMPlatformLink *out_plink,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
const char *iface = nm_device_get_iface (device);
|
||||
NMPlatformError plerr;
|
||||
|
||||
plerr = nm_platform_team_add (NM_PLATFORM_GET, iface, out_plink);
|
||||
plerr = nm_platform_link_team_add (NM_PLATFORM_GET, iface, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create team master interface '%s' for '%s': %s",
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ periodic_update_cb (gpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, NMPlatformLink *plink)
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_wifi_parent_class)->setup_start (device, plink);
|
||||
|
||||
|
|
|
|||
|
|
@ -292,10 +292,11 @@ link_add (NMPlatform *platform,
|
|||
NMLinkType type,
|
||||
const void *address,
|
||||
size_t address_len,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
||||
NMFakePlatformLink device;
|
||||
NMFakePlatformLink *new_device;
|
||||
|
||||
link_init (&device, priv->links->len, type, name);
|
||||
|
||||
|
|
@ -306,6 +307,7 @@ link_add (NMPlatform *platform,
|
|||
}
|
||||
|
||||
g_array_append_val (priv->links, device);
|
||||
new_device = &g_array_index (priv->links, NMFakePlatformLink, priv->links->len - 1);
|
||||
|
||||
if (device.link.ifindex) {
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, NMP_OBJECT_TYPE_LINK, device.link.ifindex, &device, NM_PLATFORM_SIGNAL_ADDED);
|
||||
|
|
@ -314,7 +316,7 @@ link_add (NMPlatform *platform,
|
|||
}
|
||||
|
||||
if (out_link)
|
||||
*out_link = device.link;
|
||||
*out_link = &new_device->link;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -640,43 +642,11 @@ link_release (NMPlatform *platform, int master_idx, int slave_idx)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
master_set_option (NMPlatform *platform, int master, const char *option, const char *value)
|
||||
{
|
||||
gs_free char *path = g_strdup_printf ("master:%d:%s", master, option);
|
||||
|
||||
return sysctl_set (platform, path, value);
|
||||
}
|
||||
|
||||
static char *
|
||||
master_get_option (NMPlatform *platform, int master, const char *option)
|
||||
{
|
||||
gs_free char *path = g_strdup_printf ("master:%d:%s", master, option);
|
||||
|
||||
return sysctl_get (platform, path);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
slave_set_option (NMPlatform *platform, int slave, const char *option, const char *value)
|
||||
{
|
||||
gs_free char *path = g_strdup_printf ("slave:%d:%s", slave, option);
|
||||
|
||||
return sysctl_set (platform, path, value);
|
||||
}
|
||||
|
||||
static char *
|
||||
slave_get_option (NMPlatform *platform, int slave, const char *option)
|
||||
{
|
||||
gs_free char *path = g_strdup_printf ("slave:%d:%s", slave, option);
|
||||
|
||||
return sysctl_get (platform, path);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint32 vlan_flags, NMPlatformLink *out_link)
|
||||
vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint32 vlan_flags, const NMPlatformLink **out_link)
|
||||
{
|
||||
NMFakePlatformLink *device;
|
||||
|
||||
if (!link_add (platform, name, NM_LINK_TYPE_VLAN, NULL, 0, NULL))
|
||||
if (!link_add (platform, name, NM_LINK_TYPE_VLAN, NULL, 0, out_link))
|
||||
return FALSE;
|
||||
|
||||
device = link_get (platform, nm_platform_link_get_ifindex (platform, name));
|
||||
|
|
@ -689,7 +659,7 @@ vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint
|
|||
device->link.parent = parent;
|
||||
|
||||
if (out_link)
|
||||
*out_link = device->link;
|
||||
*out_link = &device->link;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -712,11 +682,11 @@ static gboolean
|
|||
link_vxlan_add (NMPlatform *platform,
|
||||
const char *name,
|
||||
NMPlatformLnkVxlan *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMFakePlatformLink *device;
|
||||
|
||||
if (!link_add (platform, name, NM_LINK_TYPE_VXLAN, NULL, 0, NULL))
|
||||
if (!link_add (platform, name, NM_LINK_TYPE_VXLAN, NULL, 0, out_link))
|
||||
return FALSE;
|
||||
|
||||
device = link_get (platform, nm_platform_link_get_ifindex (platform, name));
|
||||
|
|
@ -729,12 +699,12 @@ link_vxlan_add (NMPlatform *platform,
|
|||
device->link.parent = props->parent_ifindex;
|
||||
|
||||
if (out_link)
|
||||
*out_link = device->link;
|
||||
*out_link = &device->link;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatformLink *out_link)
|
||||
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
|
||||
{
|
||||
NMFakePlatformLink *device, *parent_device;
|
||||
gs_free char *name = NULL;
|
||||
|
|
@ -1476,10 +1446,6 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass)
|
|||
|
||||
platform_class->link_enslave = link_enslave;
|
||||
platform_class->link_release = link_release;
|
||||
platform_class->master_set_option = master_set_option;
|
||||
platform_class->master_get_option = master_get_option;
|
||||
platform_class->slave_set_option = slave_set_option;
|
||||
platform_class->slave_get_option = slave_get_option;
|
||||
|
||||
platform_class->vlan_add = vlan_add;
|
||||
platform_class->link_vlan_change = link_vlan_change;
|
||||
|
|
|
|||
|
|
@ -618,7 +618,7 @@ _linktype_get_type (NMPlatform *platform,
|
|||
NMPlatformTunProperties props;
|
||||
|
||||
if ( platform
|
||||
&& nm_platform_tun_get_properties_ifname (platform, ifname, &props)) {
|
||||
&& nm_platform_link_tun_get_properties_ifname (platform, ifname, &props)) {
|
||||
if (!g_strcmp0 (props.mode, "tap"))
|
||||
return NM_LINK_TYPE_TAP;
|
||||
if (!g_strcmp0 (props.mode, "tun"))
|
||||
|
|
@ -3592,7 +3592,7 @@ do_add_link_with_lookup (NMPlatform *platform,
|
|||
NMLinkType link_type,
|
||||
const char *name,
|
||||
struct nl_msg *nlmsg,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
const NMPObject *obj;
|
||||
|
||||
|
|
@ -3600,8 +3600,8 @@ do_add_link_with_lookup (NMPlatform *platform,
|
|||
|
||||
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
|
||||
0, name, FALSE, link_type, NULL, NULL);
|
||||
if (out_link && obj)
|
||||
*out_link = obj->link;
|
||||
if (out_link)
|
||||
*out_link = obj ? &obj->link : NULL;
|
||||
return !!obj;
|
||||
}
|
||||
|
||||
|
|
@ -3801,7 +3801,7 @@ link_add (NMPlatform *platform,
|
|||
NMLinkType type,
|
||||
const void *address,
|
||||
size_t address_len,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
|
||||
|
|
@ -4160,7 +4160,7 @@ vlan_add (NMPlatform *platform,
|
|||
int parent,
|
||||
int vlan_id,
|
||||
guint32 vlan_flags,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
|
||||
|
|
@ -4204,7 +4204,7 @@ static int
|
|||
link_gre_add (NMPlatform *platform,
|
||||
const char *name,
|
||||
NMPlatformLnkGre *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
struct nlattr *info;
|
||||
|
|
@ -4259,7 +4259,7 @@ static int
|
|||
link_ip6tnl_add (NMPlatform *platform,
|
||||
const char *name,
|
||||
NMPlatformLnkIp6Tnl *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
struct nlattr *info;
|
||||
|
|
@ -4320,7 +4320,7 @@ static int
|
|||
link_ipip_add (NMPlatform *platform,
|
||||
const char *name,
|
||||
NMPlatformLnkIpIp *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
struct nlattr *info;
|
||||
|
|
@ -4372,7 +4372,7 @@ link_macvlan_add (NMPlatform *platform,
|
|||
const char *name,
|
||||
int parent,
|
||||
NMPlatformLnkMacvlan *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
struct nlattr *info;
|
||||
|
|
@ -4420,7 +4420,7 @@ static int
|
|||
link_sit_add (NMPlatform *platform,
|
||||
const char *name,
|
||||
NMPlatformLnkSit *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
struct nlattr *info;
|
||||
|
|
@ -4471,7 +4471,7 @@ static gboolean
|
|||
link_vxlan_add (NMPlatform *platform,
|
||||
const char *name,
|
||||
NMPlatformLnkVxlan *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
struct nlattr *info;
|
||||
|
|
@ -4714,61 +4714,61 @@ link_vlan_change (NMPlatform *platform,
|
|||
static int
|
||||
tun_add (NMPlatform *platform, const char *name, gboolean tap,
|
||||
gint64 owner, gint64 group, gboolean pi, gboolean vnet_hdr,
|
||||
gboolean multi_queue, NMPlatformLink *out_link)
|
||||
gboolean multi_queue, const NMPlatformLink **out_link)
|
||||
{
|
||||
const NMPObject *obj;
|
||||
struct ifreq ifr = { };
|
||||
int fd;
|
||||
const NMPObject *obj;
|
||||
struct ifreq ifr = { };
|
||||
int fd;
|
||||
|
||||
_LOGD ("link: add %s '%s' owner %" G_GINT64_FORMAT " group %" G_GINT64_FORMAT,
|
||||
tap ? "tap" : "tun", name, owner, group);
|
||||
_LOGD ("link: add %s '%s' owner %" G_GINT64_FORMAT " group %" G_GINT64_FORMAT,
|
||||
tap ? "tap" : "tun", name, owner, group);
|
||||
|
||||
fd = open ("/dev/net/tun", O_RDWR);
|
||||
if (fd < 0)
|
||||
return FALSE;
|
||||
fd = open ("/dev/net/tun", O_RDWR);
|
||||
if (fd < 0)
|
||||
return FALSE;
|
||||
|
||||
strncpy (ifr.ifr_name, name, IFNAMSIZ);
|
||||
ifr.ifr_flags = tap ? IFF_TAP : IFF_TUN;
|
||||
strncpy (ifr.ifr_name, name, IFNAMSIZ);
|
||||
ifr.ifr_flags = tap ? IFF_TAP : IFF_TUN;
|
||||
|
||||
if (!pi)
|
||||
ifr.ifr_flags |= IFF_NO_PI;
|
||||
if (vnet_hdr)
|
||||
ifr.ifr_flags |= IFF_VNET_HDR;
|
||||
if (multi_queue)
|
||||
ifr.ifr_flags |= NM_IFF_MULTI_QUEUE;
|
||||
if (!pi)
|
||||
ifr.ifr_flags |= IFF_NO_PI;
|
||||
if (vnet_hdr)
|
||||
ifr.ifr_flags |= IFF_VNET_HDR;
|
||||
if (multi_queue)
|
||||
ifr.ifr_flags |= NM_IFF_MULTI_QUEUE;
|
||||
|
||||
if (ioctl (fd, TUNSETIFF, &ifr)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
if (ioctl (fd, TUNSETIFF, &ifr)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (owner >= 0 && owner < G_MAXINT32) {
|
||||
if (ioctl (fd, TUNSETOWNER, (uid_t) owner)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (owner >= 0 && owner < G_MAXINT32) {
|
||||
if (ioctl (fd, TUNSETOWNER, (uid_t) owner)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (group >= 0 && group < G_MAXINT32) {
|
||||
if (ioctl (fd, TUNSETGROUP, (gid_t) group)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (group >= 0 && group < G_MAXINT32) {
|
||||
if (ioctl (fd, TUNSETGROUP, (gid_t) group)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (ioctl (fd, TUNSETPERSIST, 1)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
do_request_link (platform, 0, name, TRUE);
|
||||
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
|
||||
0, name, FALSE,
|
||||
tap ? NM_LINK_TYPE_TAP : NM_LINK_TYPE_TUN,
|
||||
NULL, NULL);
|
||||
if (out_link && obj)
|
||||
*out_link = obj->link;
|
||||
if (ioctl (fd, TUNSETPERSIST, 1)) {
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
do_request_link (platform, 0, name, TRUE);
|
||||
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
|
||||
0, name, FALSE,
|
||||
tap ? NM_LINK_TYPE_TAP : NM_LINK_TYPE_TUN,
|
||||
NULL, NULL);
|
||||
if (out_link)
|
||||
*out_link = obj ? &obj->link : NULL;
|
||||
|
||||
return !!obj;
|
||||
return !!obj;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -4801,93 +4801,10 @@ link_release (NMPlatform *platform, int master, int slave)
|
|||
return link_enslave (platform, 0, slave);
|
||||
}
|
||||
|
||||
static char *
|
||||
link_option_path (NMPlatform *platform, int master, const char *category, const char *option)
|
||||
{
|
||||
const char *name = nm_platform_link_get_name (platform, master);
|
||||
|
||||
if (!name || !category || !option)
|
||||
return NULL;
|
||||
|
||||
return g_strdup_printf ("/sys/class/net/%s/%s/%s",
|
||||
ASSERT_VALID_PATH_COMPONENT (name),
|
||||
ASSERT_VALID_PATH_COMPONENT (category),
|
||||
ASSERT_VALID_PATH_COMPONENT (option));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
link_set_option (NMPlatform *platform, int master, const char *category, const char *option, const char *value)
|
||||
{
|
||||
gs_free char *path = link_option_path (platform, master, category, option);
|
||||
|
||||
return path && nm_platform_sysctl_set (platform, path, value);
|
||||
}
|
||||
|
||||
static char *
|
||||
link_get_option (NMPlatform *platform, int master, const char *category, const char *option)
|
||||
{
|
||||
gs_free char *path = link_option_path (platform, master, category, option);
|
||||
|
||||
return path ? nm_platform_sysctl_get (platform, path) : NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
master_category (NMPlatform *platform, int master)
|
||||
{
|
||||
switch (nm_platform_link_get_type (platform, master)) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
return "bridge";
|
||||
case NM_LINK_TYPE_BOND:
|
||||
return "bonding";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
slave_category (NMPlatform *platform, int slave)
|
||||
{
|
||||
int master = nm_platform_link_get_master (platform, slave);
|
||||
|
||||
if (master <= 0)
|
||||
return NULL;
|
||||
|
||||
switch (nm_platform_link_get_type (platform, master)) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
return "brport";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
master_set_option (NMPlatform *platform, int master, const char *option, const char *value)
|
||||
{
|
||||
return link_set_option (platform, master, master_category (platform, master), option, value);
|
||||
}
|
||||
|
||||
static char *
|
||||
master_get_option (NMPlatform *platform, int master, const char *option)
|
||||
{
|
||||
return link_get_option (platform, master, master_category (platform, master), option);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
slave_set_option (NMPlatform *platform, int slave, const char *option, const char *value)
|
||||
{
|
||||
return link_set_option (platform, slave, slave_category (platform, slave), option, value);
|
||||
}
|
||||
|
||||
static char *
|
||||
slave_get_option (NMPlatform *platform, int slave, const char *option)
|
||||
{
|
||||
return link_get_option (platform, slave, slave_category (platform, slave), option);
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static gboolean
|
||||
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatformLink *out_link)
|
||||
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
const NMPObject *obj_parent;
|
||||
|
|
@ -4911,8 +4828,8 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatfor
|
|||
|
||||
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
|
||||
0, ifname, FALSE, NM_LINK_TYPE_INFINIBAND, NULL, NULL);
|
||||
if (out_link && obj)
|
||||
*out_link = obj->link;
|
||||
if (out_link)
|
||||
*out_link = obj ? &obj->link : NULL;
|
||||
return !!obj;
|
||||
}
|
||||
|
||||
|
|
@ -5967,10 +5884,6 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||
|
||||
platform_class->link_enslave = link_enslave;
|
||||
platform_class->link_release = link_release;
|
||||
platform_class->master_set_option = master_set_option;
|
||||
platform_class->master_get_option = master_get_option;
|
||||
platform_class->slave_set_option = slave_set_option;
|
||||
platform_class->slave_get_option = slave_get_option;
|
||||
|
||||
platform_class->vlan_add = vlan_add;
|
||||
platform_class->link_vlan_change = link_vlan_change;
|
||||
|
|
|
|||
|
|
@ -281,7 +281,6 @@ nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value)
|
|||
|
||||
g_return_val_if_fail (path, FALSE);
|
||||
g_return_val_if_fail (value, FALSE);
|
||||
g_return_val_if_fail (klass->sysctl_set, FALSE);
|
||||
|
||||
return klass->sysctl_set (self, path, value);
|
||||
}
|
||||
|
|
@ -333,7 +332,6 @@ nm_platform_sysctl_get (NMPlatform *self, const char *path)
|
|||
_CHECK_SELF (self, klass, NULL);
|
||||
|
||||
g_return_val_if_fail (path, NULL);
|
||||
g_return_val_if_fail (klass->sysctl_get, NULL);
|
||||
|
||||
return klass->sysctl_get (self, path);
|
||||
}
|
||||
|
|
@ -413,8 +411,6 @@ nm_platform_link_get_all (NMPlatform *self)
|
|||
|
||||
_CHECK_SELF (self, klass, NULL);
|
||||
|
||||
g_return_val_if_fail (klass->link_get_all, NULL);
|
||||
|
||||
links = klass->link_get_all (self);
|
||||
|
||||
if (!links || links->len == 0)
|
||||
|
|
@ -571,7 +567,7 @@ nm_platform_link_get_by_address (NMPlatform *self,
|
|||
}
|
||||
|
||||
static NMPlatformError
|
||||
_link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, NMPlatformLink *out_link)
|
||||
_link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, const NMPlatformLink **out_link)
|
||||
{
|
||||
const NMPlatformLink *pllink;
|
||||
|
||||
|
|
@ -586,11 +582,13 @@ _link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, N
|
|||
wrong_type ? ", expected " : "",
|
||||
wrong_type ? nm_link_type_to_string (type) : "");
|
||||
if (out_link)
|
||||
*out_link = *pllink;
|
||||
*out_link = pllink;
|
||||
if (wrong_type)
|
||||
return NM_PLATFORM_ERROR_WRONG_TYPE;
|
||||
return NM_PLATFORM_ERROR_EXISTS;
|
||||
}
|
||||
if (out_link)
|
||||
*out_link = NULL;
|
||||
return NM_PLATFORM_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -619,14 +617,13 @@ nm_platform_link_add (NMPlatform *self,
|
|||
NMLinkType type,
|
||||
const void *address,
|
||||
size_t address_len,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
|
||||
_CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (klass->link_add, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail ( (address != NULL) ^ (address_len == 0) , NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
plerr = _link_add_check_existing (self, name, type, out_link);
|
||||
|
|
@ -640,7 +637,7 @@ nm_platform_link_add (NMPlatform *self,
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_platform_dummy_add:
|
||||
* nm_platform_link_dummy_add:
|
||||
* @self: platform instance
|
||||
* @name: New interface name
|
||||
* @out_link: on success, the link object
|
||||
|
|
@ -648,7 +645,7 @@ nm_platform_link_add (NMPlatform *self,
|
|||
* Create a software ethernet-like interface
|
||||
*/
|
||||
NMPlatformError
|
||||
nm_platform_dummy_add (NMPlatform *self, const char *name, NMPlatformLink *out_link)
|
||||
nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link)
|
||||
{
|
||||
return nm_platform_link_add (self, name, NM_LINK_TYPE_DUMMY, NULL, 0, out_link);
|
||||
}
|
||||
|
|
@ -742,8 +739,6 @@ nm_platform_link_get_type_name (NMPlatform *self, int ifindex)
|
|||
{
|
||||
_CHECK_SELF (self, klass, NULL);
|
||||
|
||||
g_return_val_if_fail (klass->link_get_type_name, NULL);
|
||||
|
||||
return klass->link_get_type_name (self, ifindex);
|
||||
}
|
||||
|
||||
|
|
@ -969,7 +964,6 @@ nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolea
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex >= 0, FALSE);
|
||||
g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE);
|
||||
|
||||
if (klass->link_set_user_ipv6ll_enabled)
|
||||
return klass->link_set_user_ipv6ll_enabled (self, ifindex, enabled);
|
||||
|
|
@ -992,7 +986,6 @@ nm_platform_link_set_address (NMPlatform *self, int ifindex, gconstpointer addre
|
|||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (address, FALSE);
|
||||
g_return_val_if_fail (length > 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_set_address, FALSE);
|
||||
|
||||
_LOGD ("link: setting '%s' (%d) hardware address", nm_platform_link_get_name (self, ifindex), ifindex);
|
||||
return klass->link_set_address (self, ifindex, address, length);
|
||||
|
|
@ -1071,7 +1064,6 @@ nm_platform_link_supports_carrier_detect (NMPlatform *self, int ifindex)
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex >= 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_supports_carrier_detect, FALSE);
|
||||
|
||||
return klass->link_supports_carrier_detect (self, ifindex);
|
||||
}
|
||||
|
|
@ -1082,7 +1074,6 @@ nm_platform_link_supports_vlans (NMPlatform *self, int ifindex)
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex >= 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_supports_vlans, FALSE);
|
||||
|
||||
return klass->link_supports_vlans (self, ifindex);
|
||||
}
|
||||
|
|
@ -1101,7 +1092,6 @@ nm_platform_link_set_up (NMPlatform *self, int ifindex, gboolean *out_no_firmwar
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_set_up, FALSE);
|
||||
|
||||
_LOGD ("link: setting up '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex);
|
||||
return klass->link_set_up (self, ifindex, out_no_firmware);
|
||||
|
|
@ -1120,7 +1110,6 @@ nm_platform_link_set_down (NMPlatform *self, int ifindex)
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_set_down, FALSE);
|
||||
|
||||
_LOGD ("link: setting down '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex);
|
||||
return klass->link_set_down (self, ifindex);
|
||||
|
|
@ -1139,7 +1128,6 @@ nm_platform_link_set_arp (NMPlatform *self, int ifindex)
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex >= 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_set_arp, FALSE);
|
||||
|
||||
_LOGD ("link: setting arp '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex);
|
||||
return klass->link_set_arp (self, ifindex);
|
||||
|
|
@ -1158,7 +1146,6 @@ nm_platform_link_set_noarp (NMPlatform *self, int ifindex)
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex >= 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_set_noarp, FALSE);
|
||||
|
||||
_LOGD ("link: setting noarp '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex);
|
||||
return klass->link_set_noarp (self, ifindex);
|
||||
|
|
@ -1179,7 +1166,6 @@ nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu)
|
|||
|
||||
g_return_val_if_fail (ifindex >= 0, FALSE);
|
||||
g_return_val_if_fail (mtu > 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_set_mtu, FALSE);
|
||||
|
||||
_LOGD ("link: setting '%s' (%d) mtu %"G_GUINT32_FORMAT, nm_platform_link_get_name (self, ifindex), ifindex, mtu);
|
||||
return klass->link_set_mtu (self, ifindex, mtu);
|
||||
|
|
@ -1294,7 +1280,6 @@ nm_platform_link_get_driver_info (NMPlatform *self,
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex >= 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_get_driver_info, FALSE);
|
||||
|
||||
return klass->link_get_driver_info (self,
|
||||
ifindex,
|
||||
|
|
@ -1318,7 +1303,6 @@ nm_platform_link_enslave (NMPlatform *self, int master, int slave)
|
|||
|
||||
g_return_val_if_fail (master > 0, FALSE);
|
||||
g_return_val_if_fail (slave> 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_enslave, FALSE);
|
||||
|
||||
_LOGD ("link: enslaving '%s' (%d) to master '%s' (%d)",
|
||||
nm_platform_link_get_name (self, slave), slave,
|
||||
|
|
@ -1341,7 +1325,6 @@ nm_platform_link_release (NMPlatform *self, int master, int slave)
|
|||
|
||||
g_return_val_if_fail (master > 0, FALSE);
|
||||
g_return_val_if_fail (slave > 0, FALSE);
|
||||
g_return_val_if_fail (klass->link_release, FALSE);
|
||||
|
||||
if (nm_platform_link_get_master (self, slave) != master)
|
||||
return FALSE;
|
||||
|
|
@ -1474,7 +1457,7 @@ nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformL
|
|||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_platform_bridge_add:
|
||||
* nm_platform_link_bridge_add:
|
||||
* @self: platform instance
|
||||
* @name: New interface name
|
||||
* @address: (allow-none): set the mac address of the new bridge
|
||||
|
|
@ -1484,17 +1467,17 @@ nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformL
|
|||
* Create a software bridge.
|
||||
*/
|
||||
NMPlatformError
|
||||
nm_platform_bridge_add (NMPlatform *self,
|
||||
const char *name,
|
||||
const void *address,
|
||||
size_t address_len,
|
||||
NMPlatformLink *out_link)
|
||||
nm_platform_link_bridge_add (NMPlatform *self,
|
||||
const char *name,
|
||||
const void *address,
|
||||
size_t address_len,
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
return nm_platform_link_add (self, name, NM_LINK_TYPE_BRIDGE, address, address_len, out_link);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_bond_add:
|
||||
* nm_platform_link_bond_add:
|
||||
* @self: platform instance
|
||||
* @name: New interface name
|
||||
* @out_link: on success, the link object
|
||||
|
|
@ -1502,13 +1485,13 @@ nm_platform_bridge_add (NMPlatform *self,
|
|||
* Create a software bonding device.
|
||||
*/
|
||||
NMPlatformError
|
||||
nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_link)
|
||||
nm_platform_link_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link)
|
||||
{
|
||||
return nm_platform_link_add (self, name, NM_LINK_TYPE_BOND, NULL, 0, out_link);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_team_add:
|
||||
* nm_platform_link_team_add:
|
||||
* @self: platform instance
|
||||
* @name: New interface name
|
||||
* @out_link: on success, the link object
|
||||
|
|
@ -1516,13 +1499,13 @@ nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_li
|
|||
* Create a software teaming device.
|
||||
*/
|
||||
NMPlatformError
|
||||
nm_platform_team_add (NMPlatform *self, const char *name, NMPlatformLink *out_link)
|
||||
nm_platform_link_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link)
|
||||
{
|
||||
return nm_platform_link_add (self, name, NM_LINK_TYPE_TEAM, NULL, 0, out_link);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_vlan_add:
|
||||
* nm_platform_link_vlan_add:
|
||||
* @self: platform instance
|
||||
* @name: New interface name
|
||||
* @vlanid: VLAN identifier
|
||||
|
|
@ -1532,12 +1515,12 @@ nm_platform_team_add (NMPlatform *self, const char *name, NMPlatformLink *out_li
|
|||
* Create a software VLAN device.
|
||||
*/
|
||||
NMPlatformError
|
||||
nm_platform_vlan_add (NMPlatform *self,
|
||||
nm_platform_link_vlan_add (NMPlatform *self,
|
||||
const char *name,
|
||||
int parent,
|
||||
int vlanid,
|
||||
guint32 vlanflags,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
|
||||
|
|
@ -1546,7 +1529,6 @@ nm_platform_vlan_add (NMPlatform *self,
|
|||
g_return_val_if_fail (parent >= 0, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (vlanid >= 0, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (klass->vlan_add, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
plerr = _link_add_check_existing (self, name, NM_LINK_TYPE_VLAN, out_link);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS)
|
||||
|
|
@ -1572,7 +1554,7 @@ NMPlatformError
|
|||
nm_platform_link_vxlan_add (NMPlatform *self,
|
||||
const char *name,
|
||||
NMPlatformLnkVxlan *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
|
||||
|
|
@ -1592,7 +1574,7 @@ nm_platform_link_vxlan_add (NMPlatform *self,
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_platform_tun_add:
|
||||
* nm_platform_link_tun_add:
|
||||
* @self: platform instance
|
||||
* @name: new interface name
|
||||
* @tap: whether the interface is a TAP
|
||||
|
|
@ -1606,16 +1588,21 @@ nm_platform_link_vxlan_add (NMPlatform *self,
|
|||
* Create a TUN or TAP interface.
|
||||
*/
|
||||
NMPlatformError
|
||||
nm_platform_tun_add (NMPlatform *self, const char *name, gboolean tap,
|
||||
gint64 owner, gint64 group, gboolean pi, gboolean vnet_hdr,
|
||||
gboolean multi_queue, NMPlatformLink *out_link)
|
||||
nm_platform_link_tun_add (NMPlatform *self,
|
||||
const char *name,
|
||||
gboolean tap,
|
||||
gint64 owner,
|
||||
gint64 group,
|
||||
gboolean pi,
|
||||
gboolean vnet_hdr,
|
||||
gboolean multi_queue,
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
|
||||
_CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (klass->tun_add, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
plerr = _link_add_check_existing (self, name, tap ? NM_LINK_TYPE_TAP : NM_LINK_TYPE_TUN, out_link);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS)
|
||||
|
|
@ -1628,56 +1615,115 @@ nm_platform_tun_add (NMPlatform *self, const char *name, gboolean tap,
|
|||
return NM_PLATFORM_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static char *
|
||||
link_option_path (NMPlatform *self, int master, const char *category, const char *option)
|
||||
{
|
||||
const char *name = nm_platform_link_get_name (self, master);
|
||||
|
||||
if (!name || !category || !option)
|
||||
return NULL;
|
||||
|
||||
return g_strdup_printf ("/sys/class/net/%s/%s/%s",
|
||||
ASSERT_VALID_PATH_COMPONENT (name),
|
||||
ASSERT_VALID_PATH_COMPONENT (category),
|
||||
ASSERT_VALID_PATH_COMPONENT (option));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
link_set_option (NMPlatform *self, int master, const char *category, const char *option, const char *value)
|
||||
{
|
||||
gs_free char *path = link_option_path (self, master, category, option);
|
||||
|
||||
return path && nm_platform_sysctl_set (self, path, value);
|
||||
}
|
||||
|
||||
static char *
|
||||
link_get_option (NMPlatform *self, int master, const char *category, const char *option)
|
||||
{
|
||||
gs_free char *path = link_option_path (self, master, category, option);
|
||||
|
||||
return path ? nm_platform_sysctl_get (self, path) : NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
master_category (NMPlatform *self, int master)
|
||||
{
|
||||
switch (nm_platform_link_get_type (self, master)) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
return "bridge";
|
||||
case NM_LINK_TYPE_BOND:
|
||||
return "bonding";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
slave_category (NMPlatform *self, int slave)
|
||||
{
|
||||
int master = nm_platform_link_get_master (self, slave);
|
||||
|
||||
if (master <= 0)
|
||||
return NULL;
|
||||
|
||||
switch (nm_platform_link_get_type (self, master)) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
return "brport";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value)
|
||||
nm_platform_sysctl_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (option, FALSE);
|
||||
g_return_val_if_fail (value, FALSE);
|
||||
g_return_val_if_fail (klass->master_set_option, FALSE);
|
||||
|
||||
return klass->master_set_option (self, ifindex, option, value);
|
||||
return link_set_option (self, ifindex, master_category (self, ifindex), option, value);
|
||||
}
|
||||
|
||||
char *
|
||||
nm_platform_master_get_option (NMPlatform *self, int ifindex, const char *option)
|
||||
nm_platform_sysctl_master_get_option (NMPlatform *self, int ifindex, const char *option)
|
||||
{
|
||||
_CHECK_SELF (self, klass, NULL);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (option, FALSE);
|
||||
g_return_val_if_fail (klass->master_set_option, FALSE);
|
||||
|
||||
return klass->master_get_option (self, ifindex, option);
|
||||
return link_get_option (self, ifindex, master_category (self, ifindex), option);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value)
|
||||
nm_platform_sysctl_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (option, FALSE);
|
||||
g_return_val_if_fail (value, FALSE);
|
||||
g_return_val_if_fail (klass->slave_set_option, FALSE);
|
||||
|
||||
return klass->slave_set_option (self, ifindex, option, value);
|
||||
return link_set_option (self, ifindex, slave_category (self, ifindex), option, value);
|
||||
}
|
||||
|
||||
char *
|
||||
nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option)
|
||||
nm_platform_sysctl_slave_get_option (NMPlatform *self, int ifindex, const char *option)
|
||||
{
|
||||
_CHECK_SELF (self, klass, NULL);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (option, FALSE);
|
||||
g_return_val_if_fail (klass->slave_set_option, FALSE);
|
||||
|
||||
return klass->slave_get_option (self, ifindex, option);
|
||||
return link_get_option (self, ifindex, slave_category (self, ifindex), option);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_platform_link_vlan_change (NMPlatform *self,
|
||||
int ifindex,
|
||||
|
|
@ -1745,7 +1791,7 @@ nm_platform_link_vlan_change (NMPlatform *self,
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to)
|
||||
nm_platform_link_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to)
|
||||
{
|
||||
NMVlanQosMapping map = {
|
||||
.from = from,
|
||||
|
|
@ -1756,7 +1802,7 @@ nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int t
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to)
|
||||
nm_platform_link_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to)
|
||||
{
|
||||
NMVlanQosMapping map = {
|
||||
.from = from,
|
||||
|
|
@ -1779,7 +1825,7 @@ NMPlatformError
|
|||
nm_platform_link_gre_add (NMPlatform *self,
|
||||
const char *name,
|
||||
NMPlatformLnkGre *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
char buffer[INET_ADDRSTRLEN];
|
||||
|
|
@ -1806,7 +1852,7 @@ nm_platform_link_gre_add (NMPlatform *self,
|
|||
}
|
||||
|
||||
NMPlatformError
|
||||
nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, NMPlatformLink *out_link)
|
||||
nm_platform_link_infiniband_add (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link)
|
||||
{
|
||||
gs_free char *parent_name = NULL;
|
||||
gs_free char *name = NULL;
|
||||
|
|
@ -1816,7 +1862,6 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, N
|
|||
|
||||
g_return_val_if_fail (parent >= 0, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (p_key >= 0, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (klass->infiniband_partition_add, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
parent_name = g_strdup (nm_platform_link_get_name (self, parent));
|
||||
if ( !parent_name
|
||||
|
|
@ -1836,11 +1881,11 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, N
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_infiniband_get_properties (NMPlatform *self,
|
||||
int ifindex,
|
||||
int *out_parent,
|
||||
int *out_p_key,
|
||||
const char **out_mode)
|
||||
nm_platform_link_infiniband_get_properties (NMPlatform *self,
|
||||
int ifindex,
|
||||
int *out_parent,
|
||||
int *out_p_key,
|
||||
const char **out_mode)
|
||||
{
|
||||
const NMPlatformLnkInfiniband *plnk;
|
||||
const NMPlatformLink *plink;
|
||||
|
|
@ -1915,7 +1960,7 @@ NMPlatformError
|
|||
nm_platform_link_ip6tnl_add (NMPlatform *self,
|
||||
const char *name,
|
||||
NMPlatformLnkIp6Tnl *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
char buffer[INET6_ADDRSTRLEN];
|
||||
|
|
@ -1954,7 +1999,7 @@ NMPlatformError
|
|||
nm_platform_link_ipip_add (NMPlatform *self,
|
||||
const char *name,
|
||||
NMPlatformLnkIpIp *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
char buffer[INET_ADDRSTRLEN];
|
||||
|
|
@ -1994,7 +2039,7 @@ nm_platform_link_macvlan_add (NMPlatform *self,
|
|||
const char *name,
|
||||
int parent,
|
||||
NMPlatformLnkMacvlan *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
NMLinkType type;
|
||||
|
|
@ -2034,7 +2079,7 @@ NMPlatformError
|
|||
nm_platform_link_sit_add (NMPlatform *self,
|
||||
const char *name,
|
||||
NMPlatformLnkSit *props,
|
||||
NMPlatformLink *out_link)
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
char buffer[INET_ADDRSTRLEN];
|
||||
|
|
@ -2061,7 +2106,7 @@ nm_platform_link_sit_add (NMPlatform *self,
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex)
|
||||
nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex)
|
||||
{
|
||||
const NMPlatformLink *plink;
|
||||
int peer_ifindex;
|
||||
|
|
@ -2091,7 +2136,7 @@ nm_platform_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_if
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_tun_get_properties_ifname (NMPlatform *self, const char *ifname, NMPlatformTunProperties *props)
|
||||
nm_platform_link_tun_get_properties_ifname (NMPlatform *self, const char *ifname, NMPlatformTunProperties *props)
|
||||
{
|
||||
char *path, *val;
|
||||
gboolean success = TRUE;
|
||||
|
|
@ -2152,14 +2197,14 @@ nm_platform_tun_get_properties_ifname (NMPlatform *self, const char *ifname, NMP
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props)
|
||||
nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (props != NULL, FALSE);
|
||||
|
||||
return nm_platform_tun_get_properties_ifname (self, nm_platform_link_get_name (self, ifindex), props);
|
||||
return nm_platform_link_tun_get_properties_ifname (self, nm_platform_link_get_name (self, ifindex), props);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -2349,7 +2394,6 @@ nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex)
|
|||
_CHECK_SELF (self, klass, NULL);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, NULL);
|
||||
g_return_val_if_fail (klass->ip4_address_get_all, NULL);
|
||||
|
||||
return klass->ip4_address_get_all (self, ifindex);
|
||||
}
|
||||
|
|
@ -2360,7 +2404,6 @@ nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex)
|
|||
_CHECK_SELF (self, klass, NULL);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, NULL);
|
||||
g_return_val_if_fail (klass->ip6_address_get_all, NULL);
|
||||
|
||||
return klass->ip6_address_get_all (self, ifindex);
|
||||
}
|
||||
|
|
@ -2381,7 +2424,6 @@ nm_platform_ip4_address_add (NMPlatform *self,
|
|||
g_return_val_if_fail (plen > 0, FALSE);
|
||||
g_return_val_if_fail (lifetime > 0, FALSE);
|
||||
g_return_val_if_fail (preferred <= lifetime, FALSE);
|
||||
g_return_val_if_fail (klass->ip4_address_add, FALSE);
|
||||
g_return_val_if_fail (!label || strlen (label) < sizeof (((NMPlatformIP4Address *) NULL)->label), FALSE);
|
||||
|
||||
if (_LOGD_ENABLED ()) {
|
||||
|
|
@ -2418,7 +2460,6 @@ nm_platform_ip6_address_add (NMPlatform *self,
|
|||
g_return_val_if_fail (plen > 0, FALSE);
|
||||
g_return_val_if_fail (lifetime > 0, FALSE);
|
||||
g_return_val_if_fail (preferred <= lifetime, FALSE);
|
||||
g_return_val_if_fail (klass->ip6_address_add, FALSE);
|
||||
|
||||
if (_LOGD_ENABLED ()) {
|
||||
NMPlatformIP6Address addr = { 0 };
|
||||
|
|
@ -2448,7 +2489,6 @@ nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address
|
|||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (plen > 0, FALSE);
|
||||
g_return_val_if_fail (klass->ip4_address_delete, FALSE);
|
||||
|
||||
_LOGD ("address: deleting IPv4 address %s/%d, %sifindex %d%s",
|
||||
nm_utils_inet4_ntop (address, NULL), plen,
|
||||
|
|
@ -2468,7 +2508,6 @@ nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr a
|
|||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (plen > 0, FALSE);
|
||||
g_return_val_if_fail (klass->ip6_address_delete, FALSE);
|
||||
|
||||
_LOGD ("address: deleting IPv6 address %s/%d, ifindex %d%s",
|
||||
nm_utils_inet6_ntop (&address, NULL), plen, ifindex,
|
||||
|
|
@ -2701,7 +2740,6 @@ nm_platform_ip4_route_add (NMPlatform *self,
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (0 <= plen && plen <= 32, FALSE);
|
||||
g_return_val_if_fail (klass->ip4_route_add, FALSE);
|
||||
|
||||
if (_LOGD_ENABLED ()) {
|
||||
NMPlatformIP4Route route = { 0 };
|
||||
|
|
@ -2729,7 +2767,6 @@ nm_platform_ip6_route_add (NMPlatform *self,
|
|||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (0 <= plen && plen <= 128, FALSE);
|
||||
g_return_val_if_fail (klass->ip6_route_add, FALSE);
|
||||
|
||||
if (_LOGD_ENABLED ()) {
|
||||
NMPlatformIP6Route route = { 0 };
|
||||
|
|
@ -2754,8 +2791,6 @@ nm_platform_ip4_route_delete (NMPlatform *self, int ifindex, in_addr_t network,
|
|||
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (klass->ip4_route_delete, FALSE);
|
||||
|
||||
_LOGD ("route: deleting IPv4 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s",
|
||||
nm_utils_inet4_ntop (network, NULL), plen, metric, ifindex,
|
||||
_to_string_dev (self, ifindex, str_dev, sizeof (str_dev)));
|
||||
|
|
@ -2769,8 +2804,6 @@ nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6_addr net
|
|||
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (klass->ip6_route_delete, FALSE);
|
||||
|
||||
_LOGD ("route: deleting IPv6 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s",
|
||||
nm_utils_inet6_ntop (&network, NULL), plen, metric, ifindex,
|
||||
_to_string_dev (self, ifindex, str_dev, sizeof (str_dev)));
|
||||
|
|
|
|||
|
|
@ -456,34 +456,6 @@ typedef struct {
|
|||
|
||||
/******************************************************************/
|
||||
|
||||
/* NMPlatform abstract class and its implementations provide a layer between
|
||||
* networkmanager's device management classes and the operating system kernel.
|
||||
*
|
||||
* How it works, is best seen in tests/nm-platform-test.c source file.
|
||||
*
|
||||
* NMPlatform provides interface to configure kernel interfaces and receive
|
||||
* notifications about both internal and external configuration changes. It
|
||||
* respects the following rules:
|
||||
*
|
||||
* 1) Every change made through NMPlatform is readily available and the respective
|
||||
* signals are called synchronously.
|
||||
*
|
||||
* 2) State of an object retrieved from NMPlatform (through functions or events)
|
||||
* is at least as recent than the state retrieved before.
|
||||
*
|
||||
* Any failure of the above rules should be fixed in NMPlatform implementations
|
||||
* and tested in nm-platform-test. Synchronization hacks should never be put
|
||||
* to any other code. That's why NMPlatform was created and that's why the
|
||||
* testing code was written for it.
|
||||
*
|
||||
* In future, parts of linux platform implementation may be moved to the libnl
|
||||
* library.
|
||||
*
|
||||
* If you have any problems related to NMPlatform on your system, you should
|
||||
* always first run tests/nm-linux-platform-test as root and with all
|
||||
* network configuration daemons stopped. Look at the code first.
|
||||
*/
|
||||
|
||||
struct _NMPlatform {
|
||||
GObject parent;
|
||||
};
|
||||
|
|
@ -506,7 +478,7 @@ typedef struct {
|
|||
NMLinkType type,
|
||||
const void *address,
|
||||
size_t address_len,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
gboolean (*link_delete) (NMPlatform *, int ifindex);
|
||||
const char *(*link_get_type_name) (NMPlatform *, int ifindex);
|
||||
gboolean (*link_get_unmanaged) (NMPlatform *, int ifindex, gboolean *unmanaged);
|
||||
|
|
@ -545,12 +517,8 @@ typedef struct {
|
|||
|
||||
gboolean (*link_enslave) (NMPlatform *, int master, int slave);
|
||||
gboolean (*link_release) (NMPlatform *, int master, int slave);
|
||||
gboolean (*master_set_option) (NMPlatform *, int ifindex, const char *option, const char *value);
|
||||
char * (*master_get_option) (NMPlatform *, int ifindex, const char *option);
|
||||
gboolean (*slave_set_option) (NMPlatform *, int ifindex, const char *option, const char *value);
|
||||
char * (*slave_get_option) (NMPlatform *, int ifindex, const char *option);
|
||||
|
||||
gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags, NMPlatformLink *out_link);
|
||||
gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link);
|
||||
gboolean (*link_vlan_change) (NMPlatform *self,
|
||||
int ifindex,
|
||||
NMVlanFlags flags_mask,
|
||||
|
|
@ -562,23 +530,23 @@ typedef struct {
|
|||
const NMVlanQosMapping *egress_map,
|
||||
gsize n_egress_map);
|
||||
gboolean (*link_vxlan_add) (NMPlatform *, const char *name, NMPlatformLnkVxlan *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
|
||||
gboolean (*link_gre_add) (NMPlatform *, const char *name, NMPlatformLnkGre *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
gboolean (*link_ip6tnl_add) (NMPlatform *, const char *name, NMPlatformLnkIp6Tnl *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
gboolean (*link_ipip_add) (NMPlatform *, const char *name, NMPlatformLnkIpIp *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
gboolean (*link_macvlan_add) (NMPlatform *, const char *name, int parent, NMPlatformLnkMacvlan *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
gboolean (*link_sit_add) (NMPlatform *, const char *name, NMPlatformLnkSit *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
|
||||
gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, NMPlatformLink *out_link);
|
||||
gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, const NMPlatformLink **out_link);
|
||||
|
||||
gboolean (*tun_add) (NMPlatform *platform, const char *name, gboolean tap, gint64 owner, gint64 group, gboolean pi,
|
||||
gboolean vnet_hdr, gboolean multi_queue, NMPlatformLink *out_link);
|
||||
gboolean vnet_hdr, gboolean multi_queue, const NMPlatformLink **out_link);
|
||||
|
||||
gboolean (*wifi_get_capabilities) (NMPlatform *, int ifindex, NMDeviceWifiCapabilities *caps);
|
||||
gboolean (*wifi_get_bssid) (NMPlatform *, int ifindex, guint8 *bssid);
|
||||
|
|
@ -700,10 +668,10 @@ const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const ch
|
|||
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length);
|
||||
|
||||
GArray *nm_platform_link_get_all (NMPlatform *self);
|
||||
NMPlatformError nm_platform_dummy_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
|
||||
NMPlatformError nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, NMPlatformLink *out_link);
|
||||
NMPlatformError nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
|
||||
NMPlatformError nm_platform_team_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
|
||||
NMPlatformError nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
||||
NMPlatformError nm_platform_link_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, const NMPlatformLink **out_link);
|
||||
NMPlatformError nm_platform_link_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
||||
NMPlatformError nm_platform_link_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
||||
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
|
||||
|
||||
/* convienience methods to lookup the link and access fields of NMPlatformLink. */
|
||||
|
|
@ -756,10 +724,11 @@ gboolean nm_platform_link_supports_vlans (NMPlatform *self, int ifindex);
|
|||
|
||||
gboolean nm_platform_link_enslave (NMPlatform *self, int master, int slave);
|
||||
gboolean nm_platform_link_release (NMPlatform *self, int master, int slave);
|
||||
gboolean nm_platform_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
|
||||
char *nm_platform_master_get_option (NMPlatform *self, int ifindex, const char *option);
|
||||
gboolean nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
|
||||
char *nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option);
|
||||
|
||||
gboolean nm_platform_sysctl_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
|
||||
char *nm_platform_sysctl_master_get_option (NMPlatform *self, int ifindex, const char *option);
|
||||
gboolean nm_platform_sysctl_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
|
||||
char *nm_platform_sysctl_slave_get_option (NMPlatform *self, int ifindex, const char *option);
|
||||
|
||||
const NMPObject *nm_platform_link_get_lnk (NMPlatform *self, int ifindex, NMLinkType link_type, const NMPlatformLink **out_link);
|
||||
const NMPlatformLnkGre *nm_platform_link_get_lnk_gre (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
||||
|
|
@ -773,9 +742,9 @@ const NMPlatformLnkSit *nm_platform_link_get_lnk_sit (NMPlatform *self, int ifin
|
|||
const NMPlatformLnkVlan *nm_platform_link_get_lnk_vlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
||||
const NMPlatformLnkVxlan *nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
||||
|
||||
NMPlatformError nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, NMPlatformLink *out_link);
|
||||
gboolean nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to);
|
||||
gboolean nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to);
|
||||
NMPlatformError nm_platform_link_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link);
|
||||
gboolean nm_platform_link_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to);
|
||||
gboolean nm_platform_link_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to);
|
||||
gboolean nm_platform_link_vlan_change (NMPlatform *self,
|
||||
int ifindex,
|
||||
NMVlanFlags flags_mask,
|
||||
|
|
@ -787,18 +756,25 @@ gboolean nm_platform_link_vlan_change (NMPlatform *self,
|
|||
const NMVlanQosMapping *egress_map,
|
||||
gsize n_egress_map);
|
||||
|
||||
NMPlatformError nm_platform_link_vxlan_add (NMPlatform *self, const char *name, NMPlatformLnkVxlan *props, NMPlatformLink *out_link);
|
||||
NMPlatformError nm_platform_link_vxlan_add (NMPlatform *self, const char *name, NMPlatformLnkVxlan *props, const NMPlatformLink **out_link);
|
||||
|
||||
NMPlatformError nm_platform_tun_add (NMPlatform *self, const char *name, gboolean tap, gint64 owner, gint64 group, gboolean pi,
|
||||
gboolean vnet_hdr, gboolean multi_queue, NMPlatformLink *out_link);
|
||||
NMPlatformError nm_platform_link_tun_add (NMPlatform *self,
|
||||
const char *name,
|
||||
gboolean tap,
|
||||
gint64 owner,
|
||||
gint64 group,
|
||||
gboolean pi,
|
||||
gboolean vnet_hdr,
|
||||
gboolean multi_queue,
|
||||
const NMPlatformLink **out_link);
|
||||
|
||||
NMPlatformError nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, NMPlatformLink *out_link);
|
||||
gboolean nm_platform_infiniband_get_properties (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode);
|
||||
NMPlatformError nm_platform_link_infiniband_add (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link);
|
||||
gboolean nm_platform_link_infiniband_get_properties (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode);
|
||||
|
||||
gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex);
|
||||
gboolean nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties);
|
||||
gboolean nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex);
|
||||
gboolean nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties);
|
||||
|
||||
gboolean nm_platform_tun_get_properties_ifname (NMPlatform *platform, const char *ifname, NMPlatformTunProperties *props);
|
||||
gboolean nm_platform_link_tun_get_properties_ifname (NMPlatform *platform, const char *ifname, NMPlatformTunProperties *props);
|
||||
|
||||
gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps);
|
||||
gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid);
|
||||
|
|
@ -821,15 +797,15 @@ const struct in6_addr *nm_platform_ip6_address_get_peer (const NMPlatformIP6Addr
|
|||
const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
|
||||
|
||||
NMPlatformError nm_platform_link_gre_add (NMPlatform *self, const char *name, NMPlatformLnkGre *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
NMPlatformError nm_platform_link_ip6tnl_add (NMPlatform *self, const char *name, NMPlatformLnkIp6Tnl *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
NMPlatformError nm_platform_link_ipip_add (NMPlatform *self, const char *name, NMPlatformLnkIpIp *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
NMPlatformError nm_platform_link_macvlan_add (NMPlatform *self, const char *name, int parent, NMPlatformLnkMacvlan *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
NMPlatformError nm_platform_link_sit_add (NMPlatform *self, const char *name, NMPlatformLnkSit *props,
|
||||
NMPlatformLink *out_link);
|
||||
const NMPlatformLink **out_link);
|
||||
|
||||
const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
|
||||
GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex);
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ _g_test_run (gconstpointer user_data)
|
|||
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert_cmpint (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL), ==, NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert_cmpint (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL), ==, NM_PLATFORM_ERROR_SUCCESS);
|
||||
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
g_assert_cmpint (ifindex, >, 0);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ test_cleanup_internal (void)
|
|||
inet_pton (AF_INET6, "2001:db8:e:f:1:2:3:4", &gateway6);
|
||||
|
||||
/* Create and set up device */
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
accept_signal (link_added);
|
||||
free_signal (link_added);
|
||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME), NULL));
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ test_bogus(void)
|
|||
g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
|
||||
g_assert (!nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL));
|
||||
g_assert (!nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
|
||||
g_assert (!nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
|
||||
g_assert (!nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
|
||||
g_assert (!nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -83,15 +83,15 @@ software_add (NMLinkType link_type, const char *name)
|
|||
{
|
||||
switch (link_type) {
|
||||
case NM_LINK_TYPE_DUMMY:
|
||||
return nm_platform_dummy_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
return nm_platform_link_dummy_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
return nm_platform_bridge_add (NM_PLATFORM_GET, name, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
return nm_platform_link_bridge_add (NM_PLATFORM_GET, name, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
case NM_LINK_TYPE_BOND:
|
||||
{
|
||||
gboolean bond0_exists = !!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, "bond0");
|
||||
NMPlatformError plerr;
|
||||
|
||||
plerr = nm_platform_bond_add (NM_PLATFORM_GET, name, NULL);
|
||||
plerr = nm_platform_link_bond_add (NM_PLATFORM_GET, name, NULL);
|
||||
|
||||
/* Check that bond0 is *not* automatically created. */
|
||||
if (!bond0_exists)
|
||||
|
|
@ -99,14 +99,14 @@ software_add (NMLinkType link_type, const char *name)
|
|||
return plerr == NM_PLATFORM_ERROR_SUCCESS;
|
||||
}
|
||||
case NM_LINK_TYPE_TEAM:
|
||||
return nm_platform_team_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
return nm_platform_link_team_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
case NM_LINK_TYPE_VLAN: {
|
||||
SignalData *parent_added;
|
||||
SignalData *parent_changed;
|
||||
|
||||
/* Don't call link_callback for the bridge interface */
|
||||
parent_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, PARENT_NAME);
|
||||
if (nm_platform_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS)
|
||||
if (nm_platform_link_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS)
|
||||
accept_signal (parent_added);
|
||||
free_signal (parent_added);
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ software_add (NMLinkType link_type, const char *name)
|
|||
accept_signal (parent_changed);
|
||||
free_signal (parent_changed);
|
||||
|
||||
return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
return nm_platform_link_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
|
@ -274,8 +274,8 @@ test_slave (int master, int type, SignalData *master_changed)
|
|||
switch (type) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
if (nmtstp_is_sysfs_writable ()) {
|
||||
g_assert (nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, "priority", "789"));
|
||||
value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, "priority");
|
||||
g_assert (nm_platform_sysctl_slave_set_option (NM_PLATFORM_GET, ifindex, "priority", "789"));
|
||||
value = nm_platform_sysctl_slave_get_option (NM_PLATFORM_GET, ifindex, "priority");
|
||||
g_assert_cmpstr (value, ==, "789");
|
||||
g_free (value);
|
||||
}
|
||||
|
|
@ -367,16 +367,16 @@ test_software (NMLinkType link_type, const char *link_typename)
|
|||
switch (link_type) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
if (nmtstp_is_sysfs_writable ()) {
|
||||
g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "789"));
|
||||
value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay");
|
||||
g_assert (nm_platform_sysctl_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "789"));
|
||||
value = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay");
|
||||
g_assert_cmpstr (value, ==, "789");
|
||||
g_free (value);
|
||||
}
|
||||
break;
|
||||
case NM_LINK_TYPE_BOND:
|
||||
if (nmtstp_is_sysfs_writable ()) {
|
||||
g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup"));
|
||||
value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "mode");
|
||||
g_assert (nm_platform_sysctl_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup"));
|
||||
value = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, "mode");
|
||||
/* When reading back, the output looks slightly different. */
|
||||
g_assert (g_str_has_prefix (value, "active-backup"));
|
||||
g_free (value);
|
||||
|
|
@ -462,11 +462,13 @@ test_bridge_addr (void)
|
|||
{
|
||||
char addr[ETH_ALEN];
|
||||
NMPlatformLink link;
|
||||
const NMPlatformLink *plink;
|
||||
const NMPlatformLink *plink = NULL;
|
||||
|
||||
nm_utils_hwaddr_aton ("de:ad:be:ef:00:11", addr, sizeof (addr));
|
||||
|
||||
g_assert_cmpint (nm_platform_bridge_add (NM_PLATFORM_GET, DEVICE_NAME, addr, sizeof (addr), &link), ==, NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert_cmpint (nm_platform_link_bridge_add (NM_PLATFORM_GET, DEVICE_NAME, addr, sizeof (addr), &plink), ==, NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert (plink);
|
||||
link = *plink;
|
||||
g_assert_cmpstr (link.name, ==, DEVICE_NAME);
|
||||
|
||||
g_assert_cmpint (link.addr.len, ==, sizeof (addr));
|
||||
|
|
@ -516,11 +518,11 @@ test_internal (void)
|
|||
g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
|
||||
/* Add device */
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
accept_signal (link_added);
|
||||
|
||||
/* Try to add again */
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_EXISTS);
|
||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_EXISTS);
|
||||
|
||||
/* Check device index, name and type */
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
|
|
@ -1090,58 +1092,58 @@ test_vlan_set_xgress (void)
|
|||
|
||||
/* ingress-qos-map */
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 4, 5));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 4, 5));
|
||||
_assert_ingress_qos_mappings (ifindex, 1,
|
||||
4, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 3, 7));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 3, 7));
|
||||
_assert_ingress_qos_mappings (ifindex, 2,
|
||||
3, 7,
|
||||
4, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 3, 8));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 3, 8));
|
||||
_assert_ingress_qos_mappings (ifindex, 2,
|
||||
3, 8,
|
||||
4, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 4));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 4));
|
||||
_assert_ingress_qos_mappings (ifindex, 3,
|
||||
0, 4,
|
||||
3, 8,
|
||||
4, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, G_MAXUINT32));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, G_MAXUINT32));
|
||||
_assert_ingress_qos_mappings (ifindex, 3,
|
||||
0, G_MAXUINT32,
|
||||
3, 8,
|
||||
4, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, G_MAXUINT32 - 1));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, G_MAXUINT32 - 1));
|
||||
_assert_ingress_qos_mappings (ifindex, 3,
|
||||
0, G_MAXUINT32 - 1,
|
||||
3, 8,
|
||||
4, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 5));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 5));
|
||||
_assert_ingress_qos_mappings (ifindex, 3,
|
||||
0, 5,
|
||||
3, 8,
|
||||
4, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 5));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 5));
|
||||
_assert_ingress_qos_mappings (ifindex, 3,
|
||||
0, 5,
|
||||
3, 8,
|
||||
4, 5);
|
||||
|
||||
/* Set invalid values: */
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 8, 3));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 8, 3));
|
||||
_assert_ingress_qos_mappings (ifindex, 3,
|
||||
0, 5,
|
||||
3, 8,
|
||||
4, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 9, 4));
|
||||
g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 9, 4));
|
||||
_assert_ingress_qos_mappings (ifindex, 3,
|
||||
0, 5,
|
||||
3, 8,
|
||||
|
|
@ -1149,36 +1151,36 @@ test_vlan_set_xgress (void)
|
|||
|
||||
/* egress-qos-map */
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 7, 3));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 7, 3));
|
||||
_assert_egress_qos_mappings (ifindex, 1,
|
||||
7, 3);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 4));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 4));
|
||||
_assert_egress_qos_mappings (ifindex, 2,
|
||||
7, 3,
|
||||
8, 4);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 0, 4));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 0, 4));
|
||||
_assert_egress_qos_mappings (ifindex, 3,
|
||||
0, 4,
|
||||
7, 3,
|
||||
8, 4);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 4));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 4));
|
||||
_assert_egress_qos_mappings (ifindex, 4,
|
||||
0, 4,
|
||||
1, 4,
|
||||
7, 3,
|
||||
8, 4);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 5));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 5));
|
||||
_assert_egress_qos_mappings (ifindex, 4,
|
||||
0, 4,
|
||||
1, 5,
|
||||
7, 3,
|
||||
8, 4);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 9, 5));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 9, 5));
|
||||
_assert_egress_qos_mappings (ifindex, 5,
|
||||
0, 4,
|
||||
1, 5,
|
||||
|
|
@ -1186,7 +1188,7 @@ test_vlan_set_xgress (void)
|
|||
8, 4,
|
||||
9, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 5));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 5));
|
||||
_assert_egress_qos_mappings (ifindex, 5,
|
||||
0, 4,
|
||||
1, 5,
|
||||
|
|
@ -1194,27 +1196,27 @@ test_vlan_set_xgress (void)
|
|||
8, 5,
|
||||
9, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 0));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 0));
|
||||
_assert_egress_qos_mappings (ifindex, 4,
|
||||
0, 4,
|
||||
1, 5,
|
||||
7, 3,
|
||||
9, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 0, 0));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 0, 0));
|
||||
_assert_egress_qos_mappings (ifindex, 3,
|
||||
1, 5,
|
||||
7, 3,
|
||||
9, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 100, 4));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 100, 4));
|
||||
_assert_egress_qos_mappings (ifindex, 4,
|
||||
1, 5,
|
||||
7, 3,
|
||||
9, 5,
|
||||
100, 4);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 4));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 4));
|
||||
_assert_egress_qos_mappings (ifindex, 5,
|
||||
1, 5,
|
||||
7, 3,
|
||||
|
|
@ -1222,7 +1224,7 @@ test_vlan_set_xgress (void)
|
|||
100, 4,
|
||||
G_MAXUINT32, 4);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 8));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 8));
|
||||
_assert_egress_qos_mappings (ifindex, 5,
|
||||
1, 5,
|
||||
7, 3,
|
||||
|
|
@ -1230,20 +1232,20 @@ test_vlan_set_xgress (void)
|
|||
100, 4,
|
||||
G_MAXUINT32, 4);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 0));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 0));
|
||||
_assert_egress_qos_mappings (ifindex, 4,
|
||||
1, 5,
|
||||
7, 3,
|
||||
9, 5,
|
||||
100, 4);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 100, 0));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 100, 0));
|
||||
_assert_egress_qos_mappings (ifindex, 3,
|
||||
1, 5,
|
||||
7, 3,
|
||||
9, 5);
|
||||
|
||||
g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 0));
|
||||
g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 0));
|
||||
_assert_egress_qos_mappings (ifindex, 2,
|
||||
7, 3,
|
||||
9, 5);
|
||||
|
|
@ -1557,11 +1559,11 @@ test_nl_bugs_veth (void)
|
|||
ifindex_veth0 = nmtstp_assert_wait_for_link (IFACE_VETH0, NM_LINK_TYPE_VETH, 100)->ifindex;
|
||||
ifindex_veth1 = nmtstp_assert_wait_for_link (IFACE_VETH1, NM_LINK_TYPE_VETH, 100)->ifindex;
|
||||
|
||||
/* assert that nm_platform_veth_get_properties() returns the expected peer ifindexes. */
|
||||
g_assert (nm_platform_veth_get_properties (NM_PLATFORM_GET, ifindex_veth0, &i));
|
||||
/* assert that nm_platform_link_veth_get_properties() returns the expected peer ifindexes. */
|
||||
g_assert (nm_platform_link_veth_get_properties (NM_PLATFORM_GET, ifindex_veth0, &i));
|
||||
g_assert_cmpint (i, ==, ifindex_veth1);
|
||||
|
||||
g_assert (nm_platform_veth_get_properties (NM_PLATFORM_GET, ifindex_veth1, &i));
|
||||
g_assert (nm_platform_link_veth_get_properties (NM_PLATFORM_GET, ifindex_veth1, &i));
|
||||
g_assert_cmpint (i, ==, ifindex_veth0);
|
||||
|
||||
/* assert that NMPlatformLink.parent is the peer-ifindex. */
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ setup_tests (void)
|
|||
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
accept_signal (link_added);
|
||||
free_signal (link_added);
|
||||
|
||||
|
|
|
|||
|
|
@ -876,7 +876,7 @@ fixture_setup (test_fixture *fixture, gconstpointer user_data)
|
|||
"nm-test-device0");
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0"));
|
||||
g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, "nm-test-device0"));
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device0", NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, "nm-test-device0", NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
accept_signal (link_added);
|
||||
free_signal (link_added);
|
||||
fixture->ifindex0 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0");
|
||||
|
|
@ -888,7 +888,7 @@ fixture_setup (test_fixture *fixture, gconstpointer user_data)
|
|||
"nm-test-device1");
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1"));
|
||||
g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, "nm-test-device1"));
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device1", NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, "nm-test-device1", NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
accept_signal (link_added);
|
||||
free_signal (link_added);
|
||||
fixture->ifindex1 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue