isdn/gigaset: ratelimit CAPI message dumps

commit 8e618aad53 upstream.

Introduce a global ratelimit for CAPI message dumps to protect
against possible log flood.
Drop the ratelimit for ignored messages which is now covered by the
global one.

Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tilman Schmidt
2012-04-25 13:02:19 +00:00
committed by Greg Kroah-Hartman
parent 63ce590e41
commit ee9d6e9cbb

View File

@@ -14,6 +14,7 @@
#include "gigaset.h"
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/ratelimit.h>
#include <linux/isdn/capilli.h>
#include <linux/isdn/capicmd.h>
#include <linux/isdn/capiutil.h>
@@ -222,10 +223,14 @@ get_appl(struct gigaset_capi_ctr *iif, u16 appl)
static inline void dump_cmsg(enum debuglevel level, const char *tag, _cmsg *p)
{
#ifdef CONFIG_GIGASET_DEBUG
/* dump at most 20 messages in 20 secs */
static DEFINE_RATELIMIT_STATE(msg_dump_ratelimit, 20 * HZ, 20);
_cdebbuf *cdb;
if (!(gigaset_debuglevel & level))
return;
if (!___ratelimit(&msg_dump_ratelimit, tag))
return;
cdb = capi_cmsg2str(p);
if (cdb) {
@@ -2057,12 +2062,6 @@ static void do_reset_b3_req(struct gigaset_capi_ctr *iif,
CapiResetProcedureNotSupportedByCurrentProtocol);
}
/*
* dump unsupported/ignored messages at most twice per minute,
* some apps send those very frequently
*/
static unsigned long ignored_msg_dump_time;
/*
* unsupported CAPI message handler
*/
@@ -2072,8 +2071,7 @@ static void do_unsupported(struct gigaset_capi_ctr *iif,
{
/* decode message */
capi_message2cmsg(&iif->acmsg, skb->data);
if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000))
dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState);
}
@@ -2084,11 +2082,9 @@ static void do_nothing(struct gigaset_capi_ctr *iif,
struct gigaset_capi_appl *ap,
struct sk_buff *skb)
{
if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000)) {
/* decode message */
capi_message2cmsg(&iif->acmsg, skb->data);
dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
}
/* decode message */
capi_message2cmsg(&iif->acmsg, skb->data);
dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
dev_kfree_skb_any(skb);
}