利用systemtap定位ifconfig dropped数据包的原因

本文发布时间: 2019-Mar-22
最近在将内核从2.6.32升级到3.0后,通过ifconfig发现dropped数据包明显增多,但是测试上层应用,并不会影响应用的正常工作。其实问题到这里就可以结束了,但作为一个内核爱好者,这只是一个开始。于是决定通过systemtap来分析内核,找到dropped数据包增多的真正原因。1.问题的表面现象如下图所示:(dropped字段非常大,且一直增加) 2.分析内核代码,在dropped字段可能增加的地方,添加kprobe探测点。 3.运行脚本,定位出数据包dropped的代码逻辑 从上面输出可以看出,数据包dropped是因为skb->protocol=0x0004(802.2),linux内核并没有加载该协议的处理函数,导致dropped字段增加。问题原因找到了,dropped的数据包是cisco交换机发送的802.2协议数据包,内核不支持该协议导致,对系统无影响。但是另一个问题就出来了,为什么之前的内核就没有显示这么多dropped呢???其实看一下2.6.32内核代码,你会发现netif_receive_skb函数中,当出现不支持的protocol的时候,内核只是简单的drop,并不会增加dev->stat.dropped字段,但在3.0内核中,将这种数据包也统计到dev->stat.dropped中。check一下代码的改动记录,不难发现从2.6.37内核开始,该部分进行了改动commit caf586e5f23cebb2a68cbaf288d59dbbf2d74052Author: Eric Dumazet <[email protected]>Date: Thu Sep 30 21:06:55 2010 +0000net: add a core netdev->rx_dropped counterIn various situations, a device provides a packet to our stack and wedrop it before it enters protocol stack :- softnet backlog full (accounted in /proc/net/softnet_stat)- bad vlan tag (not accounted)- unknown/unregistered protocol (not accounted)We can handle a per-device counter of such dropped frames at core level,and automatically adds it to the device provided stats (rx_dropped), sothat standard tools can be used (ifconfig, ip link, cat /proc/net/dev)This is a generalization of commit 8990f468a (net: rx_droppedaccounting), thus reverting it.Signed-off-by: Eric Dumazet <[email protected]>Signed-off-by: David S. Miller <[email protected]>世界又清静了。。。。


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:10pm
栏目列表