zoukankan      html  css  js  c++  java
  • 利用systemtap定位ifconfig dropped数据包的原因

    http://blog.chinaunix.net/uid-20662820-id-3842431.html

     
    欢迎转载,转载请保留文章的完整性!
    Author: Tony <tingw.liu@gmail.com>
    Date: 2013年8月10日周六 @青岛


    最近在将内核从2.6.32升级到3.0后,通过ifconfig发现dropped数据包明显增多,但是测试上层应用,并不会影响应用的正常工作。其实问题到这里就可以结束了,但作为一个内核爱好者,这只是一个开始。
    于是决定通过systemtap来分析内核,找到dropped数据包增多的真正原因。关于systemtap的介绍可以参考我的另一篇博文http://blog.chinaunix.net/uid-20662820-id-3799149.html
    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 caf586e5f23cebb2a68cbaf288d59dbbf2d74052
    Author: Eric Dumazet <eric.dumazet@gmail.com>
    Date:   Thu Sep 30 21:06:55 2010 +0000
        net: add a core netdev->rx_dropped counter

        In various situations, a device provides a packet to our stack and we
        drop 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), so
        that standard tools can be used (ifconfig, ip link, cat /proc/net/dev)

        This is a generalization of commit 8990f468a (net: rx_dropped
        accounting), thus reverting it.

        Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
        Signed-off-by: David S. Miller <davem@davemloft.net>

    世界又清静了。。。。
  • 相关阅读:
    ansible 通过堡垒机/跳板机 访问目标机器需求实战(ssh agent forward)
    运维标准化与流程化建设
    运维与自动化运维发展方向
    文件atime未变问题的研究
    ansible 任务委派 delegate_to
    ansible 调优
    windows中安装模拟器后修改模拟器中的hosts方法
    负载均衡服务器主要考量三个指标
    DRBD+NFS+Keepalived高可用环境
    sshpass
  • 原文地址:https://www.cnblogs.com/zengkefu/p/6372271.html
Copyright © 2011-2022 走看看