diff --git a/src/add-ons/kernel/network/stack/datalink.cpp b/src/add-ons/kernel/network/stack/datalink.cpp index 9c4d502230..df4fae254c 100644 --- a/src/add-ons/kernel/network/stack/datalink.cpp +++ b/src/add-ons/kernel/network/stack/datalink.cpp @@ -886,9 +886,19 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option, case SIOCGIFSTATS: { // get stats + struct ifreq_stats stats = interface->DeviceInterface()->device->stats; + + struct ifreq_stats deviceStats; + if (protocol->device_module->control(protocol->device, SIOCGIFSTATS, + &deviceStats, sizeof(struct ifreq_stats)) == B_OK) { + stats.receive.dropped += deviceStats.receive.dropped; + stats.receive.errors += deviceStats.receive.errors; + stats.send = deviceStats.send; + stats.collisions += deviceStats.collisions; + } + return user_memcpy(&((struct ifreq*)argument)->ifr_stats, - &interface->DeviceInterface()->device->stats, - sizeof(struct ifreq_stats)); + &stats, sizeof(struct ifreq_stats)); } case SIOCGIFTYPE: diff --git a/src/libs/compat/freebsd_network/device_hooks.c b/src/libs/compat/freebsd_network/device_hooks.c index 4d5915ed72..72d62ac3ab 100644 --- a/src/libs/compat/freebsd_network/device_hooks.c +++ b/src/libs/compat/freebsd_network/device_hooks.c @@ -346,6 +346,24 @@ compat_control(void *cookie, uint32 op, void *arg, size_t length) return B_BAD_ADDRESS; return compat_receive(cookie, (net_buffer**)arg); + case SIOCGIFSTATS: + { + struct ifreq_stats stats; + stats.receive.packets = ifp->if_data.ifi_ipackets; + stats.receive.errors = ifp->if_data.ifi_ierrors; + stats.receive.bytes = ifp->if_data.ifi_ibytes; + stats.receive.multicast_packets = ifp->if_data.ifi_imcasts; + stats.receive.dropped = ifp->if_data.ifi_iqdrops; + stats.send.packets = ifp->if_data.ifi_opackets; + stats.send.errors = ifp->if_data.ifi_oerrors; + stats.send.bytes = ifp->if_data.ifi_obytes; + stats.send.multicast_packets = ifp->if_data.ifi_omcasts; + stats.send.dropped = ifp->if_data.ifi_oqdrops; + stats.collisions = ifp->if_data.ifi_collisions; + memcpy(arg, &stats, sizeof(stats)); + return B_OK; + } + case SIOCSIFFLAGS: case SIOCSIFMEDIA: case SIOCSIFMTU: