mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 11:08:03 +02:00
platform: merge several platform backports from master into nm-1-0
Backport these patches to have everything in platform up to a certain point of master.
This commit is contained in:
commit
b3cbb768a3
44 changed files with 1468 additions and 1270 deletions
|
|
@ -1324,7 +1324,7 @@ get_new_connection_ifname (const GSList *existing,
|
|||
for (i = 0; i < 500; i++) {
|
||||
name = g_strdup_printf ("%s%d", prefix, i);
|
||||
|
||||
if (nm_platform_link_exists (name))
|
||||
if (nm_platform_link_exists (NM_PLATFORM_GET, name))
|
||||
goto next;
|
||||
|
||||
for (iter = existing, found = FALSE; iter; iter = g_slist_next (iter)) {
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ set_nas_iface (NMDeviceAdsl *self, int idx, const char *name)
|
|||
g_return_if_fail (name != NULL);
|
||||
|
||||
g_warn_if_fail (priv->nas_ifindex <= 0);
|
||||
priv->nas_ifindex = idx > 0 ? idx : nm_platform_link_get_ifindex (name);
|
||||
priv->nas_ifindex = idx > 0 ? idx : nm_platform_link_get_ifindex (NM_PLATFORM_GET, name);
|
||||
g_warn_if_fail (priv->nas_ifindex > 0);
|
||||
|
||||
g_warn_if_fail (priv->nas_ifname == NULL);
|
||||
|
|
@ -352,7 +352,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason)
|
|||
_LOGD (LOGD_ADSL, "ATM setup successful");
|
||||
|
||||
/* otherwise we're good for stage3 */
|
||||
nm_platform_link_set_up (priv->nas_ifindex);
|
||||
nm_platform_link_set_up (NM_PLATFORM_GET, priv->nas_ifindex);
|
||||
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
|
||||
} else if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) == 0) {
|
||||
|
|
@ -492,7 +492,7 @@ carrier_update_cb (gpointer user_data)
|
|||
|
||||
path = g_strdup_printf ("/sys/class/atm/%s/carrier",
|
||||
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (NM_DEVICE (self))));
|
||||
carrier = (int) nm_platform_sysctl_get_int_checked (path, 10, 0, 1, -1);
|
||||
carrier = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, path, 10, 0, 1, -1);
|
||||
g_free (path);
|
||||
|
||||
if (carrier != -1)
|
||||
|
|
@ -526,7 +526,7 @@ get_atm_index (const char *iface)
|
|||
|
||||
path = g_strdup_printf ("/sys/class/atm/%s/atmindex",
|
||||
ASSERT_VALID_PATH_COMPONENT (iface));
|
||||
idx = (int) nm_platform_sysctl_get_int_checked (path, 10, 0, G_MAXINT, -1);
|
||||
idx = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, path, 10, 0, G_MAXINT, -1);
|
||||
g_free (path);
|
||||
|
||||
return idx;
|
||||
|
|
|
|||
|
|
@ -145,7 +145,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 (ifindex, attr, value);
|
||||
ret = nm_platform_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;
|
||||
|
|
@ -179,7 +179,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 (ifindex, *options);
|
||||
gs_free char *value = nm_platform_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)) {
|
||||
|
|
@ -335,7 +335,7 @@ apply_bonding_config (NMDevice *device)
|
|||
}
|
||||
|
||||
/* Clear ARP targets */
|
||||
contents = nm_platform_master_get_option (ifindex, "arp_ip_target");
|
||||
contents = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "arp_ip_target");
|
||||
set_arp_targets (device, contents, " \n", "-");
|
||||
g_free (contents);
|
||||
|
||||
|
|
@ -411,7 +411,8 @@ enslave_slave (NMDevice *device,
|
|||
|
||||
if (configure) {
|
||||
nm_device_take_down (slave, TRUE);
|
||||
success = nm_platform_link_enslave (nm_device_get_ip_ifindex (device),
|
||||
success = nm_platform_link_enslave (NM_PLATFORM_GET,
|
||||
nm_device_get_ip_ifindex (device),
|
||||
nm_device_get_ip_ifindex (slave));
|
||||
nm_device_bring_up (slave, TRUE, &no_firmware);
|
||||
|
||||
|
|
@ -435,7 +436,8 @@ release_slave (NMDevice *device,
|
|||
gboolean success = TRUE, no_firmware = FALSE;
|
||||
|
||||
if (configure) {
|
||||
success = nm_platform_link_release (nm_device_get_ip_ifindex (device),
|
||||
success = nm_platform_link_release (NM_PLATFORM_GET,
|
||||
nm_device_get_ip_ifindex (device),
|
||||
nm_device_get_ip_ifindex (slave));
|
||||
|
||||
if (success) {
|
||||
|
|
@ -581,11 +583,11 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
|
|||
iface = nm_connection_get_interface_name (connection);
|
||||
g_return_val_if_fail (iface != NULL, NULL);
|
||||
|
||||
if ( !nm_platform_bond_add (iface)
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if ( !nm_platform_bond_add (NM_PLATFORM_GET, iface)
|
||||
&& nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
|
||||
nm_log_warn (LOGD_DEVICE | LOGD_BOND, "(%s): failed to create bonding master interface for '%s': %s",
|
||||
iface, nm_connection_get_id (connection),
|
||||
nm_platform_get_error_msg ());
|
||||
nm_platform_get_error_msg (NM_PLATFORM_GET));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,9 +213,9 @@ commit_option (NMDevice *device, NMSetting *setting, const Option *option, gbool
|
|||
|
||||
value = g_strdup_printf ("%u", uval);
|
||||
if (slave)
|
||||
nm_platform_slave_set_option (ifindex, option->sysname, value);
|
||||
nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value);
|
||||
else
|
||||
nm_platform_master_set_option (ifindex, option->sysname, value);
|
||||
nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -259,7 +259,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
}
|
||||
|
||||
for (option = master_options; option->name; option++) {
|
||||
gs_free char *str = nm_platform_master_get_option (ifindex, option->sysname);
|
||||
gs_free char *str = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, option->sysname);
|
||||
int value;
|
||||
|
||||
if (str) {
|
||||
|
|
@ -298,7 +298,7 @@ master_update_slave_connection (NMDevice *device,
|
|||
}
|
||||
|
||||
for (option = slave_options; option->name; option++) {
|
||||
gs_free char *str = nm_platform_slave_get_option (ifindex_slave, option->sysname);
|
||||
gs_free char *str = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex_slave, option->sysname);
|
||||
int value;
|
||||
|
||||
if (str) {
|
||||
|
|
@ -346,7 +346,7 @@ enslave_slave (NMDevice *device,
|
|||
NMDeviceBridge *self = NM_DEVICE_BRIDGE (device);
|
||||
|
||||
if (configure) {
|
||||
if (!nm_platform_link_enslave (nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)))
|
||||
if (!nm_platform_link_enslave (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)))
|
||||
return FALSE;
|
||||
|
||||
commit_slave_options (slave, nm_connection_get_setting_bridge_port (connection));
|
||||
|
|
@ -372,7 +372,8 @@ release_slave (NMDevice *device,
|
|||
gboolean success = TRUE;
|
||||
|
||||
if (configure) {
|
||||
success = nm_platform_link_release (nm_device_get_ip_ifindex (device),
|
||||
success = nm_platform_link_release (NM_PLATFORM_GET,
|
||||
nm_device_get_ip_ifindex (device),
|
||||
nm_device_get_ip_ifindex (slave));
|
||||
|
||||
if (success) {
|
||||
|
|
@ -519,13 +520,14 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
|
|||
mac_address_str = NULL;
|
||||
}
|
||||
|
||||
if ( !nm_platform_bridge_add (iface,
|
||||
if ( !nm_platform_bridge_add (NM_PLATFORM_GET,
|
||||
iface,
|
||||
mac_address_str ? mac_address : NULL,
|
||||
mac_address_str ? ETH_ALEN : 0)
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
||||
&& nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
|
||||
nm_log_warn (LOGD_DEVICE | LOGD_BRIDGE, "(%s): failed to create bridge master interface for '%s': %s",
|
||||
iface, nm_connection_get_id (connection),
|
||||
nm_platform_get_error_msg ());
|
||||
nm_platform_get_error_msg (NM_PLATFORM_GET));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ _update_s390_subchannels (NMDeviceEthernet *self)
|
|||
|| !strcmp (item, "portno")) {
|
||||
char *path, *value;
|
||||
path = g_strdup_printf ("%s/%s", parent_path, item);
|
||||
value = nm_platform_sysctl_get (path);
|
||||
value = nm_platform_sysctl_get (NM_PLATFORM_GET, path);
|
||||
if (value && *value)
|
||||
g_hash_table_insert (priv->s390_options, g_strdup (item), g_strdup (value));
|
||||
else
|
||||
|
|
@ -263,7 +263,7 @@ constructor (GType type,
|
|||
if (object) {
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
int ifindex = nm_device_get_ifindex (NM_DEVICE (object));
|
||||
NMLinkType link_type = nm_platform_link_get_type (ifindex);
|
||||
NMLinkType link_type = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex);
|
||||
|
||||
g_assert ( link_type == NM_LINK_TYPE_ETHERNET
|
||||
|| link_type == NM_LINK_TYPE_VETH
|
||||
|
|
@ -375,7 +375,7 @@ get_generic_capabilities (NMDevice *device)
|
|||
{
|
||||
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
||||
|
||||
if (nm_platform_link_supports_carrier_detect (nm_device_get_ifindex (device)))
|
||||
if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (device)))
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT;
|
||||
else {
|
||||
_LOGI (LOGD_HW, "driver '%s' does not support carrier detection.",
|
||||
|
|
@ -1160,7 +1160,7 @@ dcb_state (NMDevice *device, gboolean timeout)
|
|||
g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG);
|
||||
|
||||
|
||||
carrier = nm_platform_link_is_connected (nm_device_get_ifindex (device));
|
||||
carrier = nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device));
|
||||
_LOGD (LOGD_DCB, "dcb_state() wait %d carrier %d timeout %d", priv->dcb_wait, carrier, timeout);
|
||||
|
||||
switch (priv->dcb_wait) {
|
||||
|
|
@ -1278,7 +1278,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||
s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB);
|
||||
if (s_dcb) {
|
||||
/* lldpad really really wants the carrier to be up */
|
||||
if (nm_platform_link_is_connected (nm_device_get_ifindex (device))) {
|
||||
if (nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device))) {
|
||||
if (!dcb_enable (device)) {
|
||||
*reason = NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED;
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ enum {
|
|||
static NMDeviceCapabilities
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
if (nm_platform_link_supports_carrier_detect (nm_device_get_ifindex (dev)))
|
||||
if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (dev)))
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT;
|
||||
else
|
||||
return NM_DEVICE_CAP_NONE;
|
||||
|
|
@ -117,7 +117,7 @@ constructed (GObject *object)
|
|||
int ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self));
|
||||
|
||||
if (ifindex != 0)
|
||||
priv->type_description = g_strdup (nm_platform_link_get_type_name (ifindex));
|
||||
priv->type_description = g_strdup (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex));
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ update_properties (NMDevice *device)
|
|||
GObject *object = G_OBJECT (device);
|
||||
NMPlatformGreProperties props;
|
||||
|
||||
if (!nm_platform_gre_get_properties (nm_device_get_ifindex (device), &props)) {
|
||||
if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
|
||||
_LOGW (LOGD_HW, "could not read gre properties");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
}
|
||||
}
|
||||
|
||||
ok = nm_platform_sysctl_set (mode_path, transport_mode);
|
||||
ok = nm_platform_sysctl_set (NM_PLATFORM_GET, mode_path, transport_mode);
|
||||
g_free (mode_path);
|
||||
|
||||
if (!ok) {
|
||||
|
|
@ -226,7 +226,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
|
||||
mode_path = g_strdup_printf ("/sys/class/net/%s/mode",
|
||||
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (device)));
|
||||
contents = nm_platform_sysctl_get (mode_path);
|
||||
contents = nm_platform_sysctl_get (NM_PLATFORM_GET, mode_path);
|
||||
g_free (mode_path);
|
||||
if (contents) {
|
||||
if (strstr (contents, "datagram"))
|
||||
|
|
@ -328,11 +328,11 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
|
|||
parent_ifindex = nm_device_get_ifindex (parent);
|
||||
p_key = nm_setting_infiniband_get_p_key (s_infiniband);
|
||||
|
||||
if ( !nm_platform_infiniband_partition_add (parent_ifindex, p_key)
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if ( !nm_platform_infiniband_partition_add (NM_PLATFORM_GET, parent_ifindex, p_key)
|
||||
&& nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
|
||||
nm_log_warn (LOGD_DEVICE | LOGD_INFINIBAND, "(%s): failed to add InfiniBand P_Key interface for '%s': %s",
|
||||
iface, nm_connection_get_id (connection),
|
||||
nm_platform_get_error_msg ());
|
||||
nm_platform_get_error_msg (NM_PLATFORM_GET));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ update_properties (NMDevice *device)
|
|||
GObject *object = G_OBJECT (device);
|
||||
NMPlatformMacvlanProperties props;
|
||||
|
||||
if (!nm_platform_macvlan_get_properties (nm_device_get_ifindex (device), &props)) {
|
||||
if (!nm_platform_macvlan_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
|
||||
_LOGW (LOGD_HW, "could not read macvlan properties");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ reload_tun_properties (NMDeviceTun *self)
|
|||
GObject *object = G_OBJECT (self);
|
||||
NMPlatformTunProperties props;
|
||||
|
||||
if (!nm_platform_tun_get_properties (nm_device_get_ifindex (NM_DEVICE (self)), &props)) {
|
||||
if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &props)) {
|
||||
_LOGD (LOGD_HW, "could not read tun properties");
|
||||
return;
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ constructed (GObject *object)
|
|||
gboolean properties_read;
|
||||
NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self);
|
||||
|
||||
properties_read = nm_platform_tun_get_properties (nm_device_get_ifindex (NM_DEVICE (self)), &priv->props);
|
||||
properties_read = nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &priv->props);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_tun_parent_class)->constructed (object);
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ get_peer (NMDeviceVeth *self)
|
|||
if (priv->ever_had_peer)
|
||||
return priv->peer;
|
||||
|
||||
if (!nm_platform_veth_get_properties (nm_device_get_ifindex (device), &props)) {
|
||||
if (!nm_platform_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
|
||||
_LOGW (LOGD_HW, "could not read veth properties");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
nm_connection_add_setting (connection, (NMSetting *) s_vlan);
|
||||
}
|
||||
|
||||
if (!nm_platform_vlan_get_info (ifindex, &parent_ifindex, &vlan_id)) {
|
||||
if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent_ifindex, &vlan_id)) {
|
||||
_LOGW (LOGD_VLAN, "failed to get VLAN interface info while updating connection.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -353,12 +353,12 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_INGRESS_MAP);
|
||||
for (i = 0; i < num; i++) {
|
||||
if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_INGRESS_MAP, i, &from, &to))
|
||||
nm_platform_vlan_set_ingress_map (ifindex, from, to);
|
||||
nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, from, to);
|
||||
}
|
||||
num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_EGRESS_MAP);
|
||||
for (i = 0; i < num; i++) {
|
||||
if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, i, &from, &to))
|
||||
nm_platform_vlan_set_egress_map (ifindex, from, to);
|
||||
nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -437,14 +437,14 @@ constructed (GObject *object)
|
|||
return;
|
||||
}
|
||||
|
||||
itype = nm_platform_link_get_type (ifindex);
|
||||
itype = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex);
|
||||
if (itype != NM_LINK_TYPE_VLAN) {
|
||||
_LOGE (LOGD_VLAN, "failed to get VLAN interface type.");
|
||||
priv->invalid = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nm_platform_vlan_get_info (ifindex, &parent_ifindex, &vlan_id)) {
|
||||
if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent_ifindex, &vlan_id)) {
|
||||
_LOGW (LOGD_VLAN, "failed to get VLAN interface info.");
|
||||
priv->invalid = TRUE;
|
||||
return;
|
||||
|
|
@ -603,7 +603,7 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
|
|||
return NULL;
|
||||
|
||||
/* Have to find the parent device */
|
||||
if (!nm_platform_vlan_get_info (plink->ifindex, &parent_ifindex, NULL)) {
|
||||
if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, plink->ifindex, &parent_ifindex, NULL)) {
|
||||
nm_log_err (LOGD_HW, "(%s): failed to get VLAN parent ifindex", plink->name);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -662,11 +662,12 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
|
|||
nm_setting_vlan_get_id (s_vlan));
|
||||
}
|
||||
|
||||
if ( !nm_platform_vlan_add (iface,
|
||||
if ( !nm_platform_vlan_add (NM_PLATFORM_GET,
|
||||
iface,
|
||||
nm_device_get_ifindex (parent),
|
||||
nm_setting_vlan_get_id (s_vlan),
|
||||
nm_setting_vlan_get_flags (s_vlan))
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
||||
&& nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
|
||||
nm_log_warn (LOGD_DEVICE | LOGD_VLAN, "(%s) failed to add VLAN interface for '%s'",
|
||||
iface, nm_connection_get_id (connection));
|
||||
g_free (iface);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ update_properties (NMDevice *device)
|
|||
GObject *object = G_OBJECT (device);
|
||||
NMPlatformVxlanProperties props;
|
||||
|
||||
if (!nm_platform_vxlan_get_properties (nm_device_get_ifindex (device), &props)) {
|
||||
if (!nm_platform_vxlan_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
|
||||
_LOGW (LOGD_HW, "could not read vxlan properties");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,13 +464,13 @@ reason_to_string (NMDeviceStateReason reason)
|
|||
gboolean
|
||||
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
|
||||
{
|
||||
return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
|
||||
return nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
|
||||
}
|
||||
|
||||
static guint32
|
||||
nm_device_ipv6_sysctl_get_int32 (NMDevice *self, const char *property, gint32 fallback)
|
||||
{
|
||||
return nm_platform_sysctl_get_int32 (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback);
|
||||
return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -578,13 +578,13 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
|
|||
|
||||
priv->ip_iface = g_strdup (iface);
|
||||
if (priv->ip_iface) {
|
||||
priv->ip_ifindex = nm_platform_link_get_ifindex (priv->ip_iface);
|
||||
priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
|
||||
if (priv->ip_ifindex > 0) {
|
||||
if (nm_platform_check_support_user_ipv6ll ())
|
||||
nm_platform_link_set_user_ipv6ll_enabled (priv->ip_ifindex, TRUE);
|
||||
if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET))
|
||||
nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ip_ifindex, TRUE);
|
||||
|
||||
if (!nm_platform_link_is_up (priv->ip_ifindex))
|
||||
nm_platform_link_set_up (priv->ip_ifindex);
|
||||
if (!nm_platform_link_is_up (NM_PLATFORM_GET, priv->ip_ifindex))
|
||||
nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex);
|
||||
} else {
|
||||
/* Device IP interface must always be a kernel network interface */
|
||||
_LOGW (LOGD_HW, "failed to look up interface index");
|
||||
|
|
@ -614,10 +614,10 @@ get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid)
|
|||
ifindex = nm_device_get_ip_ifindex (self);
|
||||
g_assert (ifindex);
|
||||
|
||||
link_type = nm_platform_link_get_type (ifindex);
|
||||
link_type = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex);
|
||||
g_return_val_if_fail (link_type > NM_LINK_TYPE_UNKNOWN, 0);
|
||||
|
||||
hwaddr = nm_platform_link_get_address (ifindex, &hwaddr_len);
|
||||
hwaddr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddr_len);
|
||||
if (!hwaddr_len)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -1042,7 +1042,7 @@ nm_device_finish_init (NMDevice *self)
|
|||
|
||||
/* Do not manage externally created software devices until they are IFF_UP */
|
||||
if ( is_software_external (self)
|
||||
&& !nm_platform_link_is_up (priv->ifindex)
|
||||
&& !nm_platform_link_is_up (NM_PLATFORM_GET, priv->ifindex)
|
||||
&& priv->ifindex > 0)
|
||||
nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_EXTERNAL_DOWN, TRUE);
|
||||
|
||||
|
|
@ -1230,7 +1230,7 @@ device_set_master (NMDevice *self, int ifindex)
|
|||
} else {
|
||||
_LOGW (LOGD_DEVICE, "enslaved to unknown device %d %s",
|
||||
ifindex,
|
||||
nm_platform_link_get_name (ifindex));
|
||||
nm_platform_link_get_name (NM_PLATFORM_GET, ifindex));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1286,7 +1286,7 @@ device_link_changed (NMDevice *self, NMPlatformLink *info)
|
|||
nm_device_enslave_slave (priv->master, self, NULL);
|
||||
}
|
||||
|
||||
if (priv->rdisc && nm_platform_link_get_ipv6_token (priv->ifindex, &token_iid)) {
|
||||
if (priv->rdisc && nm_platform_link_get_ipv6_token (NM_PLATFORM_GET, priv->ifindex, &token_iid)) {
|
||||
_LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface);
|
||||
if (nm_rdisc_set_iid (priv->rdisc, token_iid))
|
||||
nm_rdisc_start (priv->rdisc);
|
||||
|
|
@ -1979,7 +1979,7 @@ device_has_config (NMDevice *self)
|
|||
return TRUE;
|
||||
|
||||
/* Slaves are also configured by definition */
|
||||
if (nm_platform_link_get_master (priv->ifindex) > 0)
|
||||
if (nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) > 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
|
|
@ -2876,9 +2876,9 @@ _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlat
|
|||
GArray *routes;
|
||||
|
||||
if (addr_family == AF_INET)
|
||||
routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
||||
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
||||
else
|
||||
routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
||||
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
||||
|
||||
if (routes) {
|
||||
guint route_metric = G_MAXUINT32, m;
|
||||
|
|
@ -3171,7 +3171,7 @@ dhcp4_start (NMDevice *self,
|
|||
g_object_unref (priv->dhcp4_config);
|
||||
priv->dhcp4_config = nm_dhcp4_config_new ();
|
||||
|
||||
hw_addr = nm_platform_link_get_address (nm_device_get_ip_ifindex (self), &hw_addr_len);
|
||||
hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), &hw_addr_len);
|
||||
if (hw_addr_len) {
|
||||
tmp = g_byte_array_sized_new (hw_addr_len);
|
||||
g_byte_array_append (tmp, hw_addr, hw_addr_len);
|
||||
|
|
@ -3768,7 +3768,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
g_assert (s_ip6);
|
||||
|
||||
hw_addr = nm_platform_link_get_address (nm_device_get_ip_ifindex (self), &hw_addr_len);
|
||||
hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), &hw_addr_len);
|
||||
if (hw_addr_len) {
|
||||
tmp = g_byte_array_sized_new (hw_addr_len);
|
||||
g_byte_array_append (tmp, hw_addr, hw_addr_len);
|
||||
|
|
@ -3973,7 +3973,8 @@ check_and_add_ipv6ll_addr (NMDevice *self)
|
|||
lladdr.s6_addr16[0] = htons (0xfe80);
|
||||
nm_utils_ipv6_addr_set_interface_identfier (&lladdr, iid);
|
||||
_LOGD (LOGD_IP6, "adding IPv6LL address %s", nm_utils_inet6_ntop (&lladdr, NULL));
|
||||
if (!nm_platform_ip6_address_add (ip_ifindex,
|
||||
if (!nm_platform_ip6_address_add (NM_PLATFORM_GET,
|
||||
ip_ifindex,
|
||||
lladdr,
|
||||
in6addr_any,
|
||||
64,
|
||||
|
|
@ -4023,7 +4024,7 @@ print_support_extended_ifa_flags (NMSettingIP6ConfigPrivacy use_tempaddr)
|
|||
|
||||
if (s_libnl == -1) {
|
||||
s_libnl = !!nm_platform_check_support_libnl_extended_ifa_flags ();
|
||||
s_kernel = !!nm_platform_check_support_kernel_extended_ifa_flags ();
|
||||
s_kernel = !!nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET);
|
||||
|
||||
if (s_libnl && s_kernel) {
|
||||
nm_log_dbg (LOGD_IP6, "kernel and libnl support extended IFA_FLAGS (needed by NM for IPv6 private addresses)");
|
||||
|
|
@ -4074,8 +4075,8 @@ nm_device_set_mtu (NMDevice *self, guint32 mtu)
|
|||
if (priv->ip6_mtu)
|
||||
nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
|
||||
|
||||
if (priv->mtu != nm_platform_link_get_mtu (ifindex))
|
||||
nm_platform_link_set_mtu (ifindex, priv->mtu);
|
||||
if (priv->mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex))
|
||||
nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, priv->mtu);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -4128,7 +4129,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
|
|||
* from adding a prefix route for this address.
|
||||
**/
|
||||
system_support = nm_platform_check_support_libnl_extended_ifa_flags () &&
|
||||
nm_platform_check_support_kernel_extended_ifa_flags ();
|
||||
nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET);
|
||||
}
|
||||
|
||||
if (system_support)
|
||||
|
|
@ -4249,7 +4250,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
|
|||
}
|
||||
|
||||
if (changed & NM_RDISC_CONFIG_HOP_LIMIT)
|
||||
nm_platform_sysctl_set_ip6_hop_limit_safe (nm_device_get_ip_iface (self), rdisc->hop_limit);
|
||||
nm_platform_sysctl_set_ip6_hop_limit_safe (NM_PLATFORM_GET, nm_device_get_ip_iface (self), rdisc->hop_limit);
|
||||
|
||||
if (changed & NM_RDISC_CONFIG_MTU)
|
||||
priv->ip6_mtu = rdisc->mtu;
|
||||
|
|
@ -4289,7 +4290,7 @@ addrconf6_start_with_link_ready (NMDevice *self)
|
|||
|
||||
g_assert (priv->rdisc);
|
||||
|
||||
if (nm_platform_link_get_ipv6_token (priv->ifindex, &iid)) {
|
||||
if (nm_platform_link_get_ipv6_token (NM_PLATFORM_GET, priv->ifindex, &iid)) {
|
||||
_LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface);
|
||||
} else if (!nm_device_get_ip_iface_identifier (self, &iid)) {
|
||||
_LOGW (LOGD_IP6, "failed to get interface identifier; IPv6 cannot continue");
|
||||
|
|
@ -4404,7 +4405,7 @@ save_ip6_properties (NMDevice *self)
|
|||
g_hash_table_remove_all (priv->ip6_saved_properties);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (ip6_properties_to_save); i++) {
|
||||
value = nm_platform_sysctl_get (nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i]));
|
||||
value = nm_platform_sysctl_get (NM_PLATFORM_GET, nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i]));
|
||||
if (value) {
|
||||
g_hash_table_insert (priv->ip6_saved_properties,
|
||||
(char *) ip6_properties_to_save[i],
|
||||
|
|
@ -4445,7 +4446,7 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable)
|
|||
const char *iface = nm_device_get_ip_iface (self);
|
||||
char *value;
|
||||
|
||||
if (!nm_platform_check_support_user_ipv6ll ())
|
||||
if (!nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET))
|
||||
return;
|
||||
|
||||
priv->nm_ipv6ll = enable;
|
||||
|
|
@ -4453,13 +4454,13 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable)
|
|||
const char *detail = enable ? "enable" : "disable";
|
||||
|
||||
_LOGD (LOGD_IP6, "will %s userland IPv6LL", detail);
|
||||
if ( !nm_platform_link_set_user_ipv6ll_enabled (ifindex, enable)
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_NOT_FOUND)
|
||||
if ( !nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, enable)
|
||||
&& nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_NOT_FOUND)
|
||||
_LOGW (LOGD_IP6, "failed to %s userspace IPv6LL address handling", detail);
|
||||
|
||||
if (enable) {
|
||||
/* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */
|
||||
value = nm_platform_sysctl_get (nm_utils_ip6_property_path (iface, "disable_ipv6"));
|
||||
value = nm_platform_sysctl_get (NM_PLATFORM_GET, nm_utils_ip6_property_path (iface, "disable_ipv6"));
|
||||
if (g_strcmp0 (value, "0") == 0)
|
||||
nm_device_ipv6_sysctl_set (self, "disable_ipv6", "1");
|
||||
g_free (value);
|
||||
|
|
@ -4824,7 +4825,7 @@ nm_device_activate_stage3_ip_config_start (gpointer user_data)
|
|||
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
|
||||
|
||||
/* Device should be up before we can do anything with it */
|
||||
if (!nm_platform_link_is_up (nm_device_get_ip_ifindex (self)))
|
||||
if (!nm_platform_link_is_up (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self)))
|
||||
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
|
||||
|
||||
/* If the device is a slave, then we don't do any IP configuration but we
|
||||
|
|
@ -5079,14 +5080,14 @@ share_init (void)
|
|||
char **iter;
|
||||
int errsv;
|
||||
|
||||
if (!nm_platform_sysctl_set ("/proc/sys/net/ipv4/ip_forward", "1")) {
|
||||
if (!nm_platform_sysctl_set (NM_PLATFORM_GET, "/proc/sys/net/ipv4/ip_forward", "1")) {
|
||||
errsv = errno;
|
||||
nm_log_err (LOGD_SHARING, "share: error starting IP forwarding: (%d) %s",
|
||||
errsv, strerror (errsv));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!nm_platform_sysctl_set ("/proc/sys/net/ipv4/ip_dynaddr", "1")) {
|
||||
if (!nm_platform_sysctl_set (NM_PLATFORM_GET, "/proc/sys/net/ipv4/ip_dynaddr", "1")) {
|
||||
errsv = errno;
|
||||
nm_log_err (LOGD_SHARING, "share: error starting IP forwarding: (%d) %s",
|
||||
errsv, strerror (errsv));
|
||||
|
|
@ -5297,9 +5298,9 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
|
|||
|
||||
/* Interface must be IFF_UP before IP config can be applied */
|
||||
ip_ifindex = nm_device_get_ip_ifindex (self);
|
||||
if (!nm_platform_link_is_up (ip_ifindex) && !nm_device_uses_assumed_connection (self)) {
|
||||
nm_platform_link_set_up (ip_ifindex);
|
||||
if (!nm_platform_link_is_up (ip_ifindex))
|
||||
if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex) && !nm_device_uses_assumed_connection (self)) {
|
||||
nm_platform_link_set_up (NM_PLATFORM_GET, ip_ifindex);
|
||||
if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex))
|
||||
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
|
||||
}
|
||||
|
||||
|
|
@ -5405,9 +5406,9 @@ nm_device_activate_ip6_config_commit (gpointer user_data)
|
|||
|
||||
/* Interface must be IFF_UP before IP config can be applied */
|
||||
ip_ifindex = nm_device_get_ip_ifindex (self);
|
||||
if (!nm_platform_link_is_up (ip_ifindex) && !nm_device_uses_assumed_connection (self)) {
|
||||
nm_platform_link_set_up (ip_ifindex);
|
||||
if (!nm_platform_link_is_up (ip_ifindex))
|
||||
if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex) && !nm_device_uses_assumed_connection (self)) {
|
||||
nm_platform_link_set_up (NM_PLATFORM_GET, ip_ifindex);
|
||||
if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex))
|
||||
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
|
||||
}
|
||||
|
||||
|
|
@ -5576,7 +5577,7 @@ delete_on_deactivate_link_delete (gpointer user_data)
|
|||
|
||||
_LOGD (LOGD_DEVICE, "delete_on_deactivate: cleanup and delete virtual link #%d (id=%u)",
|
||||
data->ifindex, data->idle_add_id);
|
||||
nm_platform_link_delete (data->ifindex);
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, data->ifindex);
|
||||
g_free (data);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -5710,7 +5711,7 @@ delete_cb (NMDevice *self,
|
|||
}
|
||||
|
||||
/* Authorized */
|
||||
nm_platform_link_delete (nm_device_get_ifindex (self));
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_device_get_ifindex (self));
|
||||
dbus_g_method_return (context);
|
||||
}
|
||||
|
||||
|
|
@ -6450,7 +6451,7 @@ is_up (NMDevice *self)
|
|||
{
|
||||
int ifindex = nm_device_get_ip_ifindex (self);
|
||||
|
||||
return ifindex > 0 ? nm_platform_link_is_up (ifindex) : TRUE;
|
||||
return ifindex > 0 ? nm_platform_link_is_up (NM_PLATFORM_GET, ifindex) : TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -6475,7 +6476,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
|
|||
|
||||
do {
|
||||
g_usleep (200);
|
||||
if (!nm_platform_link_refresh (ifindex))
|
||||
if (!nm_platform_link_refresh (NM_PLATFORM_GET, ifindex))
|
||||
return FALSE;
|
||||
device_is_up = nm_device_is_up (self);
|
||||
} while (!device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until);
|
||||
|
|
@ -6515,7 +6516,7 @@ check_carrier (NMDevice *self)
|
|||
int ifindex = nm_device_get_ip_ifindex (self);
|
||||
|
||||
if (!nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER))
|
||||
nm_device_set_carrier (self, nm_platform_link_is_connected (ifindex));
|
||||
nm_device_set_carrier (self, nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -6530,9 +6531,9 @@ bring_up (NMDevice *self, gboolean *no_firmware)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
result = nm_platform_link_set_up (ifindex);
|
||||
result = nm_platform_link_set_up (NM_PLATFORM_GET, ifindex);
|
||||
if (no_firmware)
|
||||
*no_firmware = nm_platform_get_error () == NM_PLATFORM_ERROR_NO_FIRMWARE;
|
||||
*no_firmware = nm_platform_get_error (NM_PLATFORM_GET) == NM_PLATFORM_ERROR_NO_FIRMWARE;
|
||||
|
||||
/* Store carrier immediately. */
|
||||
if (result && nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT))
|
||||
|
|
@ -6562,7 +6563,7 @@ nm_device_take_down (NMDevice *self, gboolean block)
|
|||
|
||||
do {
|
||||
g_usleep (200);
|
||||
if (!nm_platform_link_refresh (ifindex))
|
||||
if (!nm_platform_link_refresh (NM_PLATFORM_GET, ifindex))
|
||||
return;
|
||||
device_is_up = nm_device_is_up (self);
|
||||
} while (device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until);
|
||||
|
|
@ -6582,7 +6583,7 @@ take_down (NMDevice *self)
|
|||
int ifindex = nm_device_get_ip_ifindex (self);
|
||||
|
||||
if (ifindex > 0)
|
||||
return nm_platform_link_set_down (ifindex);
|
||||
return nm_platform_link_set_down (NM_PLATFORM_GET, ifindex);
|
||||
|
||||
/* devices without ifindex are always up. */
|
||||
_LOGD (LOGD_HW, "cannot take down device without ifindex");
|
||||
|
|
@ -7177,7 +7178,7 @@ cp_connection_updated (NMConnectionProvider *cp, NMConnection *connection, gpoin
|
|||
gboolean
|
||||
nm_device_supports_vlans (NMDevice *self)
|
||||
{
|
||||
return nm_platform_link_supports_vlans (nm_device_get_ifindex (self));
|
||||
return nm_platform_link_supports_vlans (NM_PLATFORM_GET, nm_device_get_ifindex (self));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -7441,8 +7442,8 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, gboolean deconfig
|
|||
/* Take out any entries in the routing table and any IP address the device had. */
|
||||
ifindex = nm_device_get_ip_ifindex (self);
|
||||
if (ifindex > 0) {
|
||||
nm_platform_route_flush (ifindex);
|
||||
nm_platform_address_flush (ifindex);
|
||||
nm_platform_route_flush (NM_PLATFORM_GET, ifindex);
|
||||
nm_platform_address_flush (NM_PLATFORM_GET, ifindex);
|
||||
}
|
||||
|
||||
_cleanup_generic_post (self, deconfigure);
|
||||
|
|
@ -8119,7 +8120,7 @@ nm_device_update_hw_address (NMDevice *self)
|
|||
if (ifindex <= 0)
|
||||
return;
|
||||
|
||||
hwaddr = nm_platform_link_get_address (ifindex, &hwaddrlen);
|
||||
hwaddr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddrlen);
|
||||
|
||||
if (hwaddrlen) {
|
||||
if (!priv->hw_addr || !nm_utils_hwaddr_matches (priv->hw_addr, -1, hwaddr, hwaddrlen)) {
|
||||
|
|
@ -8165,7 +8166,7 @@ nm_device_set_hw_addr (NMDevice *self, const char *addr,
|
|||
/* Can't change MAC address while device is up */
|
||||
nm_device_take_down (self, FALSE);
|
||||
|
||||
success = nm_platform_link_set_address (nm_device_get_ip_ifindex (self), addr_bytes, priv->hw_addr_len);
|
||||
success = nm_platform_link_set_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), addr_bytes, priv->hw_addr_len);
|
||||
if (success) {
|
||||
/* MAC address succesfully changed; update the current MAC to match */
|
||||
nm_device_update_hw_address (self);
|
||||
|
|
@ -8372,11 +8373,11 @@ constructor (GType type,
|
|||
/* trigger initial ip config change to initialize ip-config */
|
||||
priv->queued_ip_config_id = g_idle_add (queued_ip_config_change, self);
|
||||
|
||||
if (nm_platform_check_support_user_ipv6ll ()) {
|
||||
if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) {
|
||||
int ip_ifindex = nm_device_get_ip_ifindex (self);
|
||||
|
||||
if (ip_ifindex > 0)
|
||||
priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (ip_ifindex);
|
||||
priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, ip_ifindex);
|
||||
}
|
||||
|
||||
return object;
|
||||
|
|
@ -8422,17 +8423,17 @@ constructed (GObject *object)
|
|||
}
|
||||
|
||||
if (priv->ifindex > 0) {
|
||||
priv->is_software = nm_platform_link_is_software (priv->ifindex);
|
||||
priv->physical_port_id = nm_platform_link_get_physical_port_id (priv->ifindex);
|
||||
priv->dev_id = nm_platform_link_get_dev_id (priv->ifindex);
|
||||
priv->mtu = nm_platform_link_get_mtu (priv->ifindex);
|
||||
priv->is_software = nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex);
|
||||
priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex);
|
||||
priv->dev_id = nm_platform_link_get_dev_id (NM_PLATFORM_GET, priv->ifindex);
|
||||
priv->mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex);
|
||||
}
|
||||
/* Indicate software device in capabilities. */
|
||||
if (priv->is_software)
|
||||
priv->capabilities |= NM_DEVICE_CAP_IS_SOFTWARE;
|
||||
|
||||
/* Enslave ourselves */
|
||||
master = nm_platform_link_get_master (priv->ifindex);
|
||||
master = nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex);
|
||||
if (master)
|
||||
device_set_master (self, master);
|
||||
|
||||
|
|
@ -8581,9 +8582,9 @@ set_property (GObject *object, guint prop_id,
|
|||
if (g_value_get_string (value)) {
|
||||
g_free (priv->iface);
|
||||
priv->iface = g_value_dup_string (value);
|
||||
priv->ifindex = nm_platform_link_get_ifindex (priv->iface);
|
||||
priv->ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->iface);
|
||||
if (priv->ifindex > 0)
|
||||
priv->up = nm_platform_link_is_up (priv->ifindex);
|
||||
priv->up = nm_platform_link_is_up (NM_PLATFORM_GET, priv->ifindex);
|
||||
}
|
||||
break;
|
||||
case PROP_DRIVER:
|
||||
|
|
|
|||
|
|
@ -638,7 +638,8 @@ enslave_slave (NMDevice *device,
|
|||
}
|
||||
}
|
||||
}
|
||||
success = nm_platform_link_enslave (nm_device_get_ip_ifindex (device),
|
||||
success = nm_platform_link_enslave (NM_PLATFORM_GET,
|
||||
nm_device_get_ip_ifindex (device),
|
||||
nm_device_get_ip_ifindex (slave));
|
||||
nm_device_bring_up (slave, TRUE, &no_firmware);
|
||||
|
||||
|
|
@ -663,7 +664,8 @@ release_slave (NMDevice *device,
|
|||
gboolean success = TRUE, no_firmware = FALSE;
|
||||
|
||||
if (configure) {
|
||||
success = nm_platform_link_release (nm_device_get_ip_ifindex (device),
|
||||
success = nm_platform_link_release (NM_PLATFORM_GET,
|
||||
nm_device_get_ip_ifindex (device),
|
||||
nm_device_get_ip_ifindex (slave));
|
||||
|
||||
if (success)
|
||||
|
|
@ -715,14 +717,14 @@ nm_device_team_new_for_connection (NMConnection *connection, GError **error)
|
|||
iface = nm_connection_get_interface_name (connection);
|
||||
g_return_val_if_fail (iface != NULL, NULL);
|
||||
|
||||
if ( !nm_platform_team_add (iface)
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if ( !nm_platform_team_add (NM_PLATFORM_GET, iface)
|
||||
&& nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
|
||||
g_set_error (error,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"failed to create team master interface '%s' for connection '%s': %s",
|
||||
iface, nm_connection_get_id (connection),
|
||||
nm_platform_get_error_msg ());
|
||||
nm_platform_get_error_msg (NM_PLATFORM_GET));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,8 +197,8 @@ _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel)
|
|||
{
|
||||
int ifindex = nm_device_get_ifindex (NM_DEVICE (self));
|
||||
|
||||
if (nm_platform_mesh_get_channel (ifindex) != channel) {
|
||||
if (nm_platform_mesh_set_channel (ifindex, channel))
|
||||
if (nm_platform_mesh_get_channel (NM_PLATFORM_GET, ifindex) != channel) {
|
||||
if (nm_platform_mesh_set_channel (NM_PLATFORM_GET, ifindex, channel))
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL);
|
||||
}
|
||||
}
|
||||
|
|
@ -224,7 +224,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||
_mesh_set_channel (self, channel);
|
||||
|
||||
ssid = nm_setting_olpc_mesh_get_ssid (s_mesh);
|
||||
nm_platform_mesh_set_ssid (nm_device_get_ifindex (device),
|
||||
nm_platform_mesh_set_ssid (NM_PLATFORM_GET,
|
||||
nm_device_get_ifindex (device),
|
||||
g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid));
|
||||
|
||||
|
|
@ -453,7 +454,7 @@ constructor (GType type,
|
|||
|
||||
self = NM_DEVICE_OLPC_MESH (object);
|
||||
|
||||
if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)), &caps)) {
|
||||
if (!nm_platform_wifi_get_capabilities (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &caps)) {
|
||||
_LOGW (LOGD_HW | LOGD_OLPC, "failed to initialize WiFi driver");
|
||||
g_object_unref (object);
|
||||
return NULL;
|
||||
|
|
@ -482,7 +483,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_boxed (value, "/");
|
||||
break;
|
||||
case PROP_ACTIVE_CHANNEL:
|
||||
g_value_set_uint (value, nm_platform_mesh_get_channel (nm_device_get_ifindex (NM_DEVICE (device))));
|
||||
g_value_set_uint (value, nm_platform_mesh_get_channel (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (device))));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,8 @@ constructor (GType type,
|
|||
self = NM_DEVICE_WIFI (object);
|
||||
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
|
||||
if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)),
|
||||
if (!nm_platform_wifi_get_capabilities (NM_PLATFORM_GET,
|
||||
nm_device_get_ifindex (NM_DEVICE (self)),
|
||||
&priv->capabilities)) {
|
||||
_LOGW (LOGD_HW | LOGD_WIFI, "failed to initialize WiFi driver");
|
||||
g_object_unref (object);
|
||||
|
|
@ -362,21 +363,21 @@ find_active_ap (NMDeviceWifi *self,
|
|||
NM80211Mode devmode;
|
||||
guint32 devfreq;
|
||||
|
||||
nm_platform_wifi_get_bssid (ifindex, bssid);
|
||||
nm_platform_wifi_get_bssid (NM_PLATFORM_GET, ifindex, bssid);
|
||||
_LOGD (LOGD_WIFI, "active BSSID: %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);
|
||||
|
||||
if (!nm_ethernet_address_is_valid (bssid, ETH_ALEN))
|
||||
return NULL;
|
||||
|
||||
ssid = nm_platform_wifi_get_ssid (ifindex);
|
||||
ssid = nm_platform_wifi_get_ssid (NM_PLATFORM_GET, ifindex);
|
||||
_LOGD (LOGD_WIFI, "active SSID: %s%s%s",
|
||||
ssid ? "'" : "",
|
||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
|
||||
ssid ? "'" : "");
|
||||
|
||||
devmode = nm_platform_wifi_get_mode (ifindex);
|
||||
devfreq = nm_platform_wifi_get_frequency (ifindex);
|
||||
devmode = nm_platform_wifi_get_mode (NM_PLATFORM_GET, ifindex);
|
||||
devfreq = nm_platform_wifi_get_frequency (NM_PLATFORM_GET, ifindex);
|
||||
|
||||
/* When matching hidden APs, do a second pass that ignores the SSID check,
|
||||
* because NM might not yet know the SSID of the hidden AP in the scan list
|
||||
|
|
@ -591,7 +592,7 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
|
|||
if (priv->current_ap && (nm_ap_get_mode (priv->current_ap) == NM_802_11_MODE_ADHOC)) {
|
||||
guint8 bssid[ETH_ALEN] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
|
||||
|
||||
nm_platform_wifi_get_bssid (ifindex, bssid);
|
||||
nm_platform_wifi_get_bssid (NM_PLATFORM_GET, ifindex, bssid);
|
||||
/* 0x02 means "locally administered" and should be OR-ed into
|
||||
* the first byte of IBSS BSSIDs.
|
||||
*/
|
||||
|
|
@ -607,7 +608,7 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
|
|||
/* Try to smooth out the strength. Atmel cards, for example, will give no strength
|
||||
* one second and normal strength the next.
|
||||
*/
|
||||
percent = nm_platform_wifi_get_quality (ifindex);
|
||||
percent = nm_platform_wifi_get_quality (NM_PLATFORM_GET, ifindex);
|
||||
if (percent >= 0 || ++priv->invalid_strength_counter > 3) {
|
||||
nm_ap_set_strength (new_ap, (gint8) percent);
|
||||
priv->invalid_strength_counter = 0;
|
||||
|
|
@ -639,7 +640,7 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
|
|||
set_current_ap (self, new_ap, TRUE, FALSE);
|
||||
}
|
||||
|
||||
new_rate = nm_platform_wifi_get_rate (ifindex);
|
||||
new_rate = nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex);
|
||||
if (new_rate != priv->rate) {
|
||||
priv->rate = new_rate;
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_BITRATE);
|
||||
|
|
@ -738,7 +739,7 @@ deactivate (NMDevice *device)
|
|||
set_current_ap (self, NULL, TRUE, FALSE);
|
||||
|
||||
/* Clear any critical protocol notification in the Wi-Fi stack */
|
||||
nm_platform_wifi_indicate_addressing_running (ifindex, FALSE);
|
||||
nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, ifindex, FALSE);
|
||||
|
||||
/* Reset MAC address back to initial address */
|
||||
if (priv->initial_hw_addr)
|
||||
|
|
@ -747,9 +748,9 @@ deactivate (NMDevice *device)
|
|||
/* Ensure we're in infrastructure mode after deactivation; some devices
|
||||
* (usually older ones) don't scan well in adhoc mode.
|
||||
*/
|
||||
if (nm_platform_wifi_get_mode (ifindex) != NM_802_11_MODE_INFRA) {
|
||||
if (nm_platform_wifi_get_mode (NM_PLATFORM_GET, ifindex) != NM_802_11_MODE_INFRA) {
|
||||
nm_device_take_down (NM_DEVICE (self), TRUE);
|
||||
nm_platform_wifi_set_mode (ifindex, NM_802_11_MODE_INFRA);
|
||||
nm_platform_wifi_set_mode (NM_PLATFORM_GET, ifindex, NM_802_11_MODE_INFRA);
|
||||
nm_device_bring_up (NM_DEVICE (self), TRUE, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -2687,9 +2688,9 @@ ensure_hotspot_frequency (NMDeviceWifi *self,
|
|||
return;
|
||||
|
||||
if (g_strcmp0 (band, "a") == 0)
|
||||
freq = nm_platform_wifi_find_frequency (nm_device_get_ifindex (NM_DEVICE (self)), a_freqs);
|
||||
freq = nm_platform_wifi_find_frequency (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), a_freqs);
|
||||
else
|
||||
freq = nm_platform_wifi_find_frequency (nm_device_get_ifindex (NM_DEVICE (self)), bg_freqs);
|
||||
freq = nm_platform_wifi_find_frequency (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), bg_freqs);
|
||||
|
||||
if (!freq)
|
||||
freq = (g_strcmp0 (band, "a") == 0) ? 5180 : 2462;
|
||||
|
|
@ -2823,7 +2824,7 @@ act_stage3_ip4_config_start (NMDevice *device,
|
|||
|
||||
/* Indicate that a critical protocol is about to start */
|
||||
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0)
|
||||
nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), TRUE);
|
||||
nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE);
|
||||
|
||||
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip4_config_start (device, out_config, reason);
|
||||
}
|
||||
|
|
@ -2846,7 +2847,7 @@ act_stage3_ip6_config_start (NMDevice *device,
|
|||
/* Indicate that a critical protocol is about to start */
|
||||
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 ||
|
||||
strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0)
|
||||
nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), TRUE);
|
||||
nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE);
|
||||
|
||||
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, reason);
|
||||
}
|
||||
|
|
@ -2998,7 +2999,7 @@ activation_success_handler (NMDevice *device)
|
|||
g_assert (connection);
|
||||
|
||||
/* Clear any critical protocol notification in the wifi stack */
|
||||
nm_platform_wifi_indicate_addressing_running (ifindex, FALSE);
|
||||
nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, ifindex, FALSE);
|
||||
|
||||
/* Clear wireless secrets tries on success */
|
||||
g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
|
||||
|
|
@ -3017,16 +3018,16 @@ activation_success_handler (NMDevice *device)
|
|||
* But if activation was successful, the card will know the BSSID. Grab
|
||||
* the BSSID off the card and fill in the BSSID of the activation AP.
|
||||
*/
|
||||
nm_platform_wifi_get_bssid (ifindex, bssid);
|
||||
nm_platform_wifi_get_bssid (NM_PLATFORM_GET, ifindex, bssid);
|
||||
if (!nm_ap_get_address (ap)) {
|
||||
char *bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
|
||||
nm_ap_set_address (ap, bssid_str);
|
||||
g_free (bssid_str);
|
||||
}
|
||||
if (!nm_ap_get_freq (ap))
|
||||
nm_ap_set_freq (ap, nm_platform_wifi_get_frequency (ifindex));
|
||||
nm_ap_set_freq (ap, nm_platform_wifi_get_frequency (NM_PLATFORM_GET, ifindex));
|
||||
if (!nm_ap_get_max_bitrate (ap))
|
||||
nm_ap_set_max_bitrate (ap, nm_platform_wifi_get_rate (ifindex));
|
||||
nm_ap_set_max_bitrate (ap, nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex));
|
||||
|
||||
tmp_ap = find_active_ap (self, ap, TRUE);
|
||||
if (tmp_ap) {
|
||||
|
|
@ -3076,7 +3077,7 @@ activation_failure_handler (NMDevice *device)
|
|||
g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
|
||||
|
||||
/* Clear any critical protocol notification in the wifi stack */
|
||||
nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), FALSE);
|
||||
nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3126,7 +3127,7 @@ device_state_changed (NMDevice *device,
|
|||
break;
|
||||
case NM_DEVICE_STATE_IP_CHECK:
|
||||
/* Clear any critical protocol notification in the wifi stack */
|
||||
nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), FALSE);
|
||||
nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), FALSE);
|
||||
break;
|
||||
case NM_DEVICE_STATE_ACTIVATED:
|
||||
activation_success_handler (device);
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ nm_modem_ip4_pre_commit (NMModem *modem,
|
|||
|
||||
g_assert (address);
|
||||
if (address->plen == 32)
|
||||
nm_platform_link_set_noarp (nm_device_get_ip_ifindex (device));
|
||||
nm_platform_link_set_noarp (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -912,9 +912,9 @@ deactivate_cleanup (NMModem *self, NMDevice *device)
|
|||
priv->ip6_method == NM_MODEM_IP_METHOD_AUTO) {
|
||||
ifindex = nm_device_get_ip_ifindex (device);
|
||||
if (ifindex > 0) {
|
||||
nm_platform_route_flush (ifindex);
|
||||
nm_platform_address_flush (ifindex);
|
||||
nm_platform_link_set_down (ifindex);
|
||||
nm_platform_route_flush (NM_PLATFORM_GET, ifindex);
|
||||
nm_platform_address_flush (NM_PLATFORM_GET, ifindex);
|
||||
nm_platform_link_set_down (NM_PLATFORM_GET, ifindex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ main (int argc, char *argv[])
|
|||
* physical interfaces.
|
||||
*/
|
||||
nm_log_dbg (LOGD_CORE, "setting up local loopback");
|
||||
nm_platform_link_set_up (1);
|
||||
nm_platform_link_set_up (NM_PLATFORM_GET, 1);
|
||||
|
||||
success = TRUE;
|
||||
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ carrier_wait (const char *iface, guint secs, gboolean up)
|
|||
|
||||
g_return_if_fail (iface != NULL);
|
||||
|
||||
ifindex = nm_platform_link_get_ifindex (iface);
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, iface);
|
||||
if (ifindex > 0) {
|
||||
/* To work around driver quirks and lldpad handling of carrier status,
|
||||
* we must wait a short period of time to see if the carrier goes
|
||||
|
|
@ -366,9 +366,9 @@ carrier_wait (const char *iface, guint secs, gboolean up)
|
|||
nm_log_dbg (LOGD_DCB, "(%s): cleanup waiting for carrier %s",
|
||||
iface, up ? "up" : "down");
|
||||
g_usleep (G_USEC_PER_SEC / 4);
|
||||
while (nm_platform_link_is_connected (ifindex) != up && count-- > 0) {
|
||||
while (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex) != up && count-- > 0) {
|
||||
g_usleep (G_USEC_PER_SEC / 10);
|
||||
nm_platform_link_refresh (ifindex);
|
||||
nm_platform_link_refresh (NM_PLATFORM_GET, ifindex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,7 +256,8 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g
|
|||
return FALSE;
|
||||
|
||||
if (vtable->vt->is_ip4) {
|
||||
success = nm_platform_ip4_route_add (entry->route.rx.ifindex,
|
||||
success = nm_platform_ip4_route_add (NM_PLATFORM_GET,
|
||||
entry->route.rx.ifindex,
|
||||
entry->route.rx.source,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -265,7 +266,8 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g
|
|||
entry->effective_metric,
|
||||
entry->route.rx.mss);
|
||||
} else {
|
||||
success = nm_platform_ip6_route_add (entry->route.rx.ifindex,
|
||||
success = nm_platform_ip6_route_add (NM_PLATFORM_GET,
|
||||
entry->route.rx.ifindex,
|
||||
entry->route.rx.source,
|
||||
in6addr_any,
|
||||
0,
|
||||
|
|
@ -290,7 +292,7 @@ _platform_route_sync_flush (const VTableIP *vtable, NMDefaultRouteManager *self,
|
|||
gboolean changed = FALSE;
|
||||
|
||||
/* prune all other default routes from this device. */
|
||||
routes = vtable->vt->route_get_all (0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
||||
routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
||||
|
||||
for (i = 0; i < routes->len; i++) {
|
||||
const NMPlatformIPRoute *route;
|
||||
|
|
@ -322,7 +324,7 @@ _platform_route_sync_flush (const VTableIP *vtable, NMDefaultRouteManager *self,
|
|||
*/
|
||||
if ( !entry
|
||||
&& (has_ifindex_synced || ifindex_to_flush == route->ifindex)) {
|
||||
vtable->vt->route_delete_default (route->ifindex, route->metric);
|
||||
vtable->vt->route_delete_default (NM_PLATFORM_GET, route->ifindex, route->metric);
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -452,7 +454,7 @@ _resync_all (const VTableIP *vtable, NMDefaultRouteManager *self, const Entry *c
|
|||
|
||||
entries = vtable->get_entries (priv);
|
||||
|
||||
routes = vtable->vt->route_get_all (0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
||||
routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
||||
|
||||
assumed_metrics = _get_assumed_interface_metrics (vtable, self, routes);
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
|
|||
* from adding a prefix route for this address.
|
||||
**/
|
||||
system_support = nm_platform_check_support_libnl_extended_ifa_flags () &&
|
||||
nm_platform_check_support_kernel_extended_ifa_flags ();
|
||||
nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET);
|
||||
}
|
||||
|
||||
if (system_support)
|
||||
|
|
@ -227,13 +227,13 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
|
|||
}
|
||||
|
||||
if (changed & NM_RDISC_CONFIG_HOP_LIMIT)
|
||||
nm_platform_sysctl_set_ip6_hop_limit_safe (global_opt.ifname, rdisc->hop_limit);
|
||||
nm_platform_sysctl_set_ip6_hop_limit_safe (NM_PLATFORM_GET, global_opt.ifname, rdisc->hop_limit);
|
||||
|
||||
if (changed & NM_RDISC_CONFIG_MTU) {
|
||||
char val[16];
|
||||
|
||||
g_snprintf (val, sizeof (val), "%d", rdisc->mtu);
|
||||
nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "mtu"), val);
|
||||
nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "mtu"), val);
|
||||
}
|
||||
|
||||
existing = nm_ip6_config_capture (ifindex, FALSE, global_opt.tempaddr);
|
||||
|
|
@ -424,7 +424,7 @@ main (int argc, char *argv[])
|
|||
/* Set up platform interaction layer */
|
||||
nm_linux_platform_setup ();
|
||||
|
||||
tmp = nm_platform_link_get_address (ifindex, &hwaddr_len);
|
||||
tmp = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddr_len);
|
||||
if (tmp) {
|
||||
hwaddr = g_byte_array_sized_new (hwaddr_len);
|
||||
g_byte_array_append (hwaddr, tmp, hwaddr_len);
|
||||
|
|
@ -443,7 +443,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (global_opt.dhcp4_address) {
|
||||
nm_platform_sysctl_set (nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1");
|
||||
nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1");
|
||||
|
||||
/* Initialize DHCP manager */
|
||||
dhcp_mgr = nm_dhcp_manager_get ();
|
||||
|
|
@ -469,7 +469,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (global_opt.slaac) {
|
||||
nm_platform_link_set_user_ipv6ll_enabled (ifindex, TRUE);
|
||||
nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, TRUE);
|
||||
|
||||
rdisc = nm_lndp_rdisc_new (ifindex, global_opt.ifname);
|
||||
g_assert (rdisc);
|
||||
|
|
@ -477,10 +477,10 @@ main (int argc, char *argv[])
|
|||
if (iid)
|
||||
nm_rdisc_set_iid (rdisc, *iid);
|
||||
|
||||
nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1");
|
||||
nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0");
|
||||
nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0");
|
||||
nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0");
|
||||
nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1");
|
||||
nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0");
|
||||
nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0");
|
||||
nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0");
|
||||
|
||||
g_signal_connect (rdisc,
|
||||
NM_RDISC_CONFIG_CHANGED,
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||
gboolean has_gateway = FALSE;
|
||||
|
||||
/* Slaves have no IP configuration */
|
||||
if (nm_platform_link_get_master (ifindex) > 0)
|
||||
if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0)
|
||||
return NULL;
|
||||
|
||||
config = nm_ip4_config_new ();
|
||||
|
|
@ -195,8 +195,8 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||
g_array_unref (priv->addresses);
|
||||
g_array_unref (priv->routes);
|
||||
|
||||
priv->addresses = nm_platform_ip4_address_get_all (ifindex);
|
||||
priv->routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
priv->addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
priv->routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
|
||||
/* Extract gateway from default route */
|
||||
old_gateway = priv->gateway;
|
||||
|
|
@ -260,7 +260,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
|
|||
g_return_val_if_fail (config != NULL, FALSE);
|
||||
|
||||
/* Addresses */
|
||||
nm_platform_ip4_address_sync (ifindex, priv->addresses, default_route_metric);
|
||||
nm_platform_ip4_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, default_route_metric);
|
||||
|
||||
/* Routes */
|
||||
{
|
||||
|
|
@ -282,7 +282,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
|
|||
g_array_append_vals (routes, route, 1);
|
||||
}
|
||||
|
||||
success = nm_platform_ip4_route_sync (ifindex, routes);
|
||||
success = nm_platform_ip4_route_sync (NM_PLATFORM_GET, ifindex, routes);
|
||||
g_array_unref (routes);
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
|
|||
gboolean notify_nameservers = FALSE;
|
||||
|
||||
/* Slaves have no IP configuration */
|
||||
if (nm_platform_link_get_master (ifindex) > 0)
|
||||
if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0)
|
||||
return NULL;
|
||||
|
||||
config = nm_ip6_config_new ();
|
||||
|
|
@ -307,8 +307,8 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
|
|||
g_array_unref (priv->addresses);
|
||||
g_array_unref (priv->routes);
|
||||
|
||||
priv->addresses = nm_platform_ip6_address_get_all (ifindex);
|
||||
priv->routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
priv->addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
priv->routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
|
||||
/* Extract gateway from default route */
|
||||
old_gateway = priv->gateway;
|
||||
|
|
@ -375,7 +375,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex)
|
|||
g_return_val_if_fail (config != NULL, FALSE);
|
||||
|
||||
/* Addresses */
|
||||
nm_platform_ip6_address_sync (ifindex, priv->addresses, TRUE);
|
||||
nm_platform_ip6_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, TRUE);
|
||||
|
||||
/* Routes */
|
||||
{
|
||||
|
|
@ -396,7 +396,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex)
|
|||
g_array_append_vals (routes, route, 1);
|
||||
}
|
||||
|
||||
success = nm_platform_ip6_route_sync (ifindex, routes);
|
||||
success = nm_platform_ip6_route_sync (NM_PLATFORM_GET, ifindex, routes);
|
||||
g_array_unref (routes);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1096,7 +1096,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection, GError
|
|||
*/
|
||||
priv->ignore_link_added_cb++;
|
||||
|
||||
nm_owned = !nm_platform_link_exists (iface);
|
||||
nm_owned = !nm_platform_link_exists (NM_PLATFORM_GET, iface);
|
||||
|
||||
for (iter = priv->factories; iter; iter = iter->next) {
|
||||
device = nm_device_factory_create_virtual_device_for_connection (NM_DEVICE_FACTORY (iter->data),
|
||||
|
|
@ -1579,13 +1579,13 @@ get_existing_connection (NMManager *manager, NMDevice *device, gboolean *out_gen
|
|||
nm_device_capture_initial_config (device);
|
||||
|
||||
if (ifindex) {
|
||||
int master_ifindex = nm_platform_link_get_master (ifindex);
|
||||
int master_ifindex = nm_platform_link_get_master (NM_PLATFORM_GET, ifindex);
|
||||
|
||||
if (master_ifindex) {
|
||||
master = nm_manager_get_device_by_ifindex (manager, master_ifindex);
|
||||
if (!master) {
|
||||
nm_log_dbg (LOGD_DEVICE, "(%s): cannot generate connection for slave before its master (%s/%d)",
|
||||
nm_device_get_iface (device), nm_platform_link_get_name (master_ifindex), master_ifindex);
|
||||
nm_device_get_iface (device), nm_platform_link_get_name (NM_PLATFORM_GET, master_ifindex), master_ifindex);
|
||||
return NULL;
|
||||
}
|
||||
if (!nm_device_get_act_request (master)) {
|
||||
|
|
@ -1877,7 +1877,7 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
|
|||
user_unmanaged = nm_device_spec_match_list (device, unmanaged_specs);
|
||||
nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_USER, user_unmanaged);
|
||||
|
||||
if (nm_platform_link_get_unmanaged (nm_device_get_ifindex (device), &platform_unmanaged))
|
||||
if (nm_platform_link_get_unmanaged (NM_PLATFORM_GET, nm_device_get_ifindex (device), &platform_unmanaged))
|
||||
nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_DEFAULT, platform_unmanaged);
|
||||
|
||||
sleeping = manager_sleeping (self);
|
||||
|
|
@ -3673,7 +3673,7 @@ done:
|
|||
static gboolean
|
||||
device_is_wake_on_lan (NMDevice *device)
|
||||
{
|
||||
return nm_platform_link_get_wake_on_lan (nm_device_get_ip_ifindex (device));
|
||||
return nm_platform_link_get_wake_on_lan (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -4268,7 +4268,7 @@ nm_manager_start (NMManager *self)
|
|||
for (iter = priv->factories; iter; iter = iter->next)
|
||||
nm_device_factory_start (iter->data);
|
||||
|
||||
nm_platform_query_devices ();
|
||||
nm_platform_query_devices (NM_PLATFORM_GET);
|
||||
|
||||
/*
|
||||
* Connections added before the manager is started do not emit
|
||||
|
|
|
|||
|
|
@ -1152,7 +1152,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
|
|||
route.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
route.ifindex = ifindex;
|
||||
route.source = source;
|
||||
route.network = network;
|
||||
route.network = nm_utils_ip4_address_clear_host_address (network, plen);
|
||||
route.plen = plen;
|
||||
route.gateway = gateway;
|
||||
route.metric = metric;
|
||||
|
|
@ -1169,8 +1169,8 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
|
|||
break;
|
||||
}
|
||||
if (i == priv->ip4_routes->len) {
|
||||
g_warning ("Fake platform: error adding %s: Network Unreachable",
|
||||
nm_platform_ip4_route_to_string (&route));
|
||||
nm_log_warn (LOGD_PLATFORM, "Fake platform: error adding %s: Network Unreachable",
|
||||
nm_platform_ip4_route_to_string (&route));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1217,7 +1217,7 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
|
|||
route.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
route.ifindex = ifindex;
|
||||
route.source = source;
|
||||
route.network = network;
|
||||
nm_utils_ip6_address_clear_host_address (&route.network, &network, plen);
|
||||
route.plen = plen;
|
||||
route.gateway = gateway;
|
||||
route.metric = metric;
|
||||
|
|
@ -1236,8 +1236,8 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
|
|||
break;
|
||||
}
|
||||
if (i == priv->ip6_routes->len) {
|
||||
g_warning ("Fake platform: error adding %s: Network Unreachable",
|
||||
nm_platform_ip6_route_to_string (&route));
|
||||
nm_log_warn (LOGD_PLATFORM, "Fake platform: error adding %s: Network Unreachable",
|
||||
nm_platform_ip6_route_to_string (&route));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,16 @@
|
|||
#define warning(...) nm_log_warn (LOGD_PLATFORM, __VA_ARGS__)
|
||||
#define error(...) nm_log_err (LOGD_PLATFORM, __VA_ARGS__)
|
||||
|
||||
#define return_type(t, name) \
|
||||
G_STMT_START { \
|
||||
if (out_name) \
|
||||
*out_name = name; \
|
||||
return t; \
|
||||
} G_STMT_END
|
||||
|
||||
/******************************************************************
|
||||
* libnl unility functions and wrappers
|
||||
******************************************************************/
|
||||
|
||||
struct libnl_vtable
|
||||
{
|
||||
|
|
@ -79,41 +89,6 @@ struct libnl_vtable
|
|||
int (*f_nl_has_capability) (int capability);
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct nl_sock *nlh;
|
||||
struct nl_sock *nlh_event;
|
||||
struct nl_cache *link_cache;
|
||||
struct nl_cache *address_cache;
|
||||
struct nl_cache *route_cache;
|
||||
GIOChannel *event_channel;
|
||||
guint event_id;
|
||||
|
||||
GUdevClient *udev_client;
|
||||
GHashTable *udev_devices;
|
||||
|
||||
GHashTable *wifi_data;
|
||||
|
||||
int support_kernel_extended_ifa_flags;
|
||||
int support_user_ipv6ll;
|
||||
} NMLinuxPlatformPrivate;
|
||||
|
||||
#define NM_LINUX_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_LINUX_PLATFORM, NMLinuxPlatformPrivate))
|
||||
|
||||
G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM)
|
||||
|
||||
static const char *to_string_object (NMPlatform *platform, struct nl_object *obj);
|
||||
static gboolean _address_match (struct rtnl_addr *addr, int family, int ifindex);
|
||||
static gboolean _route_match (struct rtnl_route *rtnlroute, int family, int ifindex, gboolean include_proto_kernel);
|
||||
|
||||
void
|
||||
nm_linux_platform_setup (void)
|
||||
{
|
||||
nm_platform_setup (NM_TYPE_LINUX_PLATFORM);
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static int
|
||||
_nl_f_nl_has_capability (int capability)
|
||||
{
|
||||
|
|
@ -149,57 +124,6 @@ _nl_has_capability (int capability)
|
|||
return (_nl_get_vtable ()->f_nl_has_capability) (capability);
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static guint32
|
||||
_get_expiry (guint32 now_s, guint32 lifetime_s)
|
||||
{
|
||||
gint64 t = ((gint64) now_s) + ((gint64) lifetime_s);
|
||||
|
||||
return MIN (t, NM_PLATFORM_LIFETIME_PERMANENT - 1);
|
||||
}
|
||||
|
||||
/* The rtnl_addr object contains relative lifetimes @valid and @preferred
|
||||
* that count in seconds, starting from the moment when the kernel constructed
|
||||
* the netlink message.
|
||||
*
|
||||
* There is also a field rtnl_addr_last_update_time(), which is the absolute
|
||||
* time in 1/100th of a second of clock_gettime (CLOCK_MONOTONIC) when the address
|
||||
* was modified (wrapping every 497 days).
|
||||
* Immediately at the time when the address was last modified, #NOW and @last_update_time
|
||||
* are the same, so (only) in that case @valid and @preferred are anchored at @last_update_time.
|
||||
* However, this is not true in general. As time goes by, whenever kernel sends a new address
|
||||
* via netlink, the lifetimes keep counting down.
|
||||
*
|
||||
* As we cache the rtnl_addr object we must know the absolute expiries.
|
||||
* As a hack, modify the relative timestamps valid and preferred into absolute
|
||||
* timestamps of scale nm_utils_get_monotonic_timestamp_s().
|
||||
**/
|
||||
static void
|
||||
_rtnl_addr_hack_lifetimes_rel_to_abs (struct rtnl_addr *rtnladdr)
|
||||
{
|
||||
guint32 a_valid = rtnl_addr_get_valid_lifetime (rtnladdr);
|
||||
guint32 a_preferred = rtnl_addr_get_preferred_lifetime (rtnladdr);
|
||||
guint32 now;
|
||||
|
||||
if (a_valid == NM_PLATFORM_LIFETIME_PERMANENT &&
|
||||
a_preferred == NM_PLATFORM_LIFETIME_PERMANENT)
|
||||
return;
|
||||
|
||||
now = (guint32) nm_utils_get_monotonic_timestamp_s ();
|
||||
|
||||
if (a_preferred > a_valid)
|
||||
a_preferred = a_valid;
|
||||
|
||||
if (a_valid != NM_PLATFORM_LIFETIME_PERMANENT)
|
||||
rtnl_addr_set_valid_lifetime (rtnladdr, _get_expiry (now, a_valid));
|
||||
rtnl_addr_set_preferred_lifetime (rtnladdr, _get_expiry (now, a_preferred));
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
/* libnl library workarounds and additions */
|
||||
|
||||
/* Automatic deallocation of local variables */
|
||||
#define auto_nl_cache __attribute__((cleanup(put_nl_cache)))
|
||||
static void
|
||||
|
|
@ -237,8 +161,6 @@ put_nl_addr (void *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
/* wrap the libnl alloc functions and abort on out-of-memory*/
|
||||
|
||||
static struct nl_addr *
|
||||
|
|
@ -303,8 +225,6 @@ _nm_rtnl_route_nh_alloc (void)
|
|||
return nexthop;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
/* rtnl_addr_set_prefixlen fails to update the nl_addr prefixlen */
|
||||
static void
|
||||
nm_rtnl_addr_set_prefixlen (struct rtnl_addr *rtnladdr, int plen)
|
||||
|
|
@ -319,6 +239,213 @@ nm_rtnl_addr_set_prefixlen (struct rtnl_addr *rtnladdr, int plen)
|
|||
}
|
||||
#define rtnl_addr_set_prefixlen nm_rtnl_addr_set_prefixlen
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static guint32
|
||||
_get_expiry (guint32 now_s, guint32 lifetime_s)
|
||||
{
|
||||
gint64 t = ((gint64) now_s) + ((gint64) lifetime_s);
|
||||
|
||||
return MIN (t, NM_PLATFORM_LIFETIME_PERMANENT - 1);
|
||||
}
|
||||
|
||||
/* The rtnl_addr object contains relative lifetimes @valid and @preferred
|
||||
* that count in seconds, starting from the moment when the kernel constructed
|
||||
* the netlink message.
|
||||
*
|
||||
* There is also a field rtnl_addr_last_update_time(), which is the absolute
|
||||
* time in 1/100th of a second of clock_gettime (CLOCK_MONOTONIC) when the address
|
||||
* was modified (wrapping every 497 days).
|
||||
* Immediately at the time when the address was last modified, #NOW and @last_update_time
|
||||
* are the same, so (only) in that case @valid and @preferred are anchored at @last_update_time.
|
||||
* However, this is not true in general. As time goes by, whenever kernel sends a new address
|
||||
* via netlink, the lifetimes keep counting down.
|
||||
*
|
||||
* As we cache the rtnl_addr object we must know the absolute expiries.
|
||||
* As a hack, modify the relative timestamps valid and preferred into absolute
|
||||
* timestamps of scale nm_utils_get_monotonic_timestamp_s().
|
||||
**/
|
||||
static void
|
||||
_rtnl_addr_hack_lifetimes_rel_to_abs (struct rtnl_addr *rtnladdr)
|
||||
{
|
||||
guint32 a_valid = rtnl_addr_get_valid_lifetime (rtnladdr);
|
||||
guint32 a_preferred = rtnl_addr_get_preferred_lifetime (rtnladdr);
|
||||
guint32 now;
|
||||
|
||||
if (a_valid == NM_PLATFORM_LIFETIME_PERMANENT &&
|
||||
a_preferred == NM_PLATFORM_LIFETIME_PERMANENT)
|
||||
return;
|
||||
|
||||
now = (guint32) nm_utils_get_monotonic_timestamp_s ();
|
||||
|
||||
if (a_preferred > a_valid)
|
||||
a_preferred = a_valid;
|
||||
|
||||
if (a_valid != NM_PLATFORM_LIFETIME_PERMANENT)
|
||||
rtnl_addr_set_valid_lifetime (rtnladdr, _get_expiry (now, a_valid));
|
||||
rtnl_addr_set_preferred_lifetime (rtnladdr, _get_expiry (now, a_preferred));
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* ethtool
|
||||
******************************************************************/
|
||||
|
||||
static gboolean
|
||||
ethtool_get (const char *name, gpointer edata)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int fd;
|
||||
|
||||
memset (&ifr, 0, sizeof (ifr));
|
||||
strncpy (ifr.ifr_name, name, IFNAMSIZ);
|
||||
ifr.ifr_data = edata;
|
||||
|
||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
error ("ethtool: Could not open socket.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ioctl (fd, SIOCETHTOOL, &ifr) < 0) {
|
||||
debug ("ethtool: Request failed: %s", strerror (errno));
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
ethtool_get_stringset_index (const char *ifname, int stringset_id, const char *string)
|
||||
{
|
||||
gs_free struct ethtool_sset_info *info = NULL;
|
||||
gs_free struct ethtool_gstrings *strings = NULL;
|
||||
guint32 len, i;
|
||||
|
||||
info = g_malloc0 (sizeof (*info) + sizeof (guint32));
|
||||
info->cmd = ETHTOOL_GSSET_INFO;
|
||||
info->reserved = 0;
|
||||
info->sset_mask = 1ULL << stringset_id;
|
||||
|
||||
if (!ethtool_get (ifname, info))
|
||||
return -1;
|
||||
if (!info->sset_mask)
|
||||
return -1;
|
||||
|
||||
len = info->data[0];
|
||||
|
||||
strings = g_malloc0 (sizeof (*strings) + len * ETH_GSTRING_LEN);
|
||||
strings->cmd = ETHTOOL_GSTRINGS;
|
||||
strings->string_set = stringset_id;
|
||||
strings->len = len;
|
||||
if (!ethtool_get (ifname, strings))
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!strcmp ((char *) &strings->data[i * ETH_GSTRING_LEN], string))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const char *
|
||||
ethtool_get_driver (const char *ifname)
|
||||
{
|
||||
struct ethtool_drvinfo drvinfo = { 0 };
|
||||
|
||||
g_return_val_if_fail (ifname != NULL, NULL);
|
||||
|
||||
drvinfo.cmd = ETHTOOL_GDRVINFO;
|
||||
if (!ethtool_get (ifname, &drvinfo))
|
||||
return NULL;
|
||||
|
||||
if (!*drvinfo.driver)
|
||||
return NULL;
|
||||
|
||||
return g_intern_string (drvinfo.driver);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* udev
|
||||
******************************************************************/
|
||||
|
||||
static const char *
|
||||
udev_get_driver (GUdevDevice *device, int ifindex)
|
||||
{
|
||||
GUdevDevice *parent = NULL, *grandparent = NULL;
|
||||
const char *driver, *subsys;
|
||||
|
||||
driver = g_udev_device_get_driver (device);
|
||||
if (driver)
|
||||
return driver;
|
||||
|
||||
/* Try the parent */
|
||||
parent = g_udev_device_get_parent (device);
|
||||
if (parent) {
|
||||
driver = g_udev_device_get_driver (parent);
|
||||
if (!driver) {
|
||||
/* Try the grandparent if it's an ibmebus device or if the
|
||||
* subsys is NULL which usually indicates some sort of
|
||||
* platform device like a 'gadget' net interface.
|
||||
*/
|
||||
subsys = g_udev_device_get_subsystem (parent);
|
||||
if ( (g_strcmp0 (subsys, "ibmebus") == 0)
|
||||
|| (subsys == NULL)) {
|
||||
grandparent = g_udev_device_get_parent (parent);
|
||||
if (grandparent) {
|
||||
driver = g_udev_device_get_driver (grandparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Intern the string so we don't have to worry about memory
|
||||
* management in NMPlatformLink.
|
||||
*/
|
||||
if (driver)
|
||||
driver = g_intern_string (driver);
|
||||
|
||||
g_clear_object (&parent);
|
||||
g_clear_object (&grandparent);
|
||||
|
||||
return driver;
|
||||
}
|
||||
|
||||
static NMLinkType
|
||||
udev_detect_link_type_from_device (GUdevDevice *udev_device, const char *ifname, int arptype, const char **out_name)
|
||||
{
|
||||
const char *prop, *sysfs_path;
|
||||
|
||||
g_assert (ifname);
|
||||
|
||||
if (!udev_device)
|
||||
return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
|
||||
|
||||
if ( g_udev_device_get_property (udev_device, "ID_NM_OLPC_MESH")
|
||||
|| g_udev_device_get_sysfs_attr (udev_device, "anycast_mask"))
|
||||
return_type (NM_LINK_TYPE_OLPC_MESH, "olpc-mesh");
|
||||
|
||||
prop = g_udev_device_get_property (udev_device, "DEVTYPE");
|
||||
sysfs_path = g_udev_device_get_sysfs_path (udev_device);
|
||||
if (wifi_utils_is_wifi (ifname, sysfs_path, prop))
|
||||
return_type (NM_LINK_TYPE_WIFI, "wifi");
|
||||
else if (g_strcmp0 (prop, "wwan") == 0)
|
||||
return_type (NM_LINK_TYPE_WWAN_ETHERNET, "wwan");
|
||||
else if (g_strcmp0 (prop, "wimax") == 0)
|
||||
return_type (NM_LINK_TYPE_WIMAX, "wimax");
|
||||
|
||||
if (arptype == ARPHRD_ETHER)
|
||||
return_type (NM_LINK_TYPE_ETHERNET, "ethernet");
|
||||
|
||||
return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* NMPlatform types and functions
|
||||
******************************************************************/
|
||||
|
||||
typedef enum {
|
||||
OBJECT_TYPE_UNKNOWN,
|
||||
OBJECT_TYPE_LINK,
|
||||
|
|
@ -327,10 +454,47 @@ typedef enum {
|
|||
OBJECT_TYPE_IP4_ROUTE,
|
||||
OBJECT_TYPE_IP6_ROUTE,
|
||||
__OBJECT_TYPE_LAST,
|
||||
OBJECT_TYPE_MAX = __OBJECT_TYPE_LAST - 1,
|
||||
} ObjectType;
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
typedef struct {
|
||||
struct nl_sock *nlh;
|
||||
struct nl_sock *nlh_event;
|
||||
struct nl_cache *link_cache;
|
||||
struct nl_cache *address_cache;
|
||||
struct nl_cache *route_cache;
|
||||
GIOChannel *event_channel;
|
||||
guint event_id;
|
||||
|
||||
GUdevClient *udev_client;
|
||||
GHashTable *udev_devices;
|
||||
|
||||
GHashTable *wifi_data;
|
||||
|
||||
int support_kernel_extended_ifa_flags;
|
||||
int support_user_ipv6ll;
|
||||
} NMLinuxPlatformPrivate;
|
||||
|
||||
#define NM_LINUX_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_LINUX_PLATFORM, NMLinuxPlatformPrivate))
|
||||
|
||||
G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM)
|
||||
|
||||
static const char *to_string_object (NMPlatform *platform, struct nl_object *obj);
|
||||
static gboolean _address_match (struct rtnl_addr *addr, int family, int ifindex);
|
||||
static gboolean _route_match (struct rtnl_route *rtnlroute, int family, int ifindex, gboolean include_proto_kernel);
|
||||
|
||||
void
|
||||
nm_linux_platform_setup (void)
|
||||
{
|
||||
nm_platform_setup (NM_TYPE_LINUX_PLATFORM);
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static ObjectType
|
||||
object_type_from_nl_object (const struct nl_object *object)
|
||||
_nlo_get_object_type (const struct nl_object *object)
|
||||
{
|
||||
const char *type_str;
|
||||
|
||||
|
|
@ -364,7 +528,7 @@ object_type_from_nl_object (const struct nl_object *object)
|
|||
static void
|
||||
_nl_link_family_unset (struct nl_object *obj, int *family)
|
||||
{
|
||||
if (!obj || object_type_from_nl_object (obj) != OBJECT_TYPE_LINK)
|
||||
if (!obj || _nlo_get_object_type (obj) != OBJECT_TYPE_LINK)
|
||||
*family = AF_UNSPEC;
|
||||
else {
|
||||
*family = rtnl_link_get_family ((struct rtnl_link *) obj);
|
||||
|
|
@ -407,7 +571,7 @@ static struct nl_object *
|
|||
get_kernel_object (struct nl_sock *sock, struct nl_object *needle)
|
||||
{
|
||||
struct nl_object *object = NULL;
|
||||
ObjectType type = object_type_from_nl_object (needle);
|
||||
ObjectType type = _nlo_get_object_type (needle);
|
||||
|
||||
switch (type) {
|
||||
case OBJECT_TYPE_LINK:
|
||||
|
|
@ -483,7 +647,7 @@ get_kernel_object (struct nl_sock *sock, struct nl_object *needle)
|
|||
static int
|
||||
add_kernel_object (struct nl_sock *sock, struct nl_object *object)
|
||||
{
|
||||
switch (object_type_from_nl_object (object)) {
|
||||
switch (_nlo_get_object_type (object)) {
|
||||
case OBJECT_TYPE_LINK:
|
||||
return rtnl_link_add (sock, (struct rtnl_link *) object, NLM_F_CREATE);
|
||||
case OBJECT_TYPE_IP4_ADDRESS:
|
||||
|
|
@ -582,68 +746,6 @@ nm_rtnl_link_parse_info_data (struct nl_sock *sk, int ifindex,
|
|||
|
||||
/******************************************************************/
|
||||
|
||||
static gboolean
|
||||
ethtool_get (const char *name, gpointer edata)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int fd;
|
||||
|
||||
memset (&ifr, 0, sizeof (ifr));
|
||||
strncpy (ifr.ifr_name, name, IFNAMSIZ);
|
||||
ifr.ifr_data = edata;
|
||||
|
||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
error ("ethtool: Could not open socket.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ioctl (fd, SIOCETHTOOL, &ifr) < 0) {
|
||||
debug ("ethtool: Request failed: %s", strerror (errno));
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
ethtool_get_stringset_index (const char *ifname, int stringset_id, const char *string)
|
||||
{
|
||||
gs_free struct ethtool_sset_info *info = NULL;
|
||||
gs_free struct ethtool_gstrings *strings = NULL;
|
||||
guint32 len, i;
|
||||
|
||||
info = g_malloc0 (sizeof (*info) + sizeof (guint32));
|
||||
info->cmd = ETHTOOL_GSSET_INFO;
|
||||
info->reserved = 0;
|
||||
info->sset_mask = 1ULL << stringset_id;
|
||||
|
||||
if (!ethtool_get (ifname, info))
|
||||
return -1;
|
||||
if (!info->sset_mask)
|
||||
return -1;
|
||||
|
||||
len = info->data[0];
|
||||
|
||||
strings = g_malloc0 (sizeof (*strings) + len * ETH_GSTRING_LEN);
|
||||
strings->cmd = ETHTOOL_GSTRINGS;
|
||||
strings->string_set = stringset_id;
|
||||
strings->len = len;
|
||||
if (!ethtool_get (ifname, strings))
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!strcmp ((char *) &strings->data[i * ETH_GSTRING_LEN], string))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static void
|
||||
_check_support_kernel_extended_ifa_flags_init (NMLinuxPlatformPrivate *priv, struct nl_msg *msg)
|
||||
{
|
||||
|
|
@ -741,62 +843,6 @@ type_to_string (NMLinkType type)
|
|||
}
|
||||
}
|
||||
|
||||
#define return_type(t, name) \
|
||||
G_STMT_START { \
|
||||
if (out_name) \
|
||||
*out_name = name; \
|
||||
return t; \
|
||||
} G_STMT_END
|
||||
|
||||
static NMLinkType
|
||||
link_type_from_udev (NMPlatform *platform, int ifindex, const char *ifname, int arptype, const char **out_name)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
GUdevDevice *udev_device;
|
||||
const char *prop, *sysfs_path;
|
||||
|
||||
g_assert (ifname);
|
||||
|
||||
udev_device = g_hash_table_lookup (priv->udev_devices, GINT_TO_POINTER (ifindex));
|
||||
if (!udev_device)
|
||||
return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
|
||||
|
||||
if ( g_udev_device_get_property (udev_device, "ID_NM_OLPC_MESH")
|
||||
|| g_udev_device_get_sysfs_attr (udev_device, "anycast_mask"))
|
||||
return_type (NM_LINK_TYPE_OLPC_MESH, "olpc-mesh");
|
||||
|
||||
prop = g_udev_device_get_property (udev_device, "DEVTYPE");
|
||||
sysfs_path = g_udev_device_get_sysfs_path (udev_device);
|
||||
if (wifi_utils_is_wifi (ifname, sysfs_path, prop))
|
||||
return_type (NM_LINK_TYPE_WIFI, "wifi");
|
||||
else if (g_strcmp0 (prop, "wwan") == 0)
|
||||
return_type (NM_LINK_TYPE_WWAN_ETHERNET, "wwan");
|
||||
else if (g_strcmp0 (prop, "wimax") == 0)
|
||||
return_type (NM_LINK_TYPE_WIMAX, "wimax");
|
||||
|
||||
if (arptype == ARPHRD_ETHER)
|
||||
return_type (NM_LINK_TYPE_ETHERNET, "ethernet");
|
||||
|
||||
return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
|
||||
}
|
||||
|
||||
static const char *
|
||||
ethtool_get_driver (const char *ifname)
|
||||
{
|
||||
struct ethtool_drvinfo drvinfo = { 0 };
|
||||
|
||||
g_return_val_if_fail (ifname != NULL, NULL);
|
||||
|
||||
drvinfo.cmd = ETHTOOL_GDRVINFO;
|
||||
if (!ethtool_get (ifname, &drvinfo))
|
||||
return NULL;
|
||||
|
||||
if (!*drvinfo.driver)
|
||||
return NULL;
|
||||
|
||||
return g_intern_string (drvinfo.driver);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
link_is_announceable (NMPlatform *platform, struct rtnl_link *rtnllink)
|
||||
{
|
||||
|
|
@ -824,6 +870,7 @@ link_extract_type (NMPlatform *platform, struct rtnl_link *rtnllink, const char
|
|||
int arptype = rtnl_link_get_arptype (rtnllink);
|
||||
const char *driver;
|
||||
const char *ifname;
|
||||
GUdevDevice *udev_device = NULL;
|
||||
|
||||
if (arptype == ARPHRD_LOOPBACK)
|
||||
return_type (NM_LINK_TYPE_LOOPBACK, "loopback");
|
||||
|
|
@ -846,11 +893,14 @@ link_extract_type (NMPlatform *platform, struct rtnl_link *rtnllink, const char
|
|||
if (!g_strcmp0 (driver, "openvswitch"))
|
||||
return_type (NM_LINK_TYPE_OPENVSWITCH, "openvswitch");
|
||||
|
||||
return link_type_from_udev (platform,
|
||||
rtnl_link_get_ifindex (rtnllink),
|
||||
ifname,
|
||||
arptype,
|
||||
out_name);
|
||||
if (platform) {
|
||||
udev_device = g_hash_table_lookup (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->udev_devices,
|
||||
GINT_TO_POINTER (rtnl_link_get_ifindex (rtnllink)));
|
||||
}
|
||||
return udev_detect_link_type_from_device (udev_device,
|
||||
ifname,
|
||||
arptype,
|
||||
out_name);
|
||||
} else if (!strcmp (type, "dummy"))
|
||||
return_type (NM_LINK_TYPE_DUMMY, "dummy");
|
||||
else if (!strcmp (type, "gre"))
|
||||
|
|
@ -867,7 +917,7 @@ link_extract_type (NMPlatform *platform, struct rtnl_link *rtnllink, const char
|
|||
NMPlatformTunProperties props;
|
||||
guint flags;
|
||||
|
||||
if (nm_platform_tun_get_properties (rtnl_link_get_ifindex (rtnllink), &props)) {
|
||||
if (nm_platform_tun_get_properties (platform, rtnl_link_get_ifindex (rtnllink), &props)) {
|
||||
if (!g_strcmp0 (props.mode, "tap"))
|
||||
return_type (NM_LINK_TYPE_TAP, "tap");
|
||||
if (!g_strcmp0 (props.mode, "tun"))
|
||||
|
|
@ -898,48 +948,6 @@ link_extract_type (NMPlatform *platform, struct rtnl_link *rtnllink, const char
|
|||
return_type (NM_LINK_TYPE_UNKNOWN, type);
|
||||
}
|
||||
|
||||
static const char *
|
||||
udev_get_driver (NMPlatform *platform, GUdevDevice *device, int ifindex)
|
||||
{
|
||||
GUdevDevice *parent = NULL, *grandparent = NULL;
|
||||
const char *driver, *subsys;
|
||||
|
||||
driver = g_udev_device_get_driver (device);
|
||||
if (driver)
|
||||
return driver;
|
||||
|
||||
/* Try the parent */
|
||||
parent = g_udev_device_get_parent (device);
|
||||
if (parent) {
|
||||
driver = g_udev_device_get_driver (parent);
|
||||
if (!driver) {
|
||||
/* Try the grandparent if it's an ibmebus device or if the
|
||||
* subsys is NULL which usually indicates some sort of
|
||||
* platform device like a 'gadget' net interface.
|
||||
*/
|
||||
subsys = g_udev_device_get_subsystem (parent);
|
||||
if ( (g_strcmp0 (subsys, "ibmebus") == 0)
|
||||
|| (subsys == NULL)) {
|
||||
grandparent = g_udev_device_get_parent (parent);
|
||||
if (grandparent) {
|
||||
driver = g_udev_device_get_driver (grandparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Intern the string so we don't have to worry about memory
|
||||
* management in NMPlatformLink.
|
||||
*/
|
||||
if (driver)
|
||||
driver = g_intern_string (driver);
|
||||
|
||||
g_clear_object (&parent);
|
||||
g_clear_object (&grandparent);
|
||||
|
||||
return driver;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
init_link (NMPlatform *platform, NMPlatformLink *info, struct rtnl_link *rtnllink)
|
||||
{
|
||||
|
|
@ -967,7 +975,7 @@ init_link (NMPlatform *platform, NMPlatformLink *info, struct rtnl_link *rtnllin
|
|||
|
||||
udev_device = g_hash_table_lookup (priv->udev_devices, GINT_TO_POINTER (info->ifindex));
|
||||
if (udev_device) {
|
||||
info->driver = udev_get_driver (platform, udev_device, info->ifindex);
|
||||
info->driver = udev_get_driver (udev_device, info->ifindex);
|
||||
if (!info->driver)
|
||||
info->driver = g_intern_string (rtnl_link_get_type (rtnllink));
|
||||
if (!info->driver)
|
||||
|
|
@ -1428,7 +1436,7 @@ to_string_object_with_type (NMPlatform *platform, struct nl_object *obj, ObjectT
|
|||
static const char *
|
||||
to_string_object (NMPlatform *platform, struct nl_object *obj)
|
||||
{
|
||||
return to_string_object_with_type (platform, obj, object_type_from_nl_object (obj));
|
||||
return to_string_object_with_type (platform, obj, _nlo_get_object_type (obj));
|
||||
}
|
||||
|
||||
#undef SET_AND_RETURN_STRING_BUFFER
|
||||
|
|
@ -1437,7 +1445,7 @@ to_string_object (NMPlatform *platform, struct nl_object *obj)
|
|||
|
||||
/* Object and cache manipulation */
|
||||
|
||||
static const char *signal_by_type_and_status[__OBJECT_TYPE_LAST] = {
|
||||
static const char *signal_by_type_and_status[OBJECT_TYPE_MAX + 1] = {
|
||||
[OBJECT_TYPE_LINK] = NM_PLATFORM_SIGNAL_LINK_CHANGED,
|
||||
[OBJECT_TYPE_IP4_ADDRESS] = NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED,
|
||||
[OBJECT_TYPE_IP6_ADDRESS] = NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED,
|
||||
|
|
@ -1468,13 +1476,13 @@ choose_cache_by_type (NMPlatform *platform, ObjectType object_type)
|
|||
static struct nl_cache *
|
||||
choose_cache (NMPlatform *platform, struct nl_object *object)
|
||||
{
|
||||
return choose_cache_by_type (platform, object_type_from_nl_object (object));
|
||||
return choose_cache_by_type (platform, _nlo_get_object_type (object));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
object_has_ifindex (struct nl_object *object, int ifindex)
|
||||
{
|
||||
switch (object_type_from_nl_object (object)) {
|
||||
switch (_nlo_get_object_type (object)) {
|
||||
case OBJECT_TYPE_IP4_ADDRESS:
|
||||
case OBJECT_TYPE_IP6_ADDRESS:
|
||||
return ifindex == rtnl_addr_get_ifindex ((struct rtnl_addr *) object);
|
||||
|
|
@ -1522,7 +1530,7 @@ static void
|
|||
announce_object (NMPlatform *platform, const struct nl_object *object, NMPlatformSignalChangeType change_type, NMPlatformReason reason)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
ObjectType object_type = object_type_from_nl_object (object);
|
||||
ObjectType object_type = _nlo_get_object_type (object);
|
||||
const char *sig = signal_by_type_and_status[object_type];
|
||||
|
||||
switch (object_type) {
|
||||
|
|
@ -1691,7 +1699,7 @@ refresh_object (NMPlatform *platform, struct nl_object *object, gboolean removed
|
|||
return FALSE;
|
||||
|
||||
/* Unsupported object types should never have reached the caches */
|
||||
type = object_type_from_nl_object (kernel_object);
|
||||
type = _nlo_get_object_type (kernel_object);
|
||||
g_assert (type != OBJECT_TYPE_UNKNOWN);
|
||||
|
||||
hack_empty_master_iff_lower_up (platform, kernel_object);
|
||||
|
|
@ -1777,7 +1785,7 @@ delete_object (NMPlatform *platform, struct nl_object *object, gboolean do_refre
|
|||
int nle;
|
||||
gboolean result = FALSE;
|
||||
|
||||
object_type = object_type_from_nl_object (object);
|
||||
object_type = _nlo_get_object_type (object);
|
||||
g_return_val_if_fail (object_type != OBJECT_TYPE_UNKNOWN, FALSE);
|
||||
|
||||
switch (object_type) {
|
||||
|
|
@ -1948,7 +1956,7 @@ event_notification (struct nl_msg *msg, gpointer user_data)
|
|||
nl_msg_parse (msg, ref_object, &object);
|
||||
g_return_val_if_fail (object, NL_OK);
|
||||
|
||||
type = object_type_from_nl_object (object);
|
||||
type = _nlo_get_object_type (object);
|
||||
|
||||
if (nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) {
|
||||
if (type == OBJECT_TYPE_LINK) {
|
||||
|
|
@ -2622,7 +2630,7 @@ supports_mii_carrier_detect (const char *ifname)
|
|||
static gboolean
|
||||
link_supports_carrier_detect (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
const char *name = nm_platform_link_get_name (ifindex);
|
||||
const char *name = nm_platform_link_get_name (platform, ifindex);
|
||||
|
||||
if (!name)
|
||||
return FALSE;
|
||||
|
|
@ -2638,7 +2646,7 @@ static gboolean
|
|||
link_supports_vlans (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
auto_nl_object struct rtnl_link *rtnllink = link_get (platform, ifindex);
|
||||
const char *name = nm_platform_link_get_name (ifindex);
|
||||
const char *name = nm_platform_link_get_name (platform, ifindex);
|
||||
gs_free struct ethtool_gfeatures *features = NULL;
|
||||
int idx, block, bit, size;
|
||||
|
||||
|
|
@ -2736,7 +2744,7 @@ link_get_physical_port_id (NMPlatform *platform, int ifindex)
|
|||
const char *ifname;
|
||||
char *path, *id;
|
||||
|
||||
ifname = nm_platform_link_get_name (ifindex);
|
||||
ifname = nm_platform_link_get_name (platform, ifindex);
|
||||
if (!ifname)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -2756,7 +2764,7 @@ link_get_dev_id (NMPlatform *platform, int ifindex)
|
|||
gs_free char *path = NULL, *id = NULL;
|
||||
gint64 int_val;
|
||||
|
||||
ifname = nm_platform_link_get_name (ifindex);
|
||||
ifname = nm_platform_link_get_name (platform, ifindex);
|
||||
if (!ifname)
|
||||
return 0;
|
||||
|
||||
|
|
@ -2869,10 +2877,10 @@ link_get_master (NMPlatform *platform, int slave)
|
|||
}
|
||||
|
||||
static char *
|
||||
link_option_path (int master, const char *category, const char *option)
|
||||
link_option_path (NMPlatform *platform, int master, const char *category, const char *option)
|
||||
{
|
||||
const char *name = nm_platform_link_get_name (master);
|
||||
|
||||
const char *name = nm_platform_link_get_name (platform, master);
|
||||
|
||||
if (!name || !category || !option)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -2883,19 +2891,19 @@ link_option_path (int master, const char *category, const char *option)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
link_set_option (int master, const char *category, const char *option, const char *value)
|
||||
link_set_option (NMPlatform *platform, int master, const char *category, const char *option, const char *value)
|
||||
{
|
||||
gs_free char *path = link_option_path (master, category, option);
|
||||
gs_free char *path = link_option_path (platform, master, category, option);
|
||||
|
||||
return path && nm_platform_sysctl_set (path, value);
|
||||
return path && nm_platform_sysctl_set (platform, path, value);
|
||||
}
|
||||
|
||||
static char *
|
||||
link_get_option (int master, const char *category, const char *option)
|
||||
link_get_option (NMPlatform *platform, int master, const char *category, const char *option)
|
||||
{
|
||||
gs_free char *path = link_option_path (master, category, option);
|
||||
gs_free char *path = link_option_path (platform, master, category, option);
|
||||
|
||||
return path ? nm_platform_sysctl_get (path) : NULL;
|
||||
return path ? nm_platform_sysctl_get (platform, path) : NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
@ -2934,25 +2942,25 @@ slave_category (NMPlatform *platform, int slave)
|
|||
static gboolean
|
||||
master_set_option (NMPlatform *platform, int master, const char *option, const char *value)
|
||||
{
|
||||
return link_set_option (master, master_category (platform, master), option, 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 (master, master_category (platform, master), 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 (slave, slave_category (platform, slave), option, 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 (slave, slave_category (platform, slave), option);
|
||||
return link_get_option (platform, slave, slave_category (platform, slave), option);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -2962,12 +2970,12 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key)
|
|||
char *path, *id;
|
||||
gboolean success;
|
||||
|
||||
parent_name = nm_platform_link_get_name (parent);
|
||||
parent_name = nm_platform_link_get_name (platform, parent);
|
||||
g_return_val_if_fail (parent_name != NULL, FALSE);
|
||||
|
||||
path = g_strdup_printf ("/sys/class/net/%s/create_child", ASSERT_VALID_PATH_COMPONENT (parent_name));
|
||||
id = g_strdup_printf ("0x%04x", p_key);
|
||||
success = nm_platform_sysctl_set (path, id);
|
||||
success = nm_platform_sysctl_set (platform, path, id);
|
||||
g_free (id);
|
||||
g_free (path);
|
||||
|
||||
|
|
@ -2988,7 +2996,7 @@ veth_get_properties (NMPlatform *platform, int ifindex, NMPlatformVethProperties
|
|||
gs_free struct ethtool_stats *stats = NULL;
|
||||
int peer_ifindex_stat;
|
||||
|
||||
ifname = nm_platform_link_get_name (ifindex);
|
||||
ifname = nm_platform_link_get_name (platform, ifindex);
|
||||
if (!ifname)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -3021,13 +3029,13 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
|
|||
props->owner = -1;
|
||||
props->group = -1;
|
||||
|
||||
ifname = nm_platform_link_get_name (ifindex);
|
||||
ifname = nm_platform_link_get_name (platform, ifindex);
|
||||
if (!ifname || !nm_utils_iface_valid_name (ifname))
|
||||
return FALSE;
|
||||
ifname = ASSERT_VALID_PATH_COMPONENT (ifname);
|
||||
|
||||
path = g_strdup_printf ("/sys/class/net/%s/owner", ifname);
|
||||
val = nm_platform_sysctl_get (path);
|
||||
val = nm_platform_sysctl_get (platform, path);
|
||||
g_free (path);
|
||||
if (val) {
|
||||
props->owner = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1);
|
||||
|
|
@ -3038,7 +3046,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
|
|||
success = FALSE;
|
||||
|
||||
path = g_strdup_printf ("/sys/class/net/%s/group", ifname);
|
||||
val = nm_platform_sysctl_get (path);
|
||||
val = nm_platform_sysctl_get (platform, path);
|
||||
g_free (path);
|
||||
if (val) {
|
||||
props->group = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1);
|
||||
|
|
@ -3049,7 +3057,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
|
|||
success = FALSE;
|
||||
|
||||
path = g_strdup_printf ("/sys/class/net/%s/tun_flags", ifname);
|
||||
val = nm_platform_sysctl_get (path);
|
||||
val = nm_platform_sysctl_get (platform, path);
|
||||
g_free (path);
|
||||
if (val) {
|
||||
gint64 flags;
|
||||
|
|
@ -3580,7 +3588,8 @@ ip4_is_link_local (const struct in_addr *src)
|
|||
}
|
||||
|
||||
static struct nl_object *
|
||||
build_rtnl_addr (int family,
|
||||
build_rtnl_addr (NMPlatform *platform,
|
||||
int family,
|
||||
int ifindex,
|
||||
gconstpointer addr,
|
||||
gconstpointer peer_addr,
|
||||
|
|
@ -3642,7 +3651,7 @@ build_rtnl_addr (int family,
|
|||
rtnl_addr_set_preferred_lifetime (rtnladdr, preferred);
|
||||
}
|
||||
if (flags) {
|
||||
if ((flags & ~0xFF) && !check_support_kernel_extended_ifa_flags (nm_platform_get ())) {
|
||||
if ((flags & ~0xFF) && !check_support_kernel_extended_ifa_flags (platform)) {
|
||||
/* Older kernels don't accept unknown netlink attributes.
|
||||
*
|
||||
* With commit libnl commit 5206c050504f8676a24854519b9c351470fb7cc6, libnl will only set
|
||||
|
|
@ -3672,7 +3681,7 @@ ip4_address_add (NMPlatform *platform,
|
|||
guint32 preferred,
|
||||
const char *label)
|
||||
{
|
||||
return add_object (platform, build_rtnl_addr (AF_INET, ifindex, &addr,
|
||||
return add_object (platform, build_rtnl_addr (platform, AF_INET, ifindex, &addr,
|
||||
peer_addr ? &peer_addr : NULL,
|
||||
plen, lifetime, preferred, 0,
|
||||
label));
|
||||
|
|
@ -3688,7 +3697,7 @@ ip6_address_add (NMPlatform *platform,
|
|||
guint32 preferred,
|
||||
guint flags)
|
||||
{
|
||||
return add_object (platform, build_rtnl_addr (AF_INET6, ifindex, &addr,
|
||||
return add_object (platform, build_rtnl_addr (platform, AF_INET6, ifindex, &addr,
|
||||
IN6_IS_ADDR_UNSPECIFIED (&peer_addr) ? NULL : &peer_addr,
|
||||
plen, lifetime, preferred, flags,
|
||||
NULL));
|
||||
|
|
@ -3697,19 +3706,19 @@ ip6_address_add (NMPlatform *platform,
|
|||
static gboolean
|
||||
ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in_addr_t peer_address)
|
||||
{
|
||||
return delete_object (platform, build_rtnl_addr (AF_INET, ifindex, &addr, peer_address ? &peer_address : NULL, plen, 0, 0, 0, NULL), TRUE);
|
||||
return delete_object (platform, build_rtnl_addr (platform, AF_INET, ifindex, &addr, peer_address ? &peer_address : NULL, plen, 0, 0, 0, NULL), TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int plen)
|
||||
{
|
||||
return delete_object (platform, build_rtnl_addr (AF_INET6, ifindex, &addr, NULL, plen, 0, 0, 0, NULL), TRUE);
|
||||
return delete_object (platform, build_rtnl_addr (platform, AF_INET6, ifindex, &addr, NULL, plen, 0, 0, 0, NULL), TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ip_address_exists (NMPlatform *platform, int family, int ifindex, gconstpointer addr, int plen)
|
||||
{
|
||||
auto_nl_object struct nl_object *object = build_rtnl_addr (family, ifindex, addr, NULL, plen, 0, 0, 0, NULL);
|
||||
auto_nl_object struct nl_object *object = build_rtnl_addr (platform, family, ifindex, addr, NULL, plen, 0, 0, 0, NULL);
|
||||
auto_nl_object struct nl_object *cached_object = nl_cache_search (choose_cache (platform, object), object);
|
||||
|
||||
return !!cached_object;
|
||||
|
|
@ -4153,7 +4162,7 @@ cache_announce_changes (NMPlatform *platform, struct nl_cache *new, struct nl_ca
|
|||
struct nl_object *cached_object = nm_nl_cache_search (old, object);
|
||||
|
||||
if (cached_object) {
|
||||
ObjectType type = object_type_from_nl_object (object);
|
||||
ObjectType type = _nlo_get_object_type (object);
|
||||
if (nm_nl_object_diff (type, object, cached_object))
|
||||
announce_object (platform, object, NM_PLATFORM_SIGNAL_CHANGED, NM_PLATFORM_REASON_EXTERNAL);
|
||||
nl_object_put (cached_object);
|
||||
|
|
@ -4180,7 +4189,7 @@ cache_remove_unknown (struct nl_cache *cache)
|
|||
struct nl_object *object;
|
||||
|
||||
for (object = nl_cache_get_first (cache); object; object = nl_cache_get_next (object)) {
|
||||
if (object_type_from_nl_object (object) == OBJECT_TYPE_UNKNOWN) {
|
||||
if (_nlo_get_object_type (object) == OBJECT_TYPE_UNKNOWN) {
|
||||
if (!objects_to_remove)
|
||||
objects_to_remove = g_ptr_array_new_with_free_func ((GDestroyNotify) nl_object_put);
|
||||
nl_object_get (object);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
/******************************************************************/
|
||||
|
||||
typedef struct _NMPlatform NMPlatform;
|
||||
|
||||
/* workaround for older libnl version, that does not define these flags. */
|
||||
#ifndef IFA_F_MANAGETEMPADDR
|
||||
#define IFA_F_MANAGETEMPADDR 0x100
|
||||
|
|
@ -252,10 +254,10 @@ typedef struct {
|
|||
gsize sizeof_route;
|
||||
int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b);
|
||||
const char *(*route_to_string) (const NMPlatformIPXRoute *route);
|
||||
GArray *(*route_get_all) (int ifindex, NMPlatformGetRouteMode mode);
|
||||
gboolean (*route_add) (int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref_src);
|
||||
gboolean (*route_delete) (int ifindex, const NMPlatformIPXRoute *route);
|
||||
gboolean (*route_delete_default) (int ifindex, guint32 metric);
|
||||
GArray *(*route_get_all) (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
|
||||
gboolean (*route_add) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref_src);
|
||||
gboolean (*route_delete) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route);
|
||||
gboolean (*route_delete_default) (NMPlatform *self, int ifindex, guint32 metric);
|
||||
guint32 (*metric_normalize) (guint32 metric);
|
||||
} NMPlatformVTableRoute;
|
||||
|
||||
|
|
@ -346,11 +348,11 @@ typedef struct {
|
|||
* network configuration daemons stopped. Look at the code first.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
struct _NMPlatform {
|
||||
GObject parent;
|
||||
|
||||
NMPlatformError error;
|
||||
} NMPlatform;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent;
|
||||
|
|
@ -491,134 +493,136 @@ void nm_platform_setup (GType type);
|
|||
NMPlatform *nm_platform_get (void);
|
||||
void nm_platform_free (void);
|
||||
|
||||
#define NM_PLATFORM_GET (nm_platform_get ())
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
void nm_platform_set_error (NMPlatformError error);
|
||||
NMPlatformError nm_platform_get_error (void);
|
||||
const char *nm_platform_get_error_msg (void);
|
||||
void nm_platform_set_error (NMPlatform *self, NMPlatformError error);
|
||||
NMPlatformError nm_platform_get_error (NMPlatform *self);
|
||||
const char *nm_platform_get_error_msg (NMPlatform *self);
|
||||
|
||||
void nm_platform_query_devices (void);
|
||||
void nm_platform_query_devices (NMPlatform *self);
|
||||
|
||||
gboolean nm_platform_sysctl_set (const char *path, const char *value);
|
||||
char *nm_platform_sysctl_get (const char *path);
|
||||
gint32 nm_platform_sysctl_get_int32 (const char *path, gint32 fallback);
|
||||
gint64 nm_platform_sysctl_get_int_checked (const char *path, guint base, gint64 min, gint64 max, gint64 fallback);
|
||||
gboolean nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value);
|
||||
char *nm_platform_sysctl_get (NMPlatform *self, const char *path);
|
||||
gint32 nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallback);
|
||||
gint64 nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint base, gint64 min, gint64 max, gint64 fallback);
|
||||
|
||||
gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (const char *iface, int value);
|
||||
gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, int value);
|
||||
|
||||
gboolean nm_platform_link_get (int ifindex, NMPlatformLink *link);
|
||||
GArray *nm_platform_link_get_all (void);
|
||||
gboolean nm_platform_dummy_add (const char *name);
|
||||
gboolean nm_platform_bridge_add (const char *name, const void *address, size_t address_len);
|
||||
gboolean nm_platform_bond_add (const char *name);
|
||||
gboolean nm_platform_team_add (const char *name);
|
||||
gboolean nm_platform_link_exists (const char *name);
|
||||
gboolean nm_platform_link_delete (int ifindex);
|
||||
int nm_platform_link_get_ifindex (const char *name);
|
||||
const char *nm_platform_link_get_name (int ifindex);
|
||||
NMLinkType nm_platform_link_get_type (int ifindex);
|
||||
const char *nm_platform_link_get_type_name (int ifindex);
|
||||
gboolean nm_platform_link_get_unmanaged (int ifindex, gboolean *managed);
|
||||
gboolean nm_platform_link_is_software (int ifindex);
|
||||
gboolean nm_platform_link_supports_slaves (int ifindex);
|
||||
gboolean nm_platform_link_get (NMPlatform *self, int ifindex, NMPlatformLink *link);
|
||||
GArray *nm_platform_link_get_all (NMPlatform *self);
|
||||
gboolean nm_platform_dummy_add (NMPlatform *self, const char *name);
|
||||
gboolean nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len);
|
||||
gboolean nm_platform_bond_add (NMPlatform *self, const char *name);
|
||||
gboolean nm_platform_team_add (NMPlatform *self, const char *name);
|
||||
gboolean nm_platform_link_exists (NMPlatform *self, const char *name);
|
||||
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
|
||||
int nm_platform_link_get_ifindex (NMPlatform *self, const char *name);
|
||||
const char *nm_platform_link_get_name (NMPlatform *self, int ifindex);
|
||||
NMLinkType nm_platform_link_get_type (NMPlatform *self, int ifindex);
|
||||
const char *nm_platform_link_get_type_name (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *managed);
|
||||
gboolean nm_platform_link_is_software (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_supports_slaves (NMPlatform *self, int ifindex);
|
||||
|
||||
gboolean nm_platform_link_refresh (int ifindex);
|
||||
gboolean nm_platform_link_refresh (NMPlatform *self, int ifindex);
|
||||
|
||||
gboolean nm_platform_link_set_up (int ifindex);
|
||||
gboolean nm_platform_link_set_down (int ifindex);
|
||||
gboolean nm_platform_link_set_arp (int ifindex);
|
||||
gboolean nm_platform_link_set_noarp (int ifindex);
|
||||
gboolean nm_platform_link_is_up (int ifindex);
|
||||
gboolean nm_platform_link_is_connected (int ifindex);
|
||||
gboolean nm_platform_link_uses_arp (int ifindex);
|
||||
gboolean nm_platform_link_set_up (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_set_down (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_set_arp (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_set_noarp (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_is_up (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_is_connected (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_uses_arp (NMPlatform *self, int ifindex);
|
||||
|
||||
gboolean nm_platform_link_get_ipv6_token (int ifindex, NMUtilsIPv6IfaceId *iid);
|
||||
gboolean nm_platform_link_get_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId *iid);
|
||||
|
||||
gboolean nm_platform_link_get_user_ipv6ll_enabled (int ifindex);
|
||||
gboolean nm_platform_link_set_user_ipv6ll_enabled (int ifindex, gboolean enabled);
|
||||
gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled);
|
||||
|
||||
gconstpointer nm_platform_link_get_address (int ifindex, size_t *length);
|
||||
gboolean nm_platform_link_set_address (int ifindex, const void *address, size_t length);
|
||||
guint32 nm_platform_link_get_mtu (int ifindex);
|
||||
gboolean nm_platform_link_set_mtu (int ifindex, guint32 mtu);
|
||||
gconstpointer nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length);
|
||||
gboolean nm_platform_link_set_address (NMPlatform *self, int ifindex, const void *address, size_t length);
|
||||
guint32 nm_platform_link_get_mtu (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu);
|
||||
|
||||
char *nm_platform_link_get_physical_port_id (int ifindex);
|
||||
guint nm_platform_link_get_dev_id (int ifindex);
|
||||
gboolean nm_platform_link_get_wake_on_lan (int ifindex);
|
||||
char *nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex);
|
||||
guint nm_platform_link_get_dev_id (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_get_wake_on_lan (NMPlatform *self, int ifindex);
|
||||
|
||||
gboolean nm_platform_link_supports_carrier_detect (int ifindex);
|
||||
gboolean nm_platform_link_supports_vlans (int ifindex);
|
||||
gboolean nm_platform_link_supports_carrier_detect (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_supports_vlans (NMPlatform *self, int ifindex);
|
||||
|
||||
gboolean nm_platform_link_enslave (int master, int slave);
|
||||
gboolean nm_platform_link_release (int master, int slave);
|
||||
int nm_platform_link_get_master (int slave);
|
||||
gboolean nm_platform_master_set_option (int ifindex, const char *option, const char *value);
|
||||
char *nm_platform_master_get_option (int ifindex, const char *option);
|
||||
gboolean nm_platform_slave_set_option (int ifindex, const char *option, const char *value);
|
||||
char *nm_platform_slave_get_option (int ifindex, const char *option);
|
||||
gboolean nm_platform_link_enslave (NMPlatform *self, int master, int slave);
|
||||
gboolean nm_platform_link_release (NMPlatform *self, int master, int slave);
|
||||
int nm_platform_link_get_master (NMPlatform *self, 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_vlan_add (const char *name, int parent, int vlanid, guint32 vlanflags);
|
||||
gboolean nm_platform_vlan_get_info (int ifindex, int *parent, int *vlanid);
|
||||
gboolean nm_platform_vlan_set_ingress_map (int ifindex, int from, int to);
|
||||
gboolean nm_platform_vlan_set_egress_map (int ifindex, int from, int to);
|
||||
gboolean nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags);
|
||||
gboolean nm_platform_vlan_get_info (NMPlatform *self, int ifindex, int *parent, int *vlanid);
|
||||
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);
|
||||
|
||||
gboolean nm_platform_infiniband_partition_add (int parent, int p_key);
|
||||
gboolean nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key);
|
||||
|
||||
gboolean nm_platform_veth_get_properties (int ifindex, NMPlatformVethProperties *properties);
|
||||
gboolean nm_platform_tun_get_properties (int ifindex, NMPlatformTunProperties *properties);
|
||||
gboolean nm_platform_macvlan_get_properties (int ifindex, NMPlatformMacvlanProperties *props);
|
||||
gboolean nm_platform_vxlan_get_properties (int ifindex, NMPlatformVxlanProperties *props);
|
||||
gboolean nm_platform_gre_get_properties (int ifindex, NMPlatformGreProperties *props);
|
||||
gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, NMPlatformVethProperties *properties);
|
||||
gboolean nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties);
|
||||
gboolean nm_platform_macvlan_get_properties (NMPlatform *self, int ifindex, NMPlatformMacvlanProperties *props);
|
||||
gboolean nm_platform_vxlan_get_properties (NMPlatform *self, int ifindex, NMPlatformVxlanProperties *props);
|
||||
gboolean nm_platform_gre_get_properties (NMPlatform *self, int ifindex, NMPlatformGreProperties *props);
|
||||
|
||||
gboolean nm_platform_wifi_get_capabilities (int ifindex, NMDeviceWifiCapabilities *caps);
|
||||
gboolean nm_platform_wifi_get_bssid (int ifindex, guint8 *bssid);
|
||||
GByteArray *nm_platform_wifi_get_ssid (int ifindex);
|
||||
guint32 nm_platform_wifi_get_frequency (int ifindex);
|
||||
int nm_platform_wifi_get_quality (int ifindex);
|
||||
guint32 nm_platform_wifi_get_rate (int ifindex);
|
||||
NM80211Mode nm_platform_wifi_get_mode (int ifindex);
|
||||
void nm_platform_wifi_set_mode (int ifindex, NM80211Mode mode);
|
||||
guint32 nm_platform_wifi_find_frequency (int ifindex, const guint32 *freqs);
|
||||
void nm_platform_wifi_indicate_addressing_running (int ifindex, gboolean running);
|
||||
gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps);
|
||||
gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid);
|
||||
GByteArray *nm_platform_wifi_get_ssid (NMPlatform *self, int ifindex);
|
||||
guint32 nm_platform_wifi_get_frequency (NMPlatform *self, int ifindex);
|
||||
int nm_platform_wifi_get_quality (NMPlatform *self, int ifindex);
|
||||
guint32 nm_platform_wifi_get_rate (NMPlatform *self, int ifindex);
|
||||
NM80211Mode nm_platform_wifi_get_mode (NMPlatform *self, int ifindex);
|
||||
void nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM80211Mode mode);
|
||||
guint32 nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs);
|
||||
void nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running);
|
||||
|
||||
guint32 nm_platform_mesh_get_channel (int ifindex);
|
||||
gboolean nm_platform_mesh_set_channel (int ifindex, guint32 channel);
|
||||
gboolean nm_platform_mesh_set_ssid (int ifindex, const guint8 *ssid, gsize len);
|
||||
guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel);
|
||||
gboolean nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len);
|
||||
|
||||
GArray *nm_platform_ip4_address_get_all (int ifindex);
|
||||
GArray *nm_platform_ip6_address_get_all (int ifindex);
|
||||
gboolean nm_platform_ip4_address_add (int ifindex,
|
||||
GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex);
|
||||
GArray *nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_ip4_address_add (NMPlatform *self, int ifindex,
|
||||
in_addr_t address, in_addr_t peer_address, int plen,
|
||||
guint32 lifetime, guint32 preferred_lft,
|
||||
const char *label);
|
||||
gboolean nm_platform_ip6_address_add (int ifindex,
|
||||
gboolean nm_platform_ip6_address_add (NMPlatform *self, int ifindex,
|
||||
struct in6_addr address, struct in6_addr peer_address, int plen,
|
||||
guint32 lifetime, guint32 preferred_lft, guint flags);
|
||||
gboolean nm_platform_ip4_address_delete (int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
|
||||
gboolean nm_platform_ip6_address_delete (int ifindex, struct in6_addr address, int plen);
|
||||
gboolean nm_platform_ip4_address_exists (int ifindex, in_addr_t address, int plen);
|
||||
gboolean nm_platform_ip6_address_exists (int ifindex, struct in6_addr address, int plen);
|
||||
gboolean nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint32 device_route_metric);
|
||||
gboolean nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses, gboolean keep_link_local);
|
||||
gboolean nm_platform_address_flush (int ifindex);
|
||||
gboolean nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
|
||||
gboolean nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
|
||||
gboolean nm_platform_ip4_address_exists (NMPlatform *self, int ifindex, in_addr_t address, int plen);
|
||||
gboolean nm_platform_ip6_address_exists (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
|
||||
gboolean nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, guint32 device_route_metric);
|
||||
gboolean nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, gboolean keep_link_local);
|
||||
gboolean nm_platform_address_flush (NMPlatform *self, int ifindex);
|
||||
|
||||
gboolean nm_platform_ip4_check_reinstall_device_route (int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric);
|
||||
gboolean nm_platform_ip4_check_reinstall_device_route (NMPlatform *self, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric);
|
||||
|
||||
GArray *nm_platform_ip4_route_get_all (int ifindex, NMPlatformGetRouteMode mode);
|
||||
GArray *nm_platform_ip6_route_get_all (int ifindex, NMPlatformGetRouteMode mode);
|
||||
gboolean nm_platform_ip4_route_add (int ifindex, NMIPConfigSource source,
|
||||
GArray *nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
|
||||
GArray *nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
|
||||
gboolean nm_platform_ip4_route_add (NMPlatform *self, int ifindex, NMIPConfigSource source,
|
||||
in_addr_t network, int plen, in_addr_t gateway,
|
||||
guint32 pref_src, guint32 metric, guint32 mss);
|
||||
gboolean nm_platform_ip6_route_add (int ifindex, NMIPConfigSource source,
|
||||
gboolean nm_platform_ip6_route_add (NMPlatform *self, int ifindex, NMIPConfigSource source,
|
||||
struct in6_addr network, int plen, struct in6_addr gateway,
|
||||
guint32 metric, guint32 mss);
|
||||
gboolean nm_platform_ip4_route_delete (int ifindex, in_addr_t network, int plen, guint32 metric);
|
||||
gboolean nm_platform_ip6_route_delete (int ifindex, struct in6_addr network, int plen, guint32 metric);
|
||||
gboolean nm_platform_ip4_route_exists (int ifindex, in_addr_t network, int plen, guint32 metric);
|
||||
gboolean nm_platform_ip6_route_exists (int ifindex, struct in6_addr network, int plen, guint32 metric);
|
||||
gboolean nm_platform_ip4_route_sync (int ifindex, const GArray *known_routes);
|
||||
gboolean nm_platform_ip6_route_sync (int ifindex, const GArray *known_routes);
|
||||
gboolean nm_platform_route_flush (int ifindex);
|
||||
gboolean nm_platform_ip4_route_delete (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric);
|
||||
gboolean nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric);
|
||||
gboolean nm_platform_ip4_route_exists (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric);
|
||||
gboolean nm_platform_ip6_route_exists (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric);
|
||||
gboolean nm_platform_ip4_route_sync (NMPlatform *self, int ifindex, const GArray *known_routes);
|
||||
gboolean nm_platform_ip6_route_sync (NMPlatform *self, int ifindex, const GArray *known_routes);
|
||||
gboolean nm_platform_route_flush (NMPlatform *self, int ifindex);
|
||||
|
||||
const char *nm_platform_link_to_string (const NMPlatformLink *link);
|
||||
const char *nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address);
|
||||
|
|
@ -633,8 +637,8 @@ int nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4R
|
|||
int nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b);
|
||||
|
||||
gboolean nm_platform_check_support_libnl_extended_ifa_flags (void);
|
||||
gboolean nm_platform_check_support_kernel_extended_ifa_flags (void);
|
||||
gboolean nm_platform_check_support_user_ipv6ll (void);
|
||||
gboolean nm_platform_check_support_kernel_extended_ifa_flags (NMPlatform *self);
|
||||
gboolean nm_platform_check_support_user_ipv6ll (NMPlatform *self);
|
||||
|
||||
void nm_platform_addr_flags2str (int flags, char *buf, size_t size);
|
||||
|
||||
|
|
|
|||
|
|
@ -44,21 +44,21 @@ dump_interface (NMPlatformLink *link)
|
|||
if (link->driver)
|
||||
printf (" driver: %s\n", link->driver);
|
||||
printf (" UDI: %s\n", link->udi);
|
||||
if (!nm_platform_vlan_get_info (link->ifindex, &vlan_parent, &vlan_id))
|
||||
if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, link->ifindex, &vlan_parent, &vlan_id))
|
||||
g_assert_not_reached ();
|
||||
if (vlan_parent)
|
||||
printf (" vlan parent %d id %d\n", vlan_parent, vlan_id);
|
||||
|
||||
if (nm_platform_link_is_software (link->ifindex))
|
||||
if (nm_platform_link_is_software (NM_PLATFORM_GET, link->ifindex))
|
||||
printf (" class software\n");
|
||||
if (nm_platform_link_supports_slaves (link->ifindex))
|
||||
if (nm_platform_link_supports_slaves (NM_PLATFORM_GET, link->ifindex))
|
||||
printf (" class supports-slaves\n");
|
||||
if (nm_platform_link_supports_carrier_detect (link->ifindex))
|
||||
if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, link->ifindex))
|
||||
printf (" feature carrier-detect\n");
|
||||
if (nm_platform_link_supports_vlans (link->ifindex))
|
||||
if (nm_platform_link_supports_vlans (NM_PLATFORM_GET, link->ifindex))
|
||||
printf (" feature vlans\n");
|
||||
|
||||
address = nm_platform_link_get_address (link->ifindex, &addrlen);
|
||||
address = nm_platform_link_get_address (NM_PLATFORM_GET, link->ifindex, &addrlen);
|
||||
if (address) {
|
||||
printf (" link-address ");
|
||||
for (i = 0; i < addrlen; i++)
|
||||
|
|
@ -66,8 +66,8 @@ dump_interface (NMPlatformLink *link)
|
|||
printf ("\n");
|
||||
}
|
||||
|
||||
ip4_addresses = nm_platform_ip4_address_get_all (link->ifindex);
|
||||
ip6_addresses = nm_platform_ip6_address_get_all (link->ifindex);
|
||||
ip4_addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, link->ifindex);
|
||||
ip6_addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, link->ifindex);
|
||||
|
||||
g_assert (ip4_addresses);
|
||||
g_assert (ip6_addresses);
|
||||
|
|
@ -85,8 +85,8 @@ dump_interface (NMPlatformLink *link)
|
|||
g_array_unref (ip4_addresses);
|
||||
g_array_unref (ip6_addresses);
|
||||
|
||||
ip4_routes = nm_platform_ip4_route_get_all (link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
ip6_routes = nm_platform_ip6_route_get_all (link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
ip4_routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
ip6_routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
|
||||
g_assert (ip4_routes);
|
||||
g_assert (ip6_routes);
|
||||
|
|
@ -112,7 +112,7 @@ dump_interface (NMPlatformLink *link)
|
|||
static void
|
||||
dump_all (void)
|
||||
{
|
||||
GArray *links = nm_platform_link_get_all ();
|
||||
GArray *links = nm_platform_link_get_all (NM_PLATFORM_GET);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < links->len; i++)
|
||||
|
|
|
|||
|
|
@ -44,13 +44,13 @@ typedef const char *string_t;
|
|||
static gboolean
|
||||
do_sysctl_set (char **argv)
|
||||
{
|
||||
return nm_platform_sysctl_set (argv[0], argv[1]);
|
||||
return nm_platform_sysctl_set (NM_PLATFORM_GET, argv[0], argv[1]);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
do_sysctl_get (char **argv)
|
||||
{
|
||||
gs_free char *value = nm_platform_sysctl_get (argv[0]);
|
||||
gs_free char *value = nm_platform_sysctl_get (NM_PLATFORM_GET, argv[0]);
|
||||
|
||||
printf ("%s\n", value);
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ parse_ifindex (const char *str)
|
|||
ifindex = strtol (str, &endptr, 10);
|
||||
|
||||
if (*endptr) {
|
||||
ifindex = nm_platform_link_get_ifindex (str);
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, str);
|
||||
}
|
||||
|
||||
return ifindex;
|
||||
|
|
@ -79,7 +79,7 @@ do_link_get_all (char **argv)
|
|||
NMPlatformLink *device;
|
||||
int i;
|
||||
|
||||
links = nm_platform_link_get_all ();
|
||||
links = nm_platform_link_get_all (NM_PLATFORM_GET);
|
||||
for (i = 0; i < links->len; i++) {
|
||||
device = &g_array_index (links, NMPlatformLink, i);
|
||||
|
||||
|
|
@ -93,25 +93,25 @@ do_link_get_all (char **argv)
|
|||
static gboolean
|
||||
do_dummy_add (char **argv)
|
||||
{
|
||||
return nm_platform_dummy_add (argv[0]);
|
||||
return nm_platform_dummy_add (NM_PLATFORM_GET, argv[0]);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
do_bridge_add (char **argv)
|
||||
{
|
||||
return nm_platform_bridge_add (argv[0], NULL, 0);
|
||||
return nm_platform_bridge_add (NM_PLATFORM_GET, argv[0], NULL, 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
do_bond_add (char **argv)
|
||||
{
|
||||
return nm_platform_bond_add (argv[0]);
|
||||
return nm_platform_bond_add (NM_PLATFORM_GET, argv[0]);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
do_team_add (char **argv)
|
||||
{
|
||||
return nm_platform_team_add (argv[0]);
|
||||
return nm_platform_team_add (NM_PLATFORM_GET, argv[0]);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -122,13 +122,13 @@ do_vlan_add (char **argv)
|
|||
int vlanid = strtol (*argv++, NULL, 10);
|
||||
guint32 vlan_flags = strtol (*argv++, NULL, 10);
|
||||
|
||||
return nm_platform_vlan_add (name, parent, vlanid, vlan_flags);
|
||||
return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent, vlanid, vlan_flags);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
do_link_exists (char **argv)
|
||||
{
|
||||
gboolean value = nm_platform_link_exists (argv[0]);
|
||||
gboolean value = nm_platform_link_exists (NM_PLATFORM_GET, argv[0]);
|
||||
|
||||
print_boolean (value);
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ do_link_exists (char **argv)
|
|||
do_link_##cmdname (char **argv) \
|
||||
{ \
|
||||
int ifindex = parse_ifindex (argv[0]); \
|
||||
return ifindex ? nm_platform_link_##cmdname (ifindex) : FALSE; \
|
||||
return ifindex ? nm_platform_link_##cmdname (NM_PLATFORM_GET, ifindex) : FALSE; \
|
||||
}
|
||||
|
||||
#define LINK_CMD_GET_FULL(cmdname, type, cond) \
|
||||
|
|
@ -149,7 +149,7 @@ do_link_exists (char **argv)
|
|||
{ \
|
||||
int ifindex = parse_ifindex (argv[0]); \
|
||||
if (ifindex) { \
|
||||
type##_t value = nm_platform_link_##cmdname (ifindex); \
|
||||
type##_t value = nm_platform_link_##cmdname (NM_PLATFORM_GET, ifindex); \
|
||||
if (cond) { \
|
||||
print_##type (value); \
|
||||
return TRUE; \
|
||||
|
|
@ -169,7 +169,7 @@ LINK_CMD (delete)
|
|||
static gboolean
|
||||
do_link_get_ifindex (char **argv)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (argv[0]);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, argv[0]);
|
||||
|
||||
if (ifindex)
|
||||
printf ("%d\n", ifindex);
|
||||
|
|
@ -213,7 +213,7 @@ do_link_set_address (char **argv)
|
|||
g_assert (!*endptr);
|
||||
}
|
||||
|
||||
return nm_platform_link_set_address (ifindex, address, sizeof (address));
|
||||
return nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, address, sizeof (address));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -224,7 +224,7 @@ do_link_get_address (char **argv)
|
|||
size_t length;
|
||||
int i;
|
||||
|
||||
address = nm_platform_link_get_address (ifindex, &length);
|
||||
address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &length);
|
||||
|
||||
if (!address || length <= 0)
|
||||
return FALSE;
|
||||
|
|
@ -242,7 +242,7 @@ do_link_set_mtu (char **argv)
|
|||
int ifindex = parse_ifindex (*argv++);
|
||||
int mtu = strtoul (*argv++, NULL, 10);
|
||||
|
||||
return nm_platform_link_set_mtu (ifindex, mtu);
|
||||
return nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, mtu);
|
||||
}
|
||||
|
||||
LINK_CMD_GET (get_mtu, decimal);
|
||||
|
|
@ -255,7 +255,7 @@ do_link_enslave (char **argv)
|
|||
int master = parse_ifindex (*argv++);
|
||||
int slave = parse_ifindex (*argv++);
|
||||
|
||||
return nm_platform_link_enslave (master, slave);
|
||||
return nm_platform_link_enslave (NM_PLATFORM_GET, master, slave);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -264,7 +264,7 @@ do_link_release (char **argv)
|
|||
int master = parse_ifindex (*argv++);
|
||||
int slave = parse_ifindex (*argv++);
|
||||
|
||||
return nm_platform_link_release (master, slave);
|
||||
return nm_platform_link_release (NM_PLATFORM_GET, master, slave);
|
||||
}
|
||||
|
||||
LINK_CMD_GET (get_master, decimal)
|
||||
|
|
@ -276,7 +276,7 @@ do_master_set_option (char **argv)
|
|||
const char *option = *argv++;
|
||||
const char *value = *argv++;
|
||||
|
||||
return nm_platform_master_set_option (ifindex, option, value);
|
||||
return nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, option, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -284,7 +284,7 @@ do_master_get_option (char **argv)
|
|||
{
|
||||
int ifindex = parse_ifindex (*argv++);
|
||||
const char *option = *argv++;
|
||||
gs_free char *value = nm_platform_master_get_option (ifindex, option);
|
||||
gs_free char *value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, option);
|
||||
|
||||
printf ("%s\n", value);
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ do_slave_set_option (char **argv)
|
|||
const char *option = *argv++;
|
||||
const char *value = *argv++;
|
||||
|
||||
return nm_platform_slave_set_option (ifindex, option, value);
|
||||
return nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, option, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -306,7 +306,7 @@ do_slave_get_option (char **argv)
|
|||
{
|
||||
int ifindex = parse_ifindex (*argv++);
|
||||
const char *option = *argv++;
|
||||
gs_free char *value = nm_platform_slave_get_option (ifindex, option);
|
||||
gs_free char *value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, option);
|
||||
|
||||
printf ("%s\n", value);
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ do_vlan_get_info (char **argv)
|
|||
int parent;
|
||||
int vlanid;
|
||||
|
||||
if (!nm_platform_vlan_get_info (ifindex, &parent, &vlanid))
|
||||
if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent, &vlanid))
|
||||
return FALSE;
|
||||
|
||||
printf ("%d %d\n", parent, vlanid);
|
||||
|
|
@ -335,7 +335,7 @@ do_vlan_set_ingress_map (char **argv)
|
|||
int from = strtol (*argv++, NULL, 10);
|
||||
int to = strtol (*argv++, NULL, 10);
|
||||
|
||||
return nm_platform_vlan_set_ingress_map (ifindex, from, to);
|
||||
return nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, from, to);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -345,7 +345,7 @@ do_vlan_set_egress_map (char **argv)
|
|||
int from = strtol (*argv++, NULL, 10);
|
||||
int to = strtol (*argv++, NULL, 10);
|
||||
|
||||
return nm_platform_vlan_set_egress_map (ifindex, from, to);
|
||||
return nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, from, to);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -354,7 +354,7 @@ do_veth_get_properties (char **argv)
|
|||
int ifindex = parse_ifindex (*argv++);
|
||||
NMPlatformVethProperties props;
|
||||
|
||||
if (!nm_platform_veth_get_properties (ifindex, &props))
|
||||
if (!nm_platform_veth_get_properties (NM_PLATFORM_GET, ifindex, &props))
|
||||
return FALSE;
|
||||
|
||||
printf ("peer: %d\n", props.peer);
|
||||
|
|
@ -368,7 +368,7 @@ do_tun_get_properties (char **argv)
|
|||
int ifindex = parse_ifindex (*argv++);
|
||||
NMPlatformTunProperties props;
|
||||
|
||||
if (!nm_platform_tun_get_properties (ifindex, &props))
|
||||
if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, ifindex, &props))
|
||||
return FALSE;
|
||||
|
||||
printf ("mode: %s\n", props.mode);
|
||||
|
|
@ -396,7 +396,7 @@ do_macvlan_get_properties (char **argv)
|
|||
int ifindex = parse_ifindex (*argv++);
|
||||
NMPlatformMacvlanProperties props;
|
||||
|
||||
if (!nm_platform_macvlan_get_properties (ifindex, &props))
|
||||
if (!nm_platform_macvlan_get_properties (NM_PLATFORM_GET, ifindex, &props))
|
||||
return FALSE;
|
||||
|
||||
printf ("parent: %d\n", props.parent_ifindex);
|
||||
|
|
@ -413,7 +413,7 @@ do_vxlan_get_properties (char **argv)
|
|||
NMPlatformVxlanProperties props;
|
||||
char addrstr[INET6_ADDRSTRLEN];
|
||||
|
||||
if (!nm_platform_vxlan_get_properties (ifindex, &props))
|
||||
if (!nm_platform_vxlan_get_properties (NM_PLATFORM_GET, ifindex, &props))
|
||||
return FALSE;
|
||||
|
||||
printf ("parent-ifindex: %u\n", props.parent_ifindex);
|
||||
|
|
@ -460,7 +460,7 @@ do_gre_get_properties (char **argv)
|
|||
NMPlatformGreProperties props;
|
||||
char addrstr[INET_ADDRSTRLEN];
|
||||
|
||||
if (!nm_platform_gre_get_properties (ifindex, &props))
|
||||
if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, ifindex, &props))
|
||||
return FALSE;
|
||||
|
||||
printf ("parent-ifindex: %u\n", props.parent_ifindex);
|
||||
|
|
@ -496,7 +496,7 @@ do_ip4_address_get_all (char **argv)
|
|||
int i;
|
||||
|
||||
if (ifindex) {
|
||||
addresses = nm_platform_ip4_address_get_all (ifindex);
|
||||
addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
for (i = 0; i < addresses->len; i++) {
|
||||
address = &g_array_index (addresses, NMPlatformIP4Address, i);
|
||||
inet_ntop (AF_INET, &address->address, addrstr, sizeof (addrstr));
|
||||
|
|
@ -518,7 +518,7 @@ do_ip6_address_get_all (char **argv)
|
|||
int i;
|
||||
|
||||
if (ifindex) {
|
||||
addresses = nm_platform_ip6_address_get_all (ifindex);
|
||||
addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
for (i = 0; i < addresses->len; i++) {
|
||||
address = &g_array_index (addresses, NMPlatformIP6Address, i);
|
||||
inet_ntop (AF_INET6, &address->address, addrstr, sizeof (addrstr));
|
||||
|
|
@ -576,7 +576,7 @@ do_ip4_address_add (char **argv)
|
|||
guint32 lifetime = strtol (*argv++, NULL, 10);
|
||||
guint32 preferred = strtol (*argv++, NULL, 10);
|
||||
|
||||
gboolean value = nm_platform_ip4_address_add (ifindex, address, 0, plen, lifetime, preferred, NULL);
|
||||
gboolean value = nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, address, 0, plen, lifetime, preferred, NULL);
|
||||
return value;
|
||||
} else
|
||||
return FALSE;
|
||||
|
|
@ -594,7 +594,7 @@ do_ip6_address_add (char **argv)
|
|||
guint32 preferred = strtol (*argv++, NULL, 10);
|
||||
guint flags = (*argv) ? rtnl_addr_str2flags (*argv++) : 0;
|
||||
|
||||
gboolean value = nm_platform_ip6_address_add (ifindex, address, in6addr_any, plen, lifetime, preferred, flags);
|
||||
gboolean value = nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, address, in6addr_any, plen, lifetime, preferred, flags);
|
||||
return value;
|
||||
} else
|
||||
return FALSE;
|
||||
|
|
@ -608,7 +608,7 @@ do_ip6_address_add (char **argv)
|
|||
v##_t address; \
|
||||
int plen; \
|
||||
if (ifindex && parse_##v##_address (*argv++, &address, &plen)) { \
|
||||
gboolean value = nm_platform_##v##_address_##cmdname (ifindex, address, plen, ##__VA_ARGS__); \
|
||||
gboolean value = nm_platform_##v##_address_##cmdname (NM_PLATFORM_GET, ifindex, address, plen, ##__VA_ARGS__); \
|
||||
if (print) { \
|
||||
print_boolean (value); \
|
||||
return TRUE; \
|
||||
|
|
@ -633,7 +633,7 @@ do_ip4_route_get_all (char **argv)
|
|||
int i;
|
||||
|
||||
if (ifindex) {
|
||||
routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
for (i = 0; i < routes->len; i++) {
|
||||
route = &g_array_index (routes, NMPlatformIP4Route, i);
|
||||
inet_ntop (AF_INET, &route->network, networkstr, sizeof (networkstr));
|
||||
|
|
@ -657,7 +657,7 @@ do_ip6_route_get_all (char **argv)
|
|||
int i;
|
||||
|
||||
if (ifindex) {
|
||||
routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
for (i = 0; i < routes->len; i++) {
|
||||
route = &g_array_index (routes, NMPlatformIP6Route, i);
|
||||
inet_ntop (AF_INET6, &route->network, networkstr, sizeof (networkstr));
|
||||
|
|
@ -683,7 +683,7 @@ do_ip4_route_add (char **argv)
|
|||
metric = strtol (*argv++, NULL, 10);
|
||||
mss = strtol (*argv++, NULL, 10);
|
||||
|
||||
return nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER,
|
||||
return nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER,
|
||||
network, plen, gateway, 0,
|
||||
metric, mss);
|
||||
}
|
||||
|
|
@ -699,7 +699,7 @@ do_ip6_route_add (char **argv)
|
|||
parse_ip6_address (*argv++, &gateway, NULL);
|
||||
metric = strtol (*argv++, NULL, 10);
|
||||
mss = strtol (*argv++, NULL, 10);
|
||||
return nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER,
|
||||
return nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER,
|
||||
network, plen, gateway,
|
||||
metric, mss);
|
||||
}
|
||||
|
|
@ -714,7 +714,7 @@ do_ip4_route_delete (char **argv)
|
|||
parse_ip4_address (*argv++, &network, &plen);
|
||||
metric = strtol (*argv++, NULL, 10);
|
||||
|
||||
return nm_platform_ip4_route_delete (ifindex, network, plen, metric);
|
||||
return nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -727,7 +727,7 @@ do_ip6_route_delete (char **argv)
|
|||
parse_ip6_address (*argv++, &network, &plen);
|
||||
metric = strtol (*argv++, NULL, 10);
|
||||
|
||||
return nm_platform_ip6_route_delete (ifindex, network, plen, metric);
|
||||
return nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -740,7 +740,7 @@ do_ip4_route_exists (char **argv)
|
|||
parse_ip4_address (*argv++, &network, &plen);
|
||||
metric = strtol (*argv++, NULL, 10);
|
||||
|
||||
print_boolean (nm_platform_ip4_route_exists (ifindex, network, plen, metric));
|
||||
print_boolean (nm_platform_ip4_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -754,7 +754,7 @@ do_ip6_route_exists (char **argv)
|
|||
parse_ip6_address (*argv++, &network, &plen);
|
||||
metric = strtol (*argv++, NULL, 10);
|
||||
|
||||
print_boolean (nm_platform_ip6_route_exists (ifindex, network, plen, metric));
|
||||
print_boolean (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -892,9 +892,9 @@ main (int argc, char **argv)
|
|||
error ("\n");
|
||||
}
|
||||
|
||||
error = nm_platform_get_error ();
|
||||
error = nm_platform_get_error (NM_PLATFORM_GET);
|
||||
if (error) {
|
||||
const char *msg = nm_platform_get_error_msg ();
|
||||
const char *msg = nm_platform_get_error_msg (NM_PLATFORM_GET);
|
||||
|
||||
error ("nm-platform: %s\n", msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ ip6_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Address *r
|
|||
static void
|
||||
test_ip4_address (void)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
SignalData *address_added = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback, ifindex);
|
||||
SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_address_callback, ifindex);
|
||||
SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback, ifindex);
|
||||
|
|
@ -64,21 +64,21 @@ test_ip4_address (void)
|
|||
inet_pton (AF_INET, IP4_ADDRESS, &addr);
|
||||
|
||||
/* Add address */
|
||||
g_assert (!nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
|
||||
g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip4_address_add (ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
|
||||
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
|
||||
g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
|
||||
no_error ();
|
||||
accept_signal (address_added);
|
||||
|
||||
/* Add address again (aka update) */
|
||||
g_assert (nm_platform_ip4_address_add (ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
|
||||
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
|
||||
no_error ();
|
||||
accept_signal (address_changed);
|
||||
|
||||
/* Test address listing */
|
||||
addresses = nm_platform_ip4_address_get_all (ifindex);
|
||||
addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
g_assert (addresses);
|
||||
no_error ();
|
||||
g_assert_cmpint (addresses->len, ==, 1);
|
||||
|
|
@ -89,13 +89,13 @@ test_ip4_address (void)
|
|||
g_array_unref (addresses);
|
||||
|
||||
/* Remove address */
|
||||
g_assert (nm_platform_ip4_address_delete (ifindex, addr, IP4_PLEN, 0));
|
||||
g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0));
|
||||
no_error ();
|
||||
g_assert (!nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
|
||||
g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
|
||||
accept_signal (address_removed);
|
||||
|
||||
/* Remove address again */
|
||||
g_assert (nm_platform_ip4_address_delete (ifindex, addr, IP4_PLEN, 0));
|
||||
g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0));
|
||||
no_error ();
|
||||
|
||||
free_signal (address_added);
|
||||
|
|
@ -106,7 +106,7 @@ test_ip4_address (void)
|
|||
static void
|
||||
test_ip6_address (void)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
SignalData *address_added = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback, ifindex);
|
||||
SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_address_callback, ifindex);
|
||||
SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback, ifindex);
|
||||
|
|
@ -120,21 +120,21 @@ test_ip6_address (void)
|
|||
inet_pton (AF_INET6, IP6_ADDRESS, &addr);
|
||||
|
||||
/* Add address */
|
||||
g_assert (!nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
|
||||
g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip6_address_add (ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
|
||||
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
|
||||
g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
no_error ();
|
||||
accept_signal (address_added);
|
||||
|
||||
/* Add address again (aka update) */
|
||||
g_assert (nm_platform_ip6_address_add (ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
|
||||
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
|
||||
no_error ();
|
||||
accept_signal (address_changed);
|
||||
|
||||
/* Test address listing */
|
||||
addresses = nm_platform_ip6_address_get_all (ifindex);
|
||||
addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
g_assert (addresses);
|
||||
no_error ();
|
||||
g_assert_cmpint (addresses->len, ==, 1);
|
||||
|
|
@ -145,13 +145,13 @@ test_ip6_address (void)
|
|||
g_array_unref (addresses);
|
||||
|
||||
/* Remove address */
|
||||
g_assert (nm_platform_ip6_address_delete (ifindex, addr, IP6_PLEN));
|
||||
g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
no_error ();
|
||||
g_assert (!nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
|
||||
g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
accept_signal (address_removed);
|
||||
|
||||
/* Remove address again */
|
||||
g_assert (nm_platform_ip6_address_delete (ifindex, addr, IP6_PLEN));
|
||||
g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
no_error ();
|
||||
|
||||
free_signal (address_added);
|
||||
|
|
@ -164,7 +164,7 @@ test_ip4_address_external (void)
|
|||
{
|
||||
SignalData *address_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback);
|
||||
SignalData *address_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback);
|
||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
in_addr_t addr;
|
||||
guint32 lifetime = 2000;
|
||||
guint32 preferred = 1000;
|
||||
|
|
@ -175,28 +175,28 @@ test_ip4_address_external (void)
|
|||
/* Looks like addresses are not announced by kerenl when the interface
|
||||
* is down. Link-local IPv6 address is automatically added.
|
||||
*/
|
||||
g_assert (nm_platform_link_set_up (nm_platform_link_get_ifindex (DEVICE_NAME)));
|
||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
|
||||
|
||||
/* Add/delete notification */
|
||||
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
|
||||
IP4_ADDRESS, IP4_PLEN, DEVICE_NAME, lifetime, preferred);
|
||||
wait_signal (address_added);
|
||||
g_assert (nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
|
||||
g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
|
||||
run_command ("ip address delete %s/%d dev %s", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME);
|
||||
wait_signal (address_removed);
|
||||
g_assert (!nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
|
||||
g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
|
||||
|
||||
/* Add/delete conflict */
|
||||
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
|
||||
IP4_ADDRESS, IP4_PLEN, DEVICE_NAME, lifetime, preferred);
|
||||
g_assert (nm_platform_ip4_address_add (ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
|
||||
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
|
||||
g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
|
||||
accept_signal (address_added);
|
||||
/*run_command ("ip address delete %s/%d dev %s", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME);
|
||||
g_assert (nm_platform_ip4_address_delete (ifindex, addr, IP4_PLEN, 0));
|
||||
no_error ();
|
||||
g_assert (!nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
|
||||
g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
|
||||
accept_signal (address_removed);*/
|
||||
|
||||
free_signal (address_added);
|
||||
|
|
@ -208,7 +208,7 @@ test_ip6_address_external (void)
|
|||
{
|
||||
SignalData *address_added = add_signal (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback);
|
||||
SignalData *address_removed = add_signal (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback);
|
||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
struct in6_addr addr;
|
||||
guint32 lifetime = 2000;
|
||||
guint32 preferred = 1000;
|
||||
|
|
@ -220,22 +220,22 @@ test_ip6_address_external (void)
|
|||
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
|
||||
IP6_ADDRESS, IP6_PLEN, DEVICE_NAME, lifetime, preferred);
|
||||
wait_signal (address_added);
|
||||
g_assert (nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
|
||||
g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
run_command ("ip address delete %s/%d dev %s", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME);
|
||||
wait_signal (address_removed);
|
||||
g_assert (!nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
|
||||
g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
|
||||
/* Add/delete conflict */
|
||||
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
|
||||
IP6_ADDRESS, IP6_PLEN, DEVICE_NAME, lifetime, preferred);
|
||||
g_assert (nm_platform_ip6_address_add (ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
|
||||
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
|
||||
g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
accept_signal (address_added);
|
||||
/*run_command ("ip address delete %s/%d dev %s", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME);
|
||||
g_assert (nm_platform_ip6_address_delete (ifindex, addr, IP6_PLEN));
|
||||
g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
no_error ();
|
||||
g_assert (!nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
|
||||
g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
|
||||
wait_signal (address_removed);*/
|
||||
|
||||
free_signal (address_added);
|
||||
|
|
@ -253,9 +253,9 @@ setup_tests (void)
|
|||
{
|
||||
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
|
||||
|
||||
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
||||
g_assert (nm_platform_dummy_add (DEVICE_NAME));
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
wait_signal (link_added);
|
||||
free_signal (link_added);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,27 +35,27 @@ 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 (DEVICE_NAME));
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
wait_signal (link_added);
|
||||
free_signal (link_added);
|
||||
g_assert (nm_platform_link_set_up (nm_platform_link_get_ifindex (DEVICE_NAME)));
|
||||
ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
g_assert (ifindex > 0);
|
||||
|
||||
/* Add routes and addresses */
|
||||
g_assert (nm_platform_ip4_address_add (ifindex, addr4, 0, plen4, lifetime, preferred, NULL));
|
||||
g_assert (nm_platform_ip6_address_add (ifindex, addr6, in6addr_any, plen6, lifetime, preferred, flags));
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway4, 0, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway6, 128, in6addr_any, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network6, plen6, gateway6, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway6, metric, mss));
|
||||
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr4, 0, plen4, lifetime, preferred, NULL));
|
||||
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr6, in6addr_any, plen6, lifetime, preferred, flags));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway4, 0, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway6, 128, in6addr_any, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network6, plen6, gateway6, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway6, metric, mss));
|
||||
|
||||
addresses4 = nm_platform_ip4_address_get_all (ifindex);
|
||||
addresses6 = nm_platform_ip6_address_get_all (ifindex);
|
||||
routes4 = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
routes6 = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
|
||||
g_assert_cmpint (addresses4->len, ==, 1);
|
||||
g_assert_cmpint (addresses6->len, ==, 1);
|
||||
|
|
@ -68,12 +68,12 @@ test_cleanup_internal (void)
|
|||
g_array_unref (routes6);
|
||||
|
||||
/* Delete interface with all addresses and routes */
|
||||
g_assert (nm_platform_link_delete (ifindex));
|
||||
g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
|
||||
|
||||
addresses4 = nm_platform_ip4_address_get_all (ifindex);
|
||||
addresses6 = nm_platform_ip6_address_get_all (ifindex);
|
||||
routes4 = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
routes6 = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||
routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
|
||||
g_assert_cmpint (addresses4->len, ==, 0);
|
||||
g_assert_cmpint (addresses6->len, ==, 0);
|
||||
|
|
@ -95,8 +95,8 @@ init_tests (int *argc, char ***argv)
|
|||
void
|
||||
setup_tests (void)
|
||||
{
|
||||
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
|
||||
g_test_add_func ("/internal", test_cleanup_internal);
|
||||
/* FIXME: add external cleanup check */
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl
|
|||
|
||||
if (data->ifindex && data->ifindex != received->ifindex)
|
||||
return;
|
||||
if (data->ifname && g_strcmp0 (data->ifname, nm_platform_link_get_name (ifindex)) != 0)
|
||||
if (data->ifname && g_strcmp0 (data->ifname, nm_platform_link_get_name (NM_PLATFORM_GET, ifindex)) != 0)
|
||||
return;
|
||||
if (change_type != data->change_type)
|
||||
return;
|
||||
|
|
@ -127,13 +127,13 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl
|
|||
debug ("Received signal '%s-%s' ifindex %d ifname '%s' %dth time.", data->name, _change_type_to_string (data->change_type), ifindex, received->name, data->received_count);
|
||||
|
||||
if (change_type == NM_PLATFORM_SIGNAL_REMOVED)
|
||||
g_assert (!nm_platform_link_get_name (ifindex));
|
||||
g_assert (!nm_platform_link_get_name (NM_PLATFORM_GET, ifindex));
|
||||
else
|
||||
g_assert (nm_platform_link_get_name (ifindex));
|
||||
g_assert (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex));
|
||||
|
||||
/* Check the data */
|
||||
g_assert (received->ifindex > 0);
|
||||
links = nm_platform_link_get_all ();
|
||||
links = nm_platform_link_get_all (NM_PLATFORM_GET);
|
||||
for (i = 0; i < links->len; i++) {
|
||||
cached = &g_array_index (links, NMPlatformLink, i);
|
||||
if (cached->ifindex == received->ifindex) {
|
||||
|
|
@ -247,9 +247,9 @@ _assert_ip4_route_exists (const char *file, guint line, const char *func, gboole
|
|||
exists ? "doesn't" : "does");
|
||||
}
|
||||
|
||||
ifindex = nm_platform_link_get_ifindex (ifname);
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname);
|
||||
g_assert (ifindex > 0);
|
||||
if (!nm_platform_ip4_route_exists (ifindex, network, plen, metric) != !exists) {
|
||||
if (!nm_platform_ip4_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric) != !exists) {
|
||||
g_error ("[%s:%u] %s(): The ip4 route %s/%d metric %u %s, but platform thinks %s",
|
||||
file, line, func,
|
||||
nm_utils_inet4_ntop (network, NULL), plen, metric,
|
||||
|
|
@ -302,7 +302,7 @@ main (int argc, char **argv)
|
|||
|
||||
result = g_test_run ();
|
||||
|
||||
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
|
||||
nm_platform_free ();
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__)
|
||||
|
||||
#define error(err) g_assert (nm_platform_get_error () == err)
|
||||
#define error(err) g_assert (nm_platform_get_error (NM_PLATFORM_GET) == err)
|
||||
#define no_error() error (NM_PLATFORM_ERROR_NONE)
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -21,68 +21,68 @@ test_bogus(void)
|
|||
{
|
||||
size_t addrlen;
|
||||
|
||||
g_assert (!nm_platform_link_exists (BOGUS_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, BOGUS_NAME));
|
||||
no_error ();
|
||||
g_assert (!nm_platform_link_delete (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_get_ifindex (BOGUS_NAME));
|
||||
g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, BOGUS_NAME));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_get_name (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_get_name (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_get_type (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_get_type (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_get_type_name (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_get_type_name (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
|
||||
g_assert (!nm_platform_link_set_up (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_set_up (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_set_down (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_set_down (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_set_arp (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_set_arp (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_set_noarp (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_set_noarp (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_is_up (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_is_connected (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_uses_arp (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
|
||||
g_assert (!nm_platform_link_get_address (BOGUS_IFINDEX, &addrlen));
|
||||
g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, &addrlen));
|
||||
g_assert (!addrlen);
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_get_address (BOGUS_IFINDEX, NULL));
|
||||
g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_set_mtu (BOGUS_IFINDEX, MTU));
|
||||
g_assert (!nm_platform_link_set_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX, MTU));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_get_mtu (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_get_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
|
||||
g_assert (!nm_platform_link_supports_carrier_detect (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_supports_vlans (BOGUS_IFINDEX));
|
||||
g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
|
||||
g_assert (!nm_platform_vlan_get_info (BOGUS_IFINDEX, NULL, NULL));
|
||||
g_assert (!nm_platform_vlan_get_info (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL, NULL));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_vlan_set_ingress_map (BOGUS_IFINDEX, 0, 0));
|
||||
g_assert (!nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_vlan_set_egress_map (BOGUS_IFINDEX, 0, 0));
|
||||
g_assert (!nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
}
|
||||
|
||||
static void
|
||||
test_loopback (void)
|
||||
{
|
||||
g_assert (nm_platform_link_exists (LO_NAME));
|
||||
g_assert_cmpint (nm_platform_link_get_type (LO_INDEX), ==, NM_LINK_TYPE_LOOPBACK);
|
||||
g_assert_cmpint (nm_platform_link_get_ifindex (LO_NAME), ==, LO_INDEX);
|
||||
g_assert_cmpstr (nm_platform_link_get_name (LO_INDEX), ==, LO_NAME);
|
||||
g_assert_cmpstr (nm_platform_link_get_type_name (LO_INDEX), ==, LO_TYPEDESC);
|
||||
g_assert (nm_platform_link_exists (NM_PLATFORM_GET, LO_NAME));
|
||||
g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, LO_INDEX), ==, NM_LINK_TYPE_LOOPBACK);
|
||||
g_assert_cmpint (nm_platform_link_get_ifindex (NM_PLATFORM_GET, LO_NAME), ==, LO_INDEX);
|
||||
g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, LO_INDEX), ==, LO_NAME);
|
||||
g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, LO_INDEX), ==, LO_TYPEDESC);
|
||||
|
||||
g_assert (nm_platform_link_supports_carrier_detect (LO_INDEX));
|
||||
g_assert (!nm_platform_link_supports_vlans (LO_INDEX));
|
||||
g_assert (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, LO_INDEX));
|
||||
g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, LO_INDEX));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -90,43 +90,43 @@ software_add (NMLinkType link_type, const char *name)
|
|||
{
|
||||
switch (link_type) {
|
||||
case NM_LINK_TYPE_DUMMY:
|
||||
return nm_platform_dummy_add (name);
|
||||
return nm_platform_dummy_add (NM_PLATFORM_GET, name);
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
return nm_platform_bridge_add (name, NULL, 0);
|
||||
return nm_platform_bridge_add (NM_PLATFORM_GET, name, NULL, 0);
|
||||
case NM_LINK_TYPE_BOND:
|
||||
{
|
||||
gboolean bond0_exists = nm_platform_link_exists ("bond0");
|
||||
gboolean result = nm_platform_bond_add (name);
|
||||
NMPlatformError error = nm_platform_get_error ();
|
||||
gboolean bond0_exists = nm_platform_link_exists (NM_PLATFORM_GET, "bond0");
|
||||
gboolean result = nm_platform_bond_add (NM_PLATFORM_GET, name);
|
||||
NMPlatformError error = nm_platform_get_error (NM_PLATFORM_GET);
|
||||
|
||||
/* Check that bond0 is *not* automatically created. */
|
||||
if (!bond0_exists)
|
||||
g_assert (!nm_platform_link_exists ("bond0"));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "bond0"));
|
||||
|
||||
nm_platform_set_error (error);
|
||||
nm_platform_set_error (NM_PLATFORM_GET, error);
|
||||
return result;
|
||||
}
|
||||
case NM_LINK_TYPE_TEAM:
|
||||
return nm_platform_team_add (name);
|
||||
return nm_platform_team_add (NM_PLATFORM_GET, name);
|
||||
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 (PARENT_NAME, NULL, 0))
|
||||
if (nm_platform_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0))
|
||||
wait_signal (parent_added);
|
||||
free_signal (parent_added);
|
||||
|
||||
{
|
||||
int parent_ifindex = nm_platform_link_get_ifindex (PARENT_NAME);
|
||||
int parent_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME);
|
||||
|
||||
parent_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, parent_ifindex);
|
||||
g_assert (nm_platform_link_set_up (parent_ifindex));
|
||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, parent_ifindex));
|
||||
accept_signal (parent_changed);
|
||||
free_signal (parent_changed);
|
||||
|
||||
return nm_platform_vlan_add (name, parent_ifindex, VLAN_ID, 0);
|
||||
return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0);
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
|
@ -144,7 +144,7 @@ test_slave (int master, int type, SignalData *master_changed)
|
|||
char *value;
|
||||
|
||||
g_assert (software_add (type, SLAVE_NAME));
|
||||
ifindex = nm_platform_link_get_ifindex (SLAVE_NAME);
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, SLAVE_NAME);
|
||||
g_assert (ifindex > 0);
|
||||
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
|
||||
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
|
||||
|
|
@ -154,19 +154,19 @@ test_slave (int master, int type, SignalData *master_changed)
|
|||
*
|
||||
* See https://bugzilla.redhat.com/show_bug.cgi?id=910348
|
||||
*/
|
||||
g_assert (nm_platform_link_set_down (ifindex));
|
||||
g_assert (!nm_platform_link_is_up (ifindex));
|
||||
g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
|
||||
accept_signal (link_changed);
|
||||
|
||||
/* Enslave */
|
||||
link_changed->ifindex = ifindex;
|
||||
g_assert (nm_platform_link_enslave (master, ifindex)); no_error ();
|
||||
g_assert_cmpint (nm_platform_link_get_master (ifindex), ==, master); no_error ();
|
||||
g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error ();
|
||||
g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, master); no_error ();
|
||||
accept_signal (link_changed);
|
||||
accept_signal (master_changed);
|
||||
|
||||
/* Set master up */
|
||||
g_assert (nm_platform_link_set_up (master));
|
||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, master));
|
||||
accept_signal (master_changed);
|
||||
|
||||
/* Master with a disconnected slave is disconnected
|
||||
|
|
@ -174,26 +174,26 @@ test_slave (int master, int type, SignalData *master_changed)
|
|||
* For some reason, bonding and teaming slaves are automatically set up. We
|
||||
* need to set them back down for this test.
|
||||
*/
|
||||
switch (nm_platform_link_get_type (master)) {
|
||||
switch (nm_platform_link_get_type (NM_PLATFORM_GET, master)) {
|
||||
case NM_LINK_TYPE_BOND:
|
||||
case NM_LINK_TYPE_TEAM:
|
||||
g_assert (nm_platform_link_set_down (ifindex));
|
||||
g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex));
|
||||
accept_signal (link_changed);
|
||||
accept_signal (master_changed);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
g_assert (!nm_platform_link_is_up (ifindex));
|
||||
g_assert (!nm_platform_link_is_connected (ifindex));
|
||||
if (nm_platform_link_is_connected (master)) {
|
||||
if (nm_platform_link_get_type (master) == NM_LINK_TYPE_TEAM) {
|
||||
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
|
||||
if (nm_platform_link_is_connected (NM_PLATFORM_GET, master)) {
|
||||
if (nm_platform_link_get_type (NM_PLATFORM_GET, master) == NM_LINK_TYPE_TEAM) {
|
||||
/* Older team versions (e.g. Fedora 17) have a bug that team master stays
|
||||
* IFF_LOWER_UP even if its slave is down. Double check it with iproute2 and if
|
||||
* `ip link` also claims master to be up, accept it. */
|
||||
char *stdout_str = NULL;
|
||||
|
||||
nmtst_spawn_sync (NULL, &stdout_str, NULL, 0, "/sbin/ip", "link", "show", "dev", nm_platform_link_get_name (master));
|
||||
nmtst_spawn_sync (NULL, &stdout_str, NULL, 0, "/sbin/ip", "link", "show", "dev", nm_platform_link_get_name (NM_PLATFORM_GET, master));
|
||||
|
||||
g_assert (strstr (stdout_str, "LOWER_UP"));
|
||||
g_free (stdout_str);
|
||||
|
|
@ -202,9 +202,9 @@ test_slave (int master, int type, SignalData *master_changed)
|
|||
}
|
||||
|
||||
/* Set slave up and see if master gets up too */
|
||||
g_assert (nm_platform_link_set_up (ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_is_connected (ifindex));
|
||||
g_assert (nm_platform_link_is_connected (master));
|
||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, master));
|
||||
accept_signal (link_changed);
|
||||
accept_signal (master_changed);
|
||||
|
||||
|
|
@ -212,16 +212,16 @@ test_slave (int master, int type, SignalData *master_changed)
|
|||
*
|
||||
* Gracefully succeed if already enslaved.
|
||||
*/
|
||||
g_assert (nm_platform_link_enslave (master, ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error ();
|
||||
accept_signal (link_changed);
|
||||
accept_signal (master_changed);
|
||||
|
||||
/* Set slave option */
|
||||
switch (type) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
g_assert (nm_platform_slave_set_option (ifindex, "priority", "789"));
|
||||
g_assert (nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, "priority", "789"));
|
||||
no_error ();
|
||||
value = nm_platform_slave_get_option (ifindex, "priority");
|
||||
value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, "priority");
|
||||
no_error ();
|
||||
g_assert_cmpstr (value, ==, "789");
|
||||
g_free (value);
|
||||
|
|
@ -231,17 +231,17 @@ test_slave (int master, int type, SignalData *master_changed)
|
|||
}
|
||||
|
||||
/* Release */
|
||||
g_assert (nm_platform_link_release (master, ifindex));
|
||||
g_assert_cmpint (nm_platform_link_get_master (ifindex), ==, 0); no_error ();
|
||||
g_assert (nm_platform_link_release (NM_PLATFORM_GET, master, ifindex));
|
||||
g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0); no_error ();
|
||||
accept_signal (link_changed);
|
||||
accept_signal (master_changed);
|
||||
|
||||
/* Release again */
|
||||
g_assert (!nm_platform_link_release (master, ifindex));
|
||||
g_assert (!nm_platform_link_release (NM_PLATFORM_GET, master, ifindex));
|
||||
error (NM_PLATFORM_ERROR_NOT_SLAVE);
|
||||
|
||||
/* Remove */
|
||||
g_assert (nm_platform_link_delete (ifindex));
|
||||
g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
|
||||
no_error ();
|
||||
accept_signal (link_removed);
|
||||
|
||||
|
|
@ -264,16 +264,16 @@ test_software (NMLinkType link_type, const char *link_typename)
|
|||
g_assert (software_add (link_type, DEVICE_NAME));
|
||||
no_error ();
|
||||
wait_signal (link_added);
|
||||
g_assert (nm_platform_link_exists (DEVICE_NAME));
|
||||
ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
g_assert (ifindex >= 0);
|
||||
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, link_type);
|
||||
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, link_typename);
|
||||
g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, link_type);
|
||||
g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, link_typename);
|
||||
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
|
||||
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
|
||||
if (link_type == NM_LINK_TYPE_VLAN) {
|
||||
g_assert (nm_platform_vlan_get_info (ifindex, &vlan_parent, &vlan_id));
|
||||
g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (PARENT_NAME));
|
||||
g_assert (nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &vlan_parent, &vlan_id));
|
||||
g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME));
|
||||
g_assert_cmpint (vlan_id, ==, VLAN_ID);
|
||||
no_error ();
|
||||
}
|
||||
|
|
@ -283,28 +283,28 @@ test_software (NMLinkType link_type, const char *link_typename)
|
|||
error (NM_PLATFORM_ERROR_EXISTS);
|
||||
|
||||
/* Set ARP/NOARP */
|
||||
g_assert (nm_platform_link_uses_arp (ifindex));
|
||||
g_assert (nm_platform_link_set_noarp (ifindex));
|
||||
g_assert (!nm_platform_link_uses_arp (ifindex));
|
||||
g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (nm_platform_link_set_noarp (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
|
||||
accept_signal (link_changed);
|
||||
g_assert (nm_platform_link_set_arp (ifindex));
|
||||
g_assert (nm_platform_link_uses_arp (ifindex));
|
||||
g_assert (nm_platform_link_set_arp (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
|
||||
accept_signal (link_changed);
|
||||
|
||||
/* Set master option */
|
||||
switch (link_type) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
g_assert (nm_platform_master_set_option (ifindex, "forward_delay", "789"));
|
||||
g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "789"));
|
||||
no_error ();
|
||||
value = nm_platform_master_get_option (ifindex, "forward_delay");
|
||||
value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay");
|
||||
no_error ();
|
||||
g_assert_cmpstr (value, ==, "789");
|
||||
g_free (value);
|
||||
break;
|
||||
case NM_LINK_TYPE_BOND:
|
||||
g_assert (nm_platform_master_set_option (ifindex, "mode", "active-backup"));
|
||||
g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup"));
|
||||
no_error ();
|
||||
value = nm_platform_master_get_option (ifindex, "mode");
|
||||
value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "mode");
|
||||
no_error ();
|
||||
/* When reading back, the output looks slightly different. */
|
||||
g_assert (g_str_has_prefix (value, "active-backup"));
|
||||
|
|
@ -328,24 +328,24 @@ test_software (NMLinkType link_type, const char *link_typename)
|
|||
}
|
||||
|
||||
/* Delete */
|
||||
g_assert (nm_platform_link_delete (ifindex));
|
||||
g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
|
||||
no_error ();
|
||||
g_assert (!nm_platform_link_exists (DEVICE_NAME)); no_error ();
|
||||
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_NONE);
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error ();
|
||||
g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_NONE);
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
g_assert (!nm_platform_link_get_type (ifindex));
|
||||
g_assert (!nm_platform_link_get_type (NM_PLATFORM_GET, ifindex));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
accept_signal (link_removed);
|
||||
|
||||
/* Delete again */
|
||||
g_assert (!nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME)));
|
||||
g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
|
||||
/* VLAN: Delete parent */
|
||||
if (link_type == NM_LINK_TYPE_VLAN) {
|
||||
SignalData *link_removed_parent = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, vlan_parent);
|
||||
|
||||
g_assert (nm_platform_link_delete (vlan_parent));
|
||||
g_assert (nm_platform_link_delete (NM_PLATFORM_GET, vlan_parent));
|
||||
accept_signal (link_removed_parent);
|
||||
free_signal (link_removed_parent);
|
||||
}
|
||||
|
|
@ -398,75 +398,75 @@ test_internal (void)
|
|||
int ifindex;
|
||||
|
||||
/* Check the functions for non-existent devices */
|
||||
g_assert (!nm_platform_link_exists (DEVICE_NAME)); no_error ();
|
||||
g_assert (!nm_platform_link_get_ifindex (DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error ();
|
||||
g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
|
||||
/* Add device */
|
||||
g_assert (nm_platform_dummy_add (DEVICE_NAME));
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
no_error ();
|
||||
wait_signal (link_added);
|
||||
|
||||
/* Try to add again */
|
||||
g_assert (!nm_platform_dummy_add (DEVICE_NAME));
|
||||
g_assert (!nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
error (NM_PLATFORM_ERROR_EXISTS);
|
||||
|
||||
/* Check device index, name and type */
|
||||
ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
g_assert (ifindex > 0);
|
||||
g_assert_cmpstr (nm_platform_link_get_name (ifindex), ==, DEVICE_NAME);
|
||||
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_DUMMY);
|
||||
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, DUMMY_TYPEDESC);
|
||||
g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex), ==, DEVICE_NAME);
|
||||
g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_DUMMY);
|
||||
g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, DUMMY_TYPEDESC);
|
||||
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
|
||||
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
|
||||
|
||||
/* Up/connected */
|
||||
g_assert (!nm_platform_link_is_up (ifindex)); no_error ();
|
||||
g_assert (!nm_platform_link_is_connected (ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_set_up (ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_is_up (ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_is_connected (ifindex)); no_error ();
|
||||
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
accept_signal (link_changed);
|
||||
g_assert (nm_platform_link_set_down (ifindex)); no_error ();
|
||||
g_assert (!nm_platform_link_is_up (ifindex)); no_error ();
|
||||
g_assert (!nm_platform_link_is_connected (ifindex)); no_error ();
|
||||
g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
|
||||
accept_signal (link_changed);
|
||||
|
||||
/* arp/noarp */
|
||||
g_assert (!nm_platform_link_uses_arp (ifindex));
|
||||
g_assert (nm_platform_link_set_arp (ifindex));
|
||||
g_assert (nm_platform_link_uses_arp (ifindex));
|
||||
g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (nm_platform_link_set_arp (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
|
||||
accept_signal (link_changed);
|
||||
g_assert (nm_platform_link_set_noarp (ifindex));
|
||||
g_assert (!nm_platform_link_uses_arp (ifindex));
|
||||
g_assert (nm_platform_link_set_noarp (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
|
||||
accept_signal (link_changed);
|
||||
|
||||
/* Features */
|
||||
g_assert (!nm_platform_link_supports_carrier_detect (ifindex));
|
||||
g_assert (nm_platform_link_supports_vlans (ifindex));
|
||||
g_assert (!nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (nm_platform_link_supports_vlans (NM_PLATFORM_GET, ifindex));
|
||||
|
||||
/* Set MAC address */
|
||||
g_assert (nm_platform_link_set_address (ifindex, mac, sizeof (mac)));
|
||||
address = nm_platform_link_get_address (ifindex, &addrlen);
|
||||
g_assert (nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, mac, sizeof (mac)));
|
||||
address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addrlen);
|
||||
g_assert (addrlen == sizeof(mac));
|
||||
g_assert (!memcmp (address, mac, addrlen));
|
||||
address = nm_platform_link_get_address (ifindex, NULL);
|
||||
address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, NULL);
|
||||
g_assert (!memcmp (address, mac, addrlen));
|
||||
accept_signal (link_changed);
|
||||
|
||||
/* Set MTU */
|
||||
g_assert (nm_platform_link_set_mtu (ifindex, MTU));
|
||||
g_assert (nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, MTU));
|
||||
no_error ();
|
||||
g_assert_cmpint (nm_platform_link_get_mtu (ifindex), ==, MTU);
|
||||
g_assert_cmpint (nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex), ==, MTU);
|
||||
accept_signal (link_changed);
|
||||
|
||||
/* Delete device */
|
||||
g_assert (nm_platform_link_delete (ifindex));
|
||||
g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
|
||||
no_error ();
|
||||
accept_signal (link_removed);
|
||||
|
||||
/* Try to delete again */
|
||||
g_assert (!nm_platform_link_delete (ifindex));
|
||||
g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
|
||||
error (NM_PLATFORM_ERROR_NOT_FOUND);
|
||||
|
||||
free_signal (link_added);
|
||||
|
|
@ -485,16 +485,16 @@ test_external (void)
|
|||
|
||||
run_command ("ip link add %s type %s", DEVICE_NAME, "dummy");
|
||||
wait_signal (link_added);
|
||||
g_assert (nm_platform_link_exists (DEVICE_NAME));
|
||||
ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
g_assert (ifindex > 0);
|
||||
g_assert_cmpstr (nm_platform_link_get_name (ifindex), ==, DEVICE_NAME);
|
||||
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_DUMMY);
|
||||
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, DUMMY_TYPEDESC);
|
||||
g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex), ==, DEVICE_NAME);
|
||||
g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_DUMMY);
|
||||
g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, DUMMY_TYPEDESC);
|
||||
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
|
||||
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
|
||||
|
||||
success = nm_platform_link_get (ifindex, &link);
|
||||
success = nm_platform_link_get (NM_PLATFORM_GET, ifindex, &link);
|
||||
g_assert (success);
|
||||
if (!link.driver) {
|
||||
/* we still lack the notification via UDEV. Expect another link changed signal. */
|
||||
|
|
@ -502,17 +502,17 @@ test_external (void)
|
|||
}
|
||||
|
||||
/* Up/connected/arp */
|
||||
g_assert (!nm_platform_link_is_up (ifindex));
|
||||
g_assert (!nm_platform_link_is_connected (ifindex));
|
||||
g_assert (!nm_platform_link_uses_arp (ifindex));
|
||||
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
|
||||
run_command ("ip link set %s up", DEVICE_NAME);
|
||||
wait_signal (link_changed);
|
||||
g_assert (nm_platform_link_is_up (ifindex));
|
||||
g_assert (nm_platform_link_is_connected (ifindex));
|
||||
g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
|
||||
run_command ("ip link set %s down", DEVICE_NAME);
|
||||
wait_signal (link_changed);
|
||||
g_assert (!nm_platform_link_is_up (ifindex));
|
||||
g_assert (!nm_platform_link_is_connected (ifindex));
|
||||
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
|
||||
g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
|
||||
/* This test doesn't trigger a netlink event at least on
|
||||
* 3.8.2-206.fc18.x86_64. Disabling the waiting and checking code
|
||||
* because of that.
|
||||
|
|
@ -530,7 +530,7 @@ test_external (void)
|
|||
|
||||
run_command ("ip link del %s", DEVICE_NAME);
|
||||
wait_signal (link_removed);
|
||||
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
|
||||
free_signal (link_added);
|
||||
free_signal (link_changed);
|
||||
|
|
@ -546,12 +546,12 @@ init_tests (int *argc, char ***argv)
|
|||
void
|
||||
setup_tests (void)
|
||||
{
|
||||
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
||||
nm_platform_link_delete (nm_platform_link_get_ifindex (SLAVE_NAME));
|
||||
nm_platform_link_delete (nm_platform_link_get_ifindex (PARENT_NAME));
|
||||
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (SLAVE_NAME));
|
||||
g_assert (!nm_platform_link_exists (PARENT_NAME));
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, SLAVE_NAME));
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, SLAVE_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, PARENT_NAME));
|
||||
|
||||
g_test_add_func ("/link/bogus", test_bogus);
|
||||
g_test_add_func ("/link/loopback", test_loopback);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ ip6_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Route *recei
|
|||
static void
|
||||
test_ip4_route_metric0 (void)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback);
|
||||
SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback);
|
||||
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback);
|
||||
|
|
@ -63,7 +63,7 @@ test_ip4_route_metric0 (void)
|
|||
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
|
||||
|
||||
/* add the first route */
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, metric, mss));
|
||||
no_error ();
|
||||
accept_signal (route_added);
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ test_ip4_route_metric0 (void)
|
|||
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
|
||||
|
||||
/* Deleting route with metric 0 does nothing */
|
||||
g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, 0));
|
||||
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
|
||||
no_error ();
|
||||
ensure_no_signal (route_removed);
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ test_ip4_route_metric0 (void)
|
|||
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
|
||||
|
||||
/* add the second route */
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, 0, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, 0, mss));
|
||||
no_error ();
|
||||
accept_signal (route_added);
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ test_ip4_route_metric0 (void)
|
|||
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
|
||||
|
||||
/* Delete route with metric 0 */
|
||||
g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, 0));
|
||||
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
|
||||
no_error ();
|
||||
accept_signal (route_removed);
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ test_ip4_route_metric0 (void)
|
|||
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
|
||||
|
||||
/* Delete route with metric 0 again (we expect nothing to happen) */
|
||||
g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, 0));
|
||||
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
|
||||
no_error ();
|
||||
ensure_no_signal (route_removed);
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ test_ip4_route_metric0 (void)
|
|||
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
|
||||
|
||||
/* Delete the other route */
|
||||
g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, metric));
|
||||
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
no_error ();
|
||||
accept_signal (route_removed);
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ test_ip4_route_metric0 (void)
|
|||
static void
|
||||
test_ip4_route (void)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback);
|
||||
SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback);
|
||||
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback);
|
||||
|
|
@ -135,40 +135,40 @@ test_ip4_route (void)
|
|||
inet_pton (AF_INET, "198.51.100.1", &gateway);
|
||||
|
||||
/* Add route to gateway */
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 32, INADDR_ANY, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 32, INADDR_ANY, 0, metric, mss));
|
||||
no_error ();
|
||||
accept_signal (route_added);
|
||||
|
||||
/* Add route */
|
||||
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
|
||||
no_error ();
|
||||
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
|
||||
no_error ();
|
||||
accept_signal (route_added);
|
||||
|
||||
/* Add route again */
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
|
||||
no_error ();
|
||||
accept_signal (route_changed);
|
||||
|
||||
/* Add default route */
|
||||
assert_ip4_route_exists (FALSE, DEVICE_NAME, 0, 0, metric);
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
|
||||
no_error ();
|
||||
assert_ip4_route_exists (TRUE, DEVICE_NAME, 0, 0, metric);
|
||||
no_error ();
|
||||
accept_signal (route_added);
|
||||
|
||||
/* Add default route again */
|
||||
g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
|
||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
|
||||
no_error ();
|
||||
accept_signal (route_changed);
|
||||
|
||||
/* Test route listing */
|
||||
routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
memset (rts, 0, sizeof (rts));
|
||||
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
|
||||
rts[0].network = gateway;
|
||||
|
|
@ -197,13 +197,13 @@ test_ip4_route (void)
|
|||
g_array_unref (routes);
|
||||
|
||||
/* Remove route */
|
||||
g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, metric));
|
||||
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
no_error ();
|
||||
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
|
||||
accept_signal (route_removed);
|
||||
|
||||
/* Remove route again */
|
||||
g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, metric));
|
||||
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
no_error ();
|
||||
|
||||
free_signal (route_added);
|
||||
|
|
@ -214,7 +214,7 @@ test_ip4_route (void)
|
|||
static void
|
||||
test_ip6_route (void)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_route_callback);
|
||||
SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_route_callback);
|
||||
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_route_callback);
|
||||
|
|
@ -231,40 +231,40 @@ test_ip6_route (void)
|
|||
inet_pton (AF_INET6, "2001:db8:c:d:1:2:3:4", &gateway);
|
||||
|
||||
/* Add route to gateway */
|
||||
g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, metric, mss));
|
||||
no_error ();
|
||||
accept_signal (route_added);
|
||||
|
||||
/* Add route */
|
||||
g_assert (!nm_platform_ip6_route_exists (ifindex, network, plen, metric));
|
||||
g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip6_route_exists (ifindex, network, plen, metric));
|
||||
g_assert (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
no_error ();
|
||||
accept_signal (route_added);
|
||||
|
||||
/* Add route again */
|
||||
g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
|
||||
no_error ();
|
||||
accept_signal (route_changed);
|
||||
|
||||
/* Add default route */
|
||||
g_assert (!nm_platform_ip6_route_exists (ifindex, in6addr_any, 0, metric));
|
||||
g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
|
||||
no_error ();
|
||||
g_assert (nm_platform_ip6_route_exists (ifindex, in6addr_any, 0, metric));
|
||||
g_assert (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric));
|
||||
no_error ();
|
||||
accept_signal (route_added);
|
||||
|
||||
/* Add default route again */
|
||||
g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
|
||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
|
||||
no_error ();
|
||||
accept_signal (route_changed);
|
||||
|
||||
/* Test route listing */
|
||||
routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
||||
memset (rts, 0, sizeof (rts));
|
||||
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
|
||||
rts[0].network = gateway;
|
||||
|
|
@ -293,13 +293,13 @@ test_ip6_route (void)
|
|||
g_array_unref (routes);
|
||||
|
||||
/* Remove route */
|
||||
g_assert (nm_platform_ip6_route_delete (ifindex, network, plen, metric));
|
||||
g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
no_error ();
|
||||
g_assert (!nm_platform_ip6_route_exists (ifindex, network, plen, metric));
|
||||
g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
accept_signal (route_removed);
|
||||
|
||||
/* Remove route again */
|
||||
g_assert (nm_platform_ip6_route_delete (ifindex, network, plen, metric));
|
||||
g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
|
||||
no_error ();
|
||||
|
||||
free_signal (route_added);
|
||||
|
|
@ -318,13 +318,13 @@ setup_tests (void)
|
|||
{
|
||||
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
|
||||
|
||||
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
||||
g_assert (nm_platform_dummy_add (DEVICE_NAME));
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
|
||||
wait_signal (link_added);
|
||||
free_signal (link_added);
|
||||
|
||||
g_assert (nm_platform_link_set_up (nm_platform_link_get_ifindex (DEVICE_NAME)));
|
||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
|
||||
|
||||
g_test_add_func ("/route/ip4", test_ip4_route);
|
||||
g_test_add_func ("/route/ip6", test_ip6_route);
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ start (NMRDisc *rdisc)
|
|||
static inline gint32
|
||||
ipv6_sysctl_get (const char *ifname, const char *property, gint32 defval)
|
||||
{
|
||||
return nm_platform_sysctl_get_int32 (nm_utils_ip6_property_path (ifname, property), defval);
|
||||
return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, nm_utils_ip6_property_path (ifname, property), defval);
|
||||
}
|
||||
|
||||
NMRDisc *
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ rdisc_new (void)
|
|||
{
|
||||
NMRDisc *rdisc;
|
||||
const int ifindex = 1;
|
||||
const char *ifname = nm_platform_link_get_name (ifindex);
|
||||
const char *ifname = nm_platform_link_get_name (NM_PLATFORM_GET, ifindex);
|
||||
|
||||
rdisc = nm_fake_rdisc_new (ifindex, ifname);
|
||||
g_assert (rdisc);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ main (int argc, char **argv)
|
|||
|
||||
if (argv[1]) {
|
||||
ifname = argv[1];
|
||||
ifindex = nm_platform_link_get_ifindex (ifname);
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname);
|
||||
} else {
|
||||
g_print ("Missing command line argument \"interface-name\"\n");
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
|
|||
if (!devtimeout)
|
||||
return;
|
||||
|
||||
if (nm_platform_link_get_ifindex (ifname) != 0)
|
||||
if (nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname) != 0)
|
||||
return;
|
||||
|
||||
/* ONBOOT=yes, DEVICE and DEVTIMEOUT are set, but device is not present */
|
||||
|
|
|
|||
|
|
@ -4335,11 +4335,11 @@ is_wifi_device (const char *name, shvarFile *parsed)
|
|||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
g_return_val_if_fail (parsed != NULL, FALSE);
|
||||
|
||||
ifindex = nm_platform_link_get_ifindex (name);
|
||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, name);
|
||||
if (ifindex == 0)
|
||||
return FALSE;
|
||||
|
||||
return nm_platform_link_get_type (ifindex) == NM_LINK_TYPE_WIFI;
|
||||
return nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) == NM_LINK_TYPE_WIFI;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -174,9 +174,9 @@ init_block_by_line (gchar * buf)
|
|||
/* ignored connection */
|
||||
conn = add_new_connection_config ("ignore", pos);
|
||||
} else {
|
||||
int ifindex = nm_platform_link_get_ifindex (pos);
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, pos);
|
||||
|
||||
if (ifindex && nm_platform_link_get_type (ifindex) != NM_LINK_TYPE_WIFI)
|
||||
if (ifindex && nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) != NM_LINK_TYPE_WIFI)
|
||||
/* wired connection */
|
||||
conn = add_new_connection_config ("wired", pos);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -232,9 +232,9 @@ vpn_cleanup (NMVpnConnection *connection, NMDevice *parent_dev)
|
|||
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
if (priv->ip_ifindex) {
|
||||
nm_platform_link_set_down (priv->ip_ifindex);
|
||||
nm_platform_route_flush (priv->ip_ifindex);
|
||||
nm_platform_address_flush (priv->ip_ifindex);
|
||||
nm_platform_link_set_down (NM_PLATFORM_GET, priv->ip_ifindex);
|
||||
nm_platform_route_flush (NM_PLATFORM_GET, priv->ip_ifindex);
|
||||
nm_platform_address_flush (NM_PLATFORM_GET, priv->ip_ifindex);
|
||||
}
|
||||
|
||||
nm_device_set_vpn4_config (parent_dev, NULL);
|
||||
|
|
@ -933,7 +933,7 @@ nm_vpn_connection_apply_config (NMVpnConnection *connection)
|
|||
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
if (priv->ip_ifindex > 0) {
|
||||
nm_platform_link_set_up (priv->ip_ifindex);
|
||||
nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex);
|
||||
|
||||
if (priv->ip4_config) {
|
||||
if (!nm_ip4_config_commit (priv->ip4_config, priv->ip_ifindex,
|
||||
|
|
@ -1027,7 +1027,7 @@ process_generic_config (NMVpnConnection *connection,
|
|||
|
||||
if (priv->ip_iface) {
|
||||
/* Grab the interface index for address/routing operations */
|
||||
priv->ip_ifindex = nm_platform_link_get_ifindex (priv->ip_iface);
|
||||
priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
|
||||
if (!priv->ip_ifindex) {
|
||||
nm_log_err (LOGD_VPN, "(%s): failed to look up VPN interface index", priv->ip_iface);
|
||||
nm_vpn_connection_config_maybe_complete (connection, FALSE);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue