Skip to content
Search RHEL

This page uses Chinese content. Search opens the Chinese documentation.

    Browse this documentation

    RHEL 10 网络排障:drop、offload 与 ring buffer 先看哪

    This content is not available in your language yet.

    “网络丢包”不是一层的事:可能丢在网卡 ring、驱动、协议栈、socket 缓冲,或者根本没丢只是重传。顺序错了会在错误的地方调参数。本页用 390 的 eth0 走一遍从底层到协议栈的检查。

    在 PVE 390 rhel10-lab(RHEL 10.2,eth0 virtio)执行:

    Terminal window
    ip -s link show eth0
    sudo ethtool -S eth0 | grep -Ei 'drop|err|miss|discard'
    ethtool -k eth0 | grep -E 'checksumming|segmentation|receive-offload'
    sudo ethtool -g eth0
    nstat -az | grep -E 'TcpRetransSegs|IpInDiscards|UdpRcvbufErrors|TcpExtListenDrops'

    E3 记录:plans/content-expansion/evidence/rhel/rhel-net-troubleshoot/run.json(6 步,含 counters/offload/ring 输出 sha256)。

    1. 网卡/驱动:ip -s link 的 errors/dropped、ethtool -S 的 *_drops;
    2. offload:ethtool -k 的 GRO/GSO/TSO/checksum;
    3. ring buffer:ethtool -g 的 RX/TX 当前值与最大值;
    4. 协议栈/socket:nstat 的重传、IpInDiscards、UdpRcvbufErrors、ss -s。
    $ ip -s link show eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP
    RX: bytes packets errors dropped missed mcast
    15344143093 3313639 0 0 0 0
    TX: bytes packets errors dropped carrier collsns
    3989742186 2511746 0 0 0 0

    RX/TX 的 errors/dropped 全 0,说明这一层没有明显丢弃。

    $ sudo ethtool -S eth0 | grep -Ei 'drop|err|miss|discard'
    rx_drops: 0
    rx_xdp_drops: 0
    tx_xdp_tx_drops: 0
    rx0_drops: 0
    rx0_xdp_drops: 0
    tx0_xdp_tx_drops: 0

    virtio 的统计项比物理网卡少;物理卡还会有 rx_missed_errors、rx_fifo_errors、tx_aborted_errors 等,名字以驱动为准。

    $ ethtool -k eth0 | grep -E 'checksumming|segmentation|receive-offload'
    rx-checksumming: on [fixed]
    tx-checksumming: on
    tcp-segmentation-offload: on
    generic-segmentation-offload: on
    generic-receive-offload: on

    [fixed] 表示不能改。做对照时可以临时关 GRO:

    Terminal window
    sudo ethtool -K eth0 gro off
    ethtool -k eth0 | grep generic-receive-offload
    # generic-receive-offload: off
    sudo ethtool -K eth0 gro on

    gro off 后小包会更多,CPU 软中断会上升;只用于定位,不要长期关。

    $ sudo ethtool -g eth0
    Ring parameters for eth0:
    Pre-set maximums:
    RX: 1024
    TX: 256
    Current hardware settings:
    RX: 1024
    TX: 256

    RX 已经顶到最大值 1024;如果 ethtool -S 里 rx_fifo_errors/rx_missed_errors 增长,才考虑加 ring 或加队列。ethtool -G eth0 rx 2048 超过最大值会报 Invalid argument。

    $ nstat -az | grep -E 'TcpRetransSegs|IpInDiscards|UdpRcvbufErrors|TcpExtListenDrops'
    IpInDiscards 0
    TcpRetransSegs 124
    UdpRcvbufErrors 0
    TcpExtListenDrops 0
    • TcpRetransSegs 有值不等于网卡丢包,可能是对端/链路/超时;
    • UdpRcvbufErrors 增长说明应用收得慢、socket buffer 不够;
    • TcpExtListenDrops 增长说明 accept 队列满。

    配合 ss -s、ss -lnt 的 Recv-Q/Send-Q 看 socket 层。

    1. ip -s link 有没有 errors/dropped;
    2. ethtool -S 哪个 *_drops 在涨;
    3. ethtool -g 是否顶满;
    4. ethtool -k 做 GRO/TSO 对照;
    5. nstat 看重传/缓冲/accept 队列;
    6. 最后才动 sysctl(rmem_max、wmem_max、netdev_max_backlog)。
    • 记录基线(重启后计数会清零);
    • 区分物理丢包与 TCP 重传;
    • ring 是否已到最大值;
    • offload 改动是否已恢复;
    • nstat 的增量而不是绝对值;
    • 变更前有回滚命令。
    • 未在物理网卡上测试(本次 virtio);
    • 未制造真实丢包/拥塞;
    • 未测试多队列/RSS 与 ethtool -L;
    • 未测试 tc/netem 注入。