linux 从softnet_stat查看内核丢包信息

时间:2023-03-09 07:42:54
linux 从softnet_stat查看内核丢包信息

1、从系统整体来考虑,通过netstat 查看:

[root@localhost net]# netstat -s |grep drop
3168 outgoing packets dropped
15184 SYNs to LISTEN sockets dropped

2、从cpu角度来考虑,通过cat /proc/net/softnet_stat查看:

cat /proc/net/softnet_stat
05e4b183  0000007c       01655efc
057c0001  0000007d
04f4078d  0000006a       01658db4
047e1d5c  0000007f       01655cbe
044aa9f7         0165a323
         0164b10c
043e9dfc  0000009d       0164c562
  0000008f       0164fe53
0434a871  0000009b
043f4ed3  0000009f       01655e71
044775a0  0000009d       016517ba
044b5259  000000a3       016508f2
045eaab3  0000009c
045bbc3a  000000a7       016510f3
0449ed94  000000ad       016599d2
0455b589         016489f9
04585e74         01657eee
046c86e9         01654cd7
03f2dcbb         0164a311
03ed4615  0000009e       01648dd1
053fdf58  0000008b       016fd7fa
050683cb  000000a0       01717e2f
04a2add6         01717ee3
045a33e3  000000a1
0445ab77  0000008e       0170ea41
         01714fa4
04345ccd         01721a2b
04350dec  0000008d       01722db2
04339c71         017173fc
044379f3  0000008d       0171e9cb
0427bc92         0171b271
0437a0b3  0000008b       0171561d
0444b485         0173080d
044786fc  0000008b
043b5c96  000000a0       017143ed
04329ef8
044d9137  0000008e       01720c75
044f11a2         0170a862
04614eaf  0000009a       017232d7
0453a0d0         0172ff7a
0529bbfd  000000a7       01639da0

各列的含义如下:

static int softnet_seq_show(struct seq_file *seq, void *v)
{
    struct softnet_data *sd = v;

    seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
           sd->processed, sd->dropped, sd->time_squeeze, ,
           , , , , /* was fastroute */
           sd->cpu_collision, sd->received_rps);
    return ;
}

每一行是每个核的情况,第一列是收到的报文,第二列是drop的报文,由于netdev_max_backlog队列溢出而被丢弃的包总数。第三列是net_rx_action中收包,一次的软中断的触发还不能处理完目前已经接收的数据,因而要设置下轮软中断,time_squeeze 就表示设置的次数.倒数第二例是cpu冲突的次数,最后一列是rps的次数。如果第二列有数值,则可以通过下面方式来尝试规避:

cat /proc/sys/net/core/netdev_max_backlog
65536

将这个值改大。

3.从设备角度来考虑:

ethtool -S eth0|grep drop
rx_dropped: 0
tx_dropped: 0
port.rx_dropped: 0
port.tx_dropped_link_down: 0