Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4157055
  • 博文数量: 601
  • 博客积分: 15410
  • 博客等级: 上将
  • 技术积分: 6884
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-16 08:11
个人简介

独学而无友,则孤陋而寡闻!

文章分类

全部博文(601)

文章存档

2020年(1)

2018年(4)

2017年(7)

2016年(42)

2015年(25)

2014年(15)

2013年(36)

2012年(46)

2011年(117)

2010年(148)

2009年(82)

2008年(37)

2007年(41)

分类: BSD

2013-02-03 20:59:13

前些日子出现ping的limit限制,这个很容易理解,是ping的扫描或DDOS。

这几天又出现“Limiting open port RST response from XXX to 200 packets/sec”,想找内核变量,但是一直没找到,实在没办法,搜源代码!

终于搜到了,原来跟icmp是一家子的,用同一个内核变量,即:net.inet.icmp.icmplim=200,代码如下:
文件:/usr/src/sys/netinet/ip_icmp.c

#define N(a)    (sizeof (a) / sizeof (a[0]))
        static struct rate {
                const char      *type;
                struct timeval  lasttime;
                int             curpps;
        } rates[BANDLIM_MAX+1] = {
                { "icmp unreach response" },
                { "icmp ping response" },
                { "icmp tstamp response" },
                { "closed port RST response" },
                { "open port RST response" },
                { "icmp6 unreach response" },
                { "sctp ootb response" }
        };

        /*
         * Return ok status if feature disabled or argument out of range.
         */
        if (V_icmplim > 0 && (u_int) which < N(rates)) {
                struct rate *r = &rates[which];
                int opps = r->curpps;

                if (!ppsratecheck(&r->lasttime, &r->curpps, V_icmplim))
                        return -1;      /* discard packet */
                /*   
                 * If we've dropped below the threshold after having
                 * rate-limited traffic print the message.  This preserves
                 * the previous behaviour at the expense of added complexity.
                 */
                if (V_icmplim_output && opps > V_icmplim)
                        log(LOG_NOTICE, "Limiting %s from %d to %d packets/sec\n",
                                r->type, opps, V_icmplim);
        }
        return 0;                       /* okay to send packet */
#undef N
}
阅读(3960) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~