r8169 网卡驱动

某台 11.10  3.0.0-12-generic 的机器网络异常,ifconfig 有大量的丢包,ssh 时不时 hung 住:
# ifconfig
eth0      Link encap:Ethernet  HWaddr 44:44:d6:b4:1e:7e
          inet addr:10.18.102.201  Bcast:10.18.102.255  Mask:255.255.255.0
          inet6 addr: fe80::5604:a6ff:feb4:1e7e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:21274 errors:0 dropped:21274 overruns:0 frame:21274
          TX packets:12028 errors:0 dropped:81 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9653617 (9.6 MB)  TX bytes:2188437 (2.1 MB)
          Interrupt:46 Base address:0xc000

syslog 有大量的如下信息:
Oct 10 11:21:29 jaseywang kernel: [  905.012397] r8169 0000:04:00.0: eth0: link up
Oct 10 11:21:32 jaseywang kernel: [  908.289727] r8169 0000:04:00.0: eth0: link up
Oct 10 11:22:19 jaseywang kernel: [  954.627060] r8169 0000:04:00.0: eth0: link up
Oct 10 11:23:20 jaseywang kernel: [ 1015.182140] r8169 0000:04:00.0: eth0: link up
Oct 10 11:23:37 jaseywang kernel: [ 1033.004186] r8169 0000:04:00.0: eth0: link up
Oct 10 11:24:16 jaseywang kernel: [ 1071.335548] r8169 0000:04:00.0: eth0: link up
Oct 10 11:25:02 jaseywang kernel: [ 1117.070819] r8169 0000:04:00.0: eth0: link up
Oct 10 11:25:42 jaseywang kernel: [ 1156.881366] r8169 0000:04:00.0: eth0: link up
Oct 10 11:26:13 jaseywang kernel: [ 1188.351029] r8169 0000:04:00.0: eth0: link up
Oct 10 11:26:43 jaseywang kernel: [ 1217.619851] r8169 0000:04:00.0: eth0: link up
Oct 10 11:26:50 jaseywang kernel: [ 1225.107516] r8169 0000:04:00.0: eth0: link up
Oct 10 11:26:52 jaseywang kernel: [ 1227.069138] r8169 0000:04:00.0: eth0: link up
Oct 10 11:26:54 jaseywang kernel: [ 1228.735701] r8169 0000:04:00.0: eth0: link up
Oct 10 11:26:56 jaseywang kernel: [ 1231.040210] r8169 0000:04:00.0: eth0: link up
Oct 10 11:27:28 jaseywang kernel: [ 1262.864740] r8169 0000:04:00.0: eth0: link up
Oct 10 11:28:07 jaseywang kernel: [ 1302.013430] r8169 0000:04:00.0: eth0: link up

更换网线无果,想到可能是网卡驱动的问题,确实是 r8169 这个驱动惹得祸,10 年就有人发现此类问题了。 将其更换为 r8168。下载这个链接的驱动。

卸载当前的 r8169:
# rmmod r8169

解压安装:
# tar zjvf r8168-8.032.00.tar.bz2
# cd r8168-8.032.00/
# ./autorun.sh

完毕,检查确认:
# lsmod  | grep r8168
r8168                 244911  0

将 r8169 加入 blacklist:
$ cat /etc/modprobe.d/blacklist-r8169.conf:
blacklist r8169

基本是把这个的链接翻译了一遍。这篇文章也确认了在 Ubuntu 的 10.10, 11.04, 11.10 版本在使用 kernel 默认的驱动时上会出现此类的问题。