aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2012-04-25 09:02:19 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-01 03:12:53 -0400
commitee9d6e9cbb6655e2d34616b3f5e6e07699f40aec (patch)
tree4d029b51bef25460373b41c2520138c821e3bed1
parent63ce590e41683a7ba1895a1d79b29a62b06c7613 (diff)
isdn/gigaset: ratelimit CAPI message dumps
commit 8e618aad5348b6e6c5a90e8d97ea643197963b20 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>
-rw-r--r--drivers/isdn/gigaset/capi.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 658e75f18d0..d1dde6577fa 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -14,6 +14,7 @@
14#include "gigaset.h" 14#include "gigaset.h"
15#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
16#include <linux/seq_file.h> 16#include <linux/seq_file.h>
17#include <linux/ratelimit.h>
17#include <linux/isdn/capilli.h> 18#include <linux/isdn/capilli.h>
18#include <linux/isdn/capicmd.h> 19#include <linux/isdn/capicmd.h>
19#include <linux/isdn/capiutil.h> 20#include <linux/isdn/capiutil.h>
@@ -222,10 +223,14 @@ get_appl(struct gigaset_capi_ctr *iif, u16 appl)
222static inline void dump_cmsg(enum debuglevel level, const char *tag, _cmsg *p) 223static inline void dump_cmsg(enum debuglevel level, const char *tag, _cmsg *p)
223{ 224{
224#ifdef CONFIG_GIGASET_DEBUG 225#ifdef CONFIG_GIGASET_DEBUG
226 /* dump at most 20 messages in 20 secs */
227 static DEFINE_RATELIMIT_STATE(msg_dump_ratelimit, 20 * HZ, 20);
225 _cdebbuf *cdb; 228 _cdebbuf *cdb;
226 229
227 if (!(gigaset_debuglevel & level)) 230 if (!(gigaset_debuglevel & level))
228 return; 231 return;
232 if (!___ratelimit(&msg_dump_ratelimit, tag))
233 return;
229 234
230 cdb = capi_cmsg2str(p); 235 cdb = capi_cmsg2str(p);
231 if (cdb) { 236 if (cdb) {
@@ -2058,12 +2063,6 @@ static void do_reset_b3_req(struct gigaset_capi_ctr *iif,
2058} 2063}
2059 2064
2060/* 2065/*
2061 * dump unsupported/ignored messages at most twice per minute,
2062 * some apps send those very frequently
2063 */
2064static unsigned long ignored_msg_dump_time;
2065
2066/*
2067 * unsupported CAPI message handler 2066 * unsupported CAPI message handler
2068 */ 2067 */
2069static void do_unsupported(struct gigaset_capi_ctr *iif, 2068static void do_unsupported(struct gigaset_capi_ctr *iif,
@@ -2072,8 +2071,7 @@ static void do_unsupported(struct gigaset_capi_ctr *iif,
2072{ 2071{
2073 /* decode message */ 2072 /* decode message */
2074 capi_message2cmsg(&iif->acmsg, skb->data); 2073 capi_message2cmsg(&iif->acmsg, skb->data);
2075 if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000)) 2074 dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
2076 dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
2077 send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState); 2075 send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState);
2078} 2076}
2079 2077
@@ -2084,11 +2082,9 @@ static void do_nothing(struct gigaset_capi_ctr *iif,
2084 struct gigaset_capi_appl *ap, 2082 struct gigaset_capi_appl *ap,
2085 struct sk_buff *skb) 2083 struct sk_buff *skb)
2086{ 2084{
2087 if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000)) { 2085 /* decode message */
2088 /* decode message */ 2086 capi_message2cmsg(&iif->acmsg, skb->data);
2089 capi_message2cmsg(&iif->acmsg, skb->data); 2087 dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
2090 dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
2091 }
2092 dev_kfree_skb_any(skb); 2088 dev_kfree_skb_any(skb);
2093} 2089}
2094 2090