mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 00:38:07 +02:00
platform: drop nm_platform_link_get_stats()
No need to add accessors for fields of NMPlatformLink. Just access them directly.
This commit is contained in:
parent
178bb25a03
commit
9c5405eba4
4 changed files with 7 additions and 55 deletions
|
|
@ -42,25 +42,20 @@ static gboolean
|
|||
update_stats (gpointer user_data)
|
||||
{
|
||||
NMDeviceStatistics *self = user_data;
|
||||
guint64 rx_packets;
|
||||
guint64 rx_bytes;
|
||||
guint64 tx_packets;
|
||||
guint64 tx_bytes;
|
||||
int ifindex;
|
||||
const NMPlatformLink *pllink;
|
||||
|
||||
ifindex = nm_device_get_ip_ifindex (self->device);
|
||||
|
||||
if (nm_platform_link_get_stats (NM_PLATFORM_GET, ifindex,
|
||||
&rx_packets, &rx_bytes,
|
||||
&tx_packets, &tx_bytes)) {
|
||||
pllink = nm_platform_link_get (NM_PLATFORM_GET, ifindex);
|
||||
if (pllink) {
|
||||
_LOGT ("{RX} %"PRIu64" packets %"PRIu64" bytes {TX} %"PRIu64" packets %"PRIu64" bytes",
|
||||
rx_packets, rx_bytes, tx_packets, tx_bytes);
|
||||
pllink->rx_packets, pllink->rx_bytes, pllink->tx_packets, pllink->tx_bytes);
|
||||
|
||||
nm_device_set_tx_bytes (self->device, tx_bytes);
|
||||
nm_device_set_rx_bytes (self->device, rx_bytes);
|
||||
} else {
|
||||
nm_device_set_tx_bytes (self->device, pllink->tx_bytes);
|
||||
nm_device_set_rx_bytes (self->device, pllink->rx_bytes);
|
||||
} else
|
||||
_LOGE ("error no stats available");
|
||||
}
|
||||
|
||||
/* Keep polling */
|
||||
nm_platform_link_refresh (NM_PLATFORM_GET, ifindex);
|
||||
|
|
|
|||
|
|
@ -4534,27 +4534,6 @@ link_get_dev_id (NMPlatform *platform, int ifindex)
|
|||
return errno ? 0 : (int) int_val;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
link_get_stats (NMPlatform *platform, int ifindex,
|
||||
guint64 *rx_packets, guint64 *rx_bytes,
|
||||
guint64 *tx_packets, guint64 *tx_bytes)
|
||||
{
|
||||
nm_auto_pop_netns NMPNetns *netns = NULL;
|
||||
const NMPObject *obj;
|
||||
|
||||
obj = cache_lookup_link (platform, ifindex);
|
||||
|
||||
if (!obj)
|
||||
return FALSE;
|
||||
|
||||
*rx_packets = obj->link.rx_packets;
|
||||
*rx_bytes = obj->link.rx_bytes;
|
||||
*tx_packets = obj->link.tx_packets;
|
||||
*tx_bytes = obj->link.tx_bytes;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
vlan_add (NMPlatform *platform,
|
||||
const char *name,
|
||||
|
|
@ -6547,7 +6526,6 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||
|
||||
platform_class->link_get_physical_port_id = link_get_physical_port_id;
|
||||
platform_class->link_get_dev_id = link_get_dev_id;
|
||||
platform_class->link_get_stats = link_get_stats;
|
||||
platform_class->link_get_wake_on_lan = link_get_wake_on_lan;
|
||||
platform_class->link_get_driver_info = link_get_driver_info;
|
||||
|
||||
|
|
|
|||
|
|
@ -1265,21 +1265,6 @@ nm_platform_link_get_dev_id (NMPlatform *self, int ifindex)
|
|||
return 0;
|
||||
}
|
||||
|
||||
gboolean nm_platform_link_get_stats (NMPlatform *self, int ifindex,
|
||||
guint64 *rx_packets, guint64 *rx_bytes,
|
||||
guint64 *tx_packets, guint64 *tx_bytes)
|
||||
{
|
||||
_CHECK_SELF (self, klass, 0);
|
||||
|
||||
g_return_val_if_fail (ifindex >= 0, 0);
|
||||
|
||||
if (klass->link_get_stats)
|
||||
return klass->link_get_stats (self, ifindex,
|
||||
rx_packets, rx_bytes,
|
||||
tx_packets, tx_bytes);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_link_get_wake_onlan:
|
||||
* @self: platform instance
|
||||
|
|
|
|||
|
|
@ -538,9 +538,6 @@ typedef struct {
|
|||
|
||||
char * (*link_get_physical_port_id) (NMPlatform *, int ifindex);
|
||||
guint (*link_get_dev_id) (NMPlatform *, int ifindex);
|
||||
gboolean (*link_get_stats) (NMPlatform *platform, int ifindex,
|
||||
guint64 *rx_packets, guint64 *rx_bytes,
|
||||
guint64 *tx_packets, guint64 *tx_bytes);
|
||||
gboolean (*link_get_wake_on_lan) (NMPlatform *, int ifindex);
|
||||
gboolean (*link_get_driver_info) (NMPlatform *,
|
||||
int ifindex,
|
||||
|
|
@ -772,9 +769,6 @@ gboolean nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu);
|
|||
|
||||
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_stats (NMPlatform *self, int ifindex,
|
||||
guint64 *rx_packets, guint64 *rx_bytes,
|
||||
guint64 *tx_packets, guint64 *tx_bytes);
|
||||
gboolean nm_platform_link_get_wake_on_lan (NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_link_get_driver_info (NMPlatform *self,
|
||||
int ifindex,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue