platform: refactor nm_platform_veth_get_properties()

For recent kernels, the peer-ifindex of veths is reported as
parent (IFA_LINK). Prefer that over the ethtool lookup.

For one, this avoids the extra ethtool call which has the
downside of sidestepping the platform cache. Also, looking
up the peer-ifindex in ethtool does not report whether the
peer lifes in another netns (NM_PLATFORM_LINK_OTHER_NETNS).

Only use ethtool as fallback for older kernels.
This commit is contained in:
Thomas Haller
2015-10-16 17:53:33 +02:00
parent dd1f4d8947
commit 7cdbc393a0
6 changed files with 28 additions and 60 deletions

View File

@@ -3976,26 +3976,6 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatfor
/******************************************************************/
static gboolean
veth_get_properties (NMPlatform *platform, int ifindex, NMPlatformVethProperties *props)
{
const char *ifname;
int peer_ifindex;
ifname = nm_platform_link_get_name (platform, ifindex);
if (!ifname)
return FALSE;
peer_ifindex = nmp_utils_ethtool_get_peer_ifindex (ifname);
if (peer_ifindex <= 0)
return FALSE;
props->peer = peer_ifindex;
return TRUE;
}
/******************************************************************/
static WifiData *
wifi_get_wifi_data (NMPlatform *platform, int ifindex)
{
@@ -5223,8 +5203,6 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->infiniband_partition_add = infiniband_partition_add;
platform_class->veth_get_properties = veth_get_properties;
platform_class->wifi_get_capabilities = wifi_get_capabilities;
platform_class->wifi_get_bssid = wifi_get_bssid;
platform_class->wifi_get_frequency = wifi_get_frequency;