20

So one of my clients configured one of their switches and the resulting configuration resulted in a duplex mismatch between the switch and a Linux host.

We have fixed the duplex mismatch, but is there an easy way to clear the error counters on the interface without restarting the system?

eth0      Link encap:Ethernet  HWaddr 00:nn:nn:nn:nn:nn
          inet addr:192.168.97.166  Bcast:192.168.97.167  Mask:255.255.255.252
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:630331763 errors:1 dropped:0 overruns:0 frame:0
          TX packets:676081436 errors:1971815 dropped:0 overruns:68637 carrier:1903180
          collisions:7649984 txqueuelen:1000 
          RX bytes:2067682611 (1.9 GiB)  TX bytes:1942809411 (1.8 GiB)

3 Answers 3

14

this is not intended, or think to be done. You may unload and load again the network driver if it's loaded as a module:

ifconfig ethX down; rmmod ethX; insmod ethX; ifconfig ethX

There will be a network outage anyway, and a risk if you can't get your hand back on it.

You may reset the switch port stats and check for new errors. Or save this current number and compare against them instead of zero

4
  • 1
    +1. Counters are, by their nature, supposed to be compared against their previous value, regardless of what that value was.
    – womble
    Jun 10, 2009 at 22:19
  • Note that the kernel modules are rarely called ethX, if ever. They're called according to the actual hardware, such as ne2k, tulip, or whatever. So the rmmod and insmod commands should be changed according to your NICs.
    – jcoppens
    Sep 13, 2014 at 18:16
  • As said on this AskUbuntu answer you should get the NIC driver, for example with ethtool -i eth0. Also you might be able to just unbind/bind the driver.
    – Pablo A
    Dec 30, 2018 at 3:22
  • the statement about counters is rather blunt and not helpful. also does not reflect industry norms or expectations. not to mention 32bit counters and what those do. for your kind attention, he's i.e. the cumulus linux manuals where they added ethtool -c for resetting counters, because that is a neccessary thing. docs.nvidia.com/networking-ethernet-software/cumulus-linux-37/… Mar 10 at 0:04
6

Have you seen this article?

http://www.ducea.com/2006/09/08/resetting-ifconfig-counters/

It suggests that unloading the network driver module and loading it back will reset the counters, and that if you have the module statically linked in the kernel, there's no other way than to reboot it.

The article offers justification.

2

Resize the ring buffers and the statistics will get reset without downtime.

ethtool -G eth1 rx 511
ethtool -G eth1 rx 4096

(RHEL 6.5)

8
  • Interesting take. Seems not to work for vmxnet and wireless interfaces. Oct 24, 2018 at 10:32
  • 1
    It also doesn't work on Ethernet. ;) (Ubuntu 14.04) Jul 16, 2019 at 13:47
  • It does not work with module i40e RHEL 7.7
    – Marc Riera
    Sep 17, 2020 at 9:31
  • @user2840748 Can you please explain the choice of those two values ?
    – SebMa
    Sep 7, 2022 at 16:05
  • @user2840748 Should not the maximum value be 4096-Ethernet_Header_Size=4078 ?
    – SebMa
    Sep 7, 2022 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .