Ping 响应丢失,但可以在 tcpdump 中看到它们

Ping 响应丢失,但可以在 tcpdump 中看到它们

红帽2.6.32-754.el6.x86_64

我有一个 FPGA 卡作为 NIC 并带有相关驱动程序。

在我的 RH 主机上,如果我通过 FPGA NIC 运行 ping,我会看到许多丢失的响应。但是,如果我还在 icmp 上运行 tcpdump 和过滤器,我可以看到响应。

以下是 ping 的示例输出(请注意许多缺失的序列号):

 from 172.16.1.9: icmp_seq=465 ttl=128 time=0.600 ms
64 bytes from 172.16.1.9: icmp_seq=467 ttl=128 time=0.490 ms
64 bytes from 172.16.1.9: icmp_seq=480 ttl=128 time=0.565 ms
64 bytes from 172.16.1.9: icmp_seq=482 ttl=128 time=0.590 ms
64 bytes from 172.16.1.9: icmp_seq=516 ttl=128 time=0.448 ms
64 bytes from 172.16.1.9: icmp_seq=526 ttl=128 time=0.649 ms
64 bytes from 172.16.1.9: icmp_seq=528 ttl=128 time=0.534 ms
64 bytes from 172.16.1.9: icmp_seq=539 ttl=128 time=0.424 ms
64 bytes from 172.16.1.9: icmp_seq=546 ttl=128 time=0.606 ms
64 bytes from 172.16.1.9: icmp_seq=562 ttl=128 time=0.521 ms
64 bytes from 172.16.1.9: icmp_seq=569 ttl=128 time=0.651 ms
64 bytes from 172.16.1.9: icmp_seq=591 ttl=128 time=0.503 ms
64 bytes from 172.16.1.9: icmp_seq=617 ttl=128 time=0.652 ms
64 bytes from 172.16.1.9: icmp_seq=642 ttl=128 time=0.503 ms
64 bytes from 172.16.1.9: icmp_seq=643 ttl=128 time=0.672 ms
64 bytes from 172.16.1.9: icmp_seq=644 ttl=128 time=0.443 ms
64 bytes from 172.16.1.9: icmp_seq=657 ttl=128 time=0.427 ms
64 bytes from 172.16.1.9: icmp_seq=668 ttl=128 time=0.503 ms
64 bytes from 172.16.1.9: icmp_seq=704 ttl=128 time=0.332 ms
64 bytes from 172.16.1.9: icmp_seq=741 ttl=128 time=0.486 ms
64 bytes from 172.16.1.9: icmp_seq=742 ttl=128 time=0.478 ms
64 bytes from 172.16.1.9: icmp_seq=751 ttl=128 time=0.513 ms
64 bytes from 172.16.1.9: icmp_seq=753 ttl=128 time=0.511 ms
From 172.16.0.156 icmp_seq=788 Destination Host Unreachable
From 172.16.0.156 icmp_seq=789 Destination Host Unreachable
From 172.16.0.156 icmp_seq=790 Destination Host Unreachable
From 172.16.0.156 icmp_seq=792 Destination Host Unreachable
From 172.16.0.156 icmp_seq=793 Destination Host Unreachable
From 172.16.0.156 icmp_seq=794 Destination Host Unreachable
64 bytes from 172.16.1.9: icmp_seq=798 ttl=128 time=0.671 ms
64 bytes from 172.16.1.9: icmp_seq=799 ttl=128 time=0.608 ms
64 bytes from 172.16.1.9: icmp_seq=801 ttl=128 time=0.538 ms
64 bytes from 172.16.1.9: icmp_seq=814 ttl=128 time=0.402 ms
64 bytes from 172.16.1.9: icmp_seq=923 ttl=128 time=0.458 ms
From 172.16.0.156 icmp_seq=952 Destination Host Unreachable
From 172.16.0.156 icmp_seq=953 Destination Host Unreachable
From 172.16.0.156 icmp_seq=954 Destination Host Unreachable
From 172.16.0.156 icmp_seq=956 Destination Host Unreachable
From 172.16.0.156 icmp_seq=957 Destination Host Unreachable
From 172.16.0.156 icmp_seq=958 Destination Host Unreachable
64 bytes from 172.16.1.9: icmp_seq=966 ttl=128 time=0.472 ms
From 172.16.0.156 icmp_seq=979 Destination Host Unreachable
From 172.16.0.156 icmp_seq=980 Destination Host Unreachable
From 172.16.0.156 icmp_seq=981 Destination Host Unreachable
64 bytes from 172.16.1.9: icmp_seq=993 ttl=128 time=0.586 ms
^C
--- 172.16.1.9 ping statistics ---
997 packets transmitted, 96 received, +15 errors, 90% packet loss, time 996823ms
rtt min/avg/max/mdev = 0.332/31.837/2001.563/226.238 ms, pipe 3

这是同时运行的 tcpdump 的片段:

16:27:24.300566 IP 172.16.1.9 > 172.16.0.156: ICMP echo reply, id 56849, seq 990, length 64
    0x0000:  4500 0054 571e 0000 8001 89c5 ac10 0109  E..TW...........
    0x0010:  ac10 009c 0000 e573 de11 03de ecd8 f65b  .......s.......[
    0x0020:  0000 0000 9294 0400 0000 0000 1011 1213  ................
    0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
    0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&'()*+,-./0123
    0x0050:  3435 3637 0000                           4567..
16:27:25.300102 IP 172.16.0.156 > 172.16.1.9: ICMP echo request, id 56849, seq 991, length 64
    0x0000:  4500 0054 0000 4000 4001 e0e3 ac10 009c  E..T..@.@.......
    0x0010:  ac10 0109 0800 5073 de11 03df edd8 f65b  ......Ps.......[
    0x0020:  0000 0000 1e94 0400 0000 0000 1011 1213  ................
    0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
    0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&'()*+,-./0123
    0x0050:  3435 3637                                4567
16:27:25.300683 IP 172.16.1.9 > 172.16.0.156: ICMP echo reply, id 56849, seq 991, length 64
    0x0000:  4500 0054 571f 0000 8001 89c4 ac10 0109  E..TW...........
    0x0010:  ac10 009c 0000 5873 de11 03df edd8 f65b  ......Xs.......[
    0x0020:  0000 0000 1e94 0400 0000 0000 1011 1213  ................
    0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
    0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&'()*+,-./0123
    0x0050:  3435 3637 0000                           4567..
16:27:26.300166 IP 172.16.0.156 > 172.16.1.9: ICMP echo request, id 56849, seq 992, length 64
    0x0000:  4500 0054 0000 4000 4001 e0e3 ac10 009c  E..T..@.@.......
    0x0010:  ac10 0109 0800 0a72 de11 03e0 eed8 f65b  .......r.......[
    0x0020:  0000 0000 6394 0400 0000 0000 1011 1213  ....c...........
    0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
    0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&'()*+,-./0123
    0x0050:  3435 3637                                4567
16:27:26.300766 IP 172.16.1.9 > 172.16.0.156: ICMP echo reply, id 56849, seq 992, length 64
    0x0000:  4500 0054 5720 0000 8001 89c3 ac10 0109  E..TW...........
    0x0010:  ac10 009c 0000 1272 de11 03e0 eed8 f65b  .......r.......[
    0x0020:  0000 0000 6394 0400 0000 0000 1011 1213  ....c...........
    0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
    0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&'()*+,-./0123
    0x0050:  3435 3637 0000                           4567..
16:27:27.300141 IP 172.16.0.156 > 172.16.1.9: ICMP echo request, id 56849, seq 993, length 64
    0x0000:  4500 0054 0000 4000 4001 e0e3 ac10 009c  E..T..@.@.......
    0x0010:  ac10 0109 0800 2071 de11 03e1 efd8 f65b  .......q.......[
    0x0020:  0000 0000 4c94 0400 0000 0000 1011 1213  ....L...........
    0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
    0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&'()*+,-./0123
    0x0050:  3435 3637                                4567
16:27:27.300694 IP 172.16.1.9 > 172.16.0.156: ICMP echo reply, id 56849, seq 993, length 64
    0x0000:  4500 0054 5721 0000 8001 89c2 ac10 0109  E..TW!..........
    0x0010:  ac10 009c 0000 2871 de11 03e1 efd8 f65b  ......(q.......[
    0x0020:  0000 0000 4c94 0400 0000 0000 1011 1213  ....L...........
    0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
    0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&'()*+,-./0123
    0x0050:  3435 3637 0000                           4567..
^C
1034 packets captured
1036 packets received by filter
0 packets dropped by kernel
1034 packets captured
1036 packets received by filter
0 packets dropped by kernel

因此,希望您可以在 tcpdump 输出中看到带有序列号 992、991 和 990 的回显答复,而 ping 完全错过了这些答复。

如果我切换到内置 NIC,则 ping 会按预期工作。这让我怀疑我的司机。但是,如果是驱动程序造成的,tcpdump 是否也看不到 icmp 回复?

答案1

是我的司机!与 NET_IP_ALIGN 偏移量相关的内容感到困惑,并且 ICMP 响应的目标 MAC 地址的前两个字节被驱动程序破坏。显然 tcpdump 不关心 MAC 地址(混杂模式),但 ping 关心。

有趣的是,如果目标 MAC 地址的前两个字节是 0x00,则 ping 不会看到回复,但看起来如果它们是其他任何字节,那么它们就会通过!所以它们似乎不必是正确的值,只是不是 0x00 即可。这可能又是我的驱动程序的问题。

相关内容