mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 10:08:05 +02:00
merge: branch 'bg/drop-veth-peer-ioctl'
platform: drop ioctl fallback for finding veth's peer https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2354
This commit is contained in:
commit
1a2fec62f0
3 changed files with 3 additions and 46 deletions
|
|
@ -3223,7 +3223,6 @@ gboolean
|
||||||
nm_platform_link_veth_get_properties(NMPlatform *self, int ifindex, int *out_peer_ifindex)
|
nm_platform_link_veth_get_properties(NMPlatform *self, int ifindex, int *out_peer_ifindex)
|
||||||
{
|
{
|
||||||
const NMPlatformLink *plink;
|
const NMPlatformLink *plink;
|
||||||
int peer_ifindex;
|
|
||||||
|
|
||||||
plink = nm_platform_link_get(self, ifindex);
|
plink = nm_platform_link_get(self, ifindex);
|
||||||
if (!plink)
|
if (!plink)
|
||||||
|
|
@ -3232,23 +3231,10 @@ nm_platform_link_veth_get_properties(NMPlatform *self, int ifindex, int *out_pee
|
||||||
if (plink->type != NM_LINK_TYPE_VETH)
|
if (plink->type != NM_LINK_TYPE_VETH)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (plink->parent != 0) {
|
if (plink->parent == 0)
|
||||||
NM_SET_OUT(out_peer_ifindex, plink->parent);
|
return FALSE;
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pre-4.1 kernel did not expose the peer_ifindex as IFA_LINK. Lookup via ethtool. */
|
NM_SET_OUT(out_peer_ifindex, plink->parent);
|
||||||
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;
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1190,33 +1190,6 @@ nmp_ethtool_ioctl_supports_vlans(int ifindex)
|
||||||
return !(features->features[block].active & (1 << bit));
|
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
|
gboolean
|
||||||
nmp_ethtool_ioctl_get_wake_on_lan(int ifindex)
|
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);
|
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_get_wake_on_lan(int ifindex);
|
||||||
|
|
||||||
gboolean nmp_ethtool_ioctl_set_wake_on_lan(int ifindex,
|
gboolean nmp_ethtool_ioctl_set_wake_on_lan(int ifindex,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue