Linux dropped 排查与定位
一、快速定位思路
二、查看网卡层 dropped
ip -s -s link show <iface>(关注 RX/TX dropped)ifconfig <iface>(关注 RX dropped / TX dropped)ip -s -s link show eth0
RX: bytes packets errors dropped overrun mcast
377786943 473945 0 12 0 0
TX: bytes packets errors dropped carrier collsns
266024587 377467 0 0 0 0
ethtool -S <iface> | egrep 'drop|discard|fifo|over|miss'
cat /proc/net/dev
ethtool -g <iface> 查看/调整 rx/tx ring 大小(需谨慎)。三、查看协议栈与应用层丢包
netstat -s # 总览
netstat -s -u # 只看 UDP
netstat -s -t # 只看 TCP
dropwatch -l kas
dropwatch> start
# Ctrl-C 停止,查看函数栈
输出示例中出现 nf_hook_slow 多为 netfilter 规则丢弃;出现 tcp_v4_rcv 等多为协议栈处理路径。sudo perf record -g -a -e skb:kfree_skb
sudo perf script
sudo iptables-save | grep -i drop
sudo iptables -L INPUT -nv # 观察 pkts 是否增长
dmesg | grep -i "TCP: drop open request"
netstat -ant | awk '$6 ~ /SYN_RECV/ {count++} END {print count}'
若 SYN_RECV 明显增多,可能是 SYN Flood 或 tcp_max_syn_backlog 偏小。四、常见现象与处理要点
ethtool -g 适度增大 rx ring,并检查中断绑定/多队列(RSS)是否均衡。net.core.rmem_max、net.core.rmem_default),并控制发送速率。