mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-26 04:10:34 +01:00
platform: drop ioctl fallback for finding veth's peer
The peer ifindex of a veth interface is available via netlink since kernel 4.1 released in 2015. Drop the code that falls back to ioctl. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1881
This commit is contained in:
parent
871da67916
commit
3482467c25
3 changed files with 3 additions and 46 deletions
|
|
@ -3211,7 +3211,6 @@ gboolean
|
|||
nm_platform_link_veth_get_properties(NMPlatform *self, int ifindex, int *out_peer_ifindex)
|
||||
{
|
||||
const NMPlatformLink *plink;
|
||||
int peer_ifindex;
|
||||
|
||||
plink = nm_platform_link_get(self, ifindex);
|
||||
if (!plink)
|
||||
|
|
@ -3220,23 +3219,10 @@ nm_platform_link_veth_get_properties(NMPlatform *self, int ifindex, int *out_pee
|
|||
if (plink->type != NM_LINK_TYPE_VETH)
|
||||
return FALSE;
|
||||
|
||||
if (plink->parent != 0) {
|
||||
NM_SET_OUT(out_peer_ifindex, plink->parent);
|
||||
return TRUE;
|
||||
}
|
||||
if (plink->parent == 0)
|
||||
return FALSE;
|
||||
|
||||
/* Pre-4.1 kernel did not expose the peer_ifindex as IFA_LINK. Lookup via ethtool. */
|
||||
if (out_peer_ifindex) {
|
||||
nm_auto_pop_netns NMPNetns *netns = NULL;
|
||||
|
||||
if (!nm_platform_netns_push(self, &netns))
|
||||
return FALSE;
|
||||
peer_ifindex = nmp_ethtool_ioctl_get_peer_ifindex(plink->ifindex);
|
||||
if (peer_ifindex <= 0)
|
||||
return FALSE;
|
||||
|
||||
*out_peer_ifindex = peer_ifindex;
|
||||
}
|
||||
NM_SET_OUT(out_peer_ifindex, plink->parent);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1190,33 +1190,6 @@ nmp_ethtool_ioctl_supports_vlans(int ifindex)
|
|||
return !(features->features[block].active & (1 << bit));
|
||||
}
|
||||
|
||||
int
|
||||
nmp_ethtool_ioctl_get_peer_ifindex(int ifindex)
|
||||
{
|
||||
nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex);
|
||||
gsize stats_len;
|
||||
gs_free struct ethtool_stats *stats_free = NULL;
|
||||
struct ethtool_stats *stats;
|
||||
int peer_ifindex_stat;
|
||||
|
||||
g_return_val_if_fail(ifindex > 0, 0);
|
||||
|
||||
peer_ifindex_stat = ethtool_get_stringset_index(&shandle, ETH_SS_STATS, "peer_ifindex");
|
||||
if (peer_ifindex_stat < 0) {
|
||||
nm_log_dbg(LOGD_PLATFORM, "ethtool[%d]: peer_ifindex stat does not exist?", ifindex);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
stats_len = sizeof(*stats) + (peer_ifindex_stat + 1) * sizeof(guint64);
|
||||
stats = nm_malloc0_maybe_a(300, stats_len, &stats_free);
|
||||
stats->cmd = ETHTOOL_GSTATS;
|
||||
stats->n_stats = peer_ifindex_stat + 1;
|
||||
if (_ethtool_call_handle(&shandle, stats, stats_len) < 0)
|
||||
return 0;
|
||||
|
||||
return stats->data[peer_ifindex_stat];
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmp_ethtool_ioctl_get_wake_on_lan(int ifindex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ gboolean nmp_ethtool_ioctl_supports_carrier_detect(int ifindex);
|
|||
|
||||
gboolean nmp_ethtool_ioctl_supports_vlans(int ifindex);
|
||||
|
||||
int nmp_ethtool_ioctl_get_peer_ifindex(int ifindex);
|
||||
|
||||
gboolean nmp_ethtool_ioctl_get_wake_on_lan(int ifindex);
|
||||
|
||||
gboolean nmp_ethtool_ioctl_set_wake_on_lan(int ifindex,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue